/**
 * @author ABC
 */
;(function($) {$.fn.slider = function(options) {
    return this.each(function(idx) {
		var timer = null;
		options = jQuery.extend({
			animSpeed: "slow"
		},options || {});
		var $slots = $(this).find("li");
		var slotCount = $slots.size();
		var slotWidth = $(this).width();
		
		$(this).wrap('<div id="scrollContainer' + idx + '">');
		var $cont = $("#scrollContainer" + idx);
		$cont.css({
			"width": slotWidth,
			"overflow": "hidden"
		});
		$(this).css({
			"display" : "block",
			"width": slotWidth * slotCount
		});
		$slots.css({
			"display": "block",
			"width": slotWidth,
			"float": "left"
		});
		if (slotCount > 1) {
			currSlot = 0;
			$navDiv = $('<div class="imgNavTable"></div>');
			$nextButton = $('<a class="imgNext" href="#">next</a>');
			$nextButton.click(function(){
				curr = $cont.scrollLeft();
				$cont.stop(true, true);
				target = $cont.scrollLeft();
				$cont.scrollLeft(curr).animate({"scrollLeft": target + slotWidth}, "slow");
				return false;
			});
			$prevButton = $('<a class="imgPrev" href="#">prev</a>');
			$prevButton.click(function(){
				curr = $cont.scrollLeft();
				$cont.stop(true, true);
				target = $cont.scrollLeft();
				$cont.scrollLeft(curr).animate({"scrollLeft": target - slotWidth}, "slow");
				return false;
			});
			$("#destaquesContainer").before($prevButton);
			$("#destaquesContainer").after($nextButton);
		}
/*		timer = setInterval(function() {
			var n = Math.round(Math.random() * slotCount);
			$cont.stop(true, true).animate({"scrollLeft": n * slotWidth}, "slow");
		}, 5000);*/
	});
}})(jQuery);

$(document).ready(function() {
	$("#mycarousel").slider();
});

