(function(jQuery) {
	var current = false;
	
	jQuery.fn.rotator = function() {
		offset = 0;
		p = jQuery(this).parent();
		jQuery('#carrousel-back').click(goBack);
		jQuery('#carrousel-forward').click(goForward);
		jQuery('#carrousel-btns').fadeIn('slow');
		
		w = 0;
		this.each(function(el) {
			el = jQuery(this);
			w += el.width(); 
		});
		p.css('width', w+'px');
		
		function goBack() {
			l = "+=385";
			if (offset==0) {
				offset = 385-w;
				l = offset;
			}
			else {
				offset += 385;
			}
			p.animate({"left": l+"px"}, 'slow');
		}
		
		function goForward() {
			l = "-=385";
			if (offset==385-w) {
				offset = 0;
				l = offset;
			}
			else {
				offset -= 385;
			}
			p.animate({"left": l+"px"}, 'slow');
		}
	
		return this;
	};
})(jQuery);

jQuery(document).ready(function() {
	jQuery('.carrousel-info').rotator();
});

