//FUNCTIONS BELLOW  
  
//slide function  
function slide(where){ 
var obj = $("#slidesContainer"); 
var s = $(".slidenews", obj).length;
var w = $(".slidenews", obj).width(); 
var h = $(".slidenews", obj).height(); 
$("#slidesContainer").width(w); 
var ts = s-1;
var t = 0;
var ot = t;
$("#cadre", $("#slidesContainer")).css('height',s*h);	
  

            //get the item width  
            var item_height = $('#cadre .slidenews').height();
			

            /* using a if statement and the where variable check 
            we will check where the user wants to slide (left or right)*/  
            if(where == 'previous'){  
                //...calculating the new left indent of the unordered list (ul) for left sliding
				//t = (t<=0) ? (options.continuous ? ts : 0) : t-1;
				
			/*	if(t<=0)
				{
					t = 0;
				}else{
					t-1;
				}*/
				
            // var top_indent = t*item_height*-1;
			var top_indent = parseInt($('#cadre').css('marginTop')) + item_height; 				
			 
            }else{  
                //...calculating the new left indent of the unordered list (ul) for right sliding 
			//	t = (ot>=ts) ? (options.continuous ? 0 : ts) : t+1;
			
			/*	if(ot>=ts)
				{
					t = ts;
				}else{
					t+1;
				}*/
				
           // var top_indent = t*item_height*-1;
			var top_indent = parseInt($('#cadre').css('marginTop')) - item_height; 				
            }  
  
            //make the sliding effect using jQuery's animate function... '  
           $('#cadre:not(:animated)').animate({marginTop : top_indent},500,function(){
  
                /* when the animation finishes use the if statement again, and make an ilussion 
                of infinity by changing place of last or first item*/  
                if(where == 'previous'){  
                    //...and if it slided to left we put the last item before the first item  
                    $('#cadre .slidenews:first').before($('#cadre .slidenews:last'));  
                }else{  
                    //...and if it slided to right we put the first item after the last item  
                    $('#cadre .slidenews:last').after($('#cadre .slidenews:first'));  
                }  
  
                //...and then just get back the default left indent
                $('#cadre').css({marginTop : '0'});
            });  
}
