(function($) {

	$.fn.slider = function(options)
	{
		
		return this.each(function()
		{  
			obj = $("#vslider"); 				
			obj1 = $("#descri");
							
			var s = $("li", obj).length;
			var w = obj.width(); 
			var h = obj.height(); 
			
			var s1 = $("li", obj1).length;
			var w1 = obj1.width(); 
			var h1 = obj1.height(); 	
		
			var ts = s-1;
			var t = 0;


			$("ul", obj).css('width',s*w);
			$("ul", obj1).css('width',s1*w1);
						
			$("#next").click(function()
			{		
				animate("next");
				obj.stopTime('controlled');
			});
			
			$("#prev").click(function()
			{		
				animate("prev");
				obj.stopTime('controlled');
			});	
			
			function animate(dir)
			{
				if(dir == "next")
				{
					t = (t>=ts) ? 0 : t+1;	
				}
				else
				{
					t = (t<=0) ? ts : t-1;
				};								
				p = (t*w*-1);
				p1 = (t*w1*-1);
				$("ul",obj).animate(
					{ marginLeft: p }, 
					800
				);				
				$("ul",obj1).animate(
					{ marginLeft: p1 }, 
					800
				);				
			};
			obj.everyTime(4000,'controlled',function(i) 
			{
			     animate("next");
			});
		});
	};
})(jQuery);
