var Slider = 
{
	init: function(cssSelector)
	{
		
		jQuery(cssSelector).each
		(
		 	function(e)
			{
				
				var item     = jQuery(this);
				var previous = jQuery('a.previous',this);
				var next     = jQuery('a.next',this);
				var list     = jQuery('ul',this);
				
				var initPos  = list.css('left').replace('px','') * 1;
				
				var perMove  = 127;
				
				list.attr('initPos',list.css('left'));
				
				
				//Uso de width 	
				var availArea= item.css('width').replace('px','') -
								(previous.width() + 1) - (next.width() + 1);

				var viewSteps= Math.round(availArea / perMove);
				
				next.bind('click',
							function(e)
							{
								if(!list.is(':animated'))
								{
									var curPos = list.css('left').replace('px','') * 1;
									curPos    -= perMove;
									
									var calc   = curPos;
									if(calc < 0)calc *= -1;
									
									if(list.width() - calc >= (perMove * viewSteps))
										list.animate({left: curPos + 'px'});
								}
								
								e.preventDefault();
								e.stopPropagation();
							});
				
				previous.bind('click',
							  function(e)
							  {
								if(!list.is(':animated'))
								{
									var curPos = list.css('left').replace('px','') * 1;
									curPos    += perMove;
									
									if(curPos <= initPos)
										list.animate({left: curPos + 'px'});
								}
								
								e.preventDefault();
								e.stopPropagation();
								
								
							  });
			}
		);
	}
};
