$(function() {

	var totalPanelsBot		= $("#scrollContainerbot").children().size();	

	var movingDistance_bot	    = 300;

	var $panels_bot			= $('#sliderbot .scrollContainerbot > div');
	var $container_bot			= $('#sliderbot .scrollContainerbot');

	$panels_bot.css({'float' : 'left','position' : 'relative'});
    
	$("#sliderbot").data("currentlyMoving_bot", false);
	
	$container_bot
		.css('width', ($panels_bot[0].offsetWidth * $panels_bot.length) + 100 )
		.css('left', "0");

	var scroll = $('#sliderbot .scrollbot').css('overflow', 'hidden');
	
	//direction true = right, false = left
	function changebot(direction) {
	   
	    //if not at the first or last panel
		if((direction && !(curPanel_bot < totalPanelsBot)) || (!direction && (curPanel_bot <= 1))) { return false; }	
        
        //if not currently moving
        if (($("#sliderbot").data("currentlyMoving_bot") == false)) {
            
			$("#sliderbot").data("currentlyMoving_bot", true);
			
			var next         = direction ? curPanel_bot + 1 : curPanel_bot - 1;
			var leftValue    = $(".scrollContainerbot").css("left");
			var movement	 = direction ? parseFloat(leftValue, 10) - movingDistance_bot : parseFloat(leftValue, 10) + movingDistance_bot;
		
			$(".scrollContainerbot")
				.stop()
				.animate({
					"left": movement
				}, function() {
					$("#sliderbot").data("currentlyMoving_bot", false);
				});
					
			curPanel_bot = next;			
			//remove all previous bound functions
			$("#panelbot_"+(curPanel_bot+1)).unbind();	
			
            //remove all previous bound functions															
			$("#panelbot_"+(curPanel_bot-1)).unbind();
			
			//remove all previous bound functions
			$("#panelbot_"+curPanel_bot).unbind();
		}
	}
	
	// Set up "Current" panel and next and prev
	
	var curPanel_bot = 0;
	
	//when the left/right arrows are clicked
	$(".rightbot").click(function(){ changebot(true); });	
	$(".leftbot").click(function(){ changebot(false); });
	
});
