$(function() {
	
	var totalPanelsVert			= $(".scrollContainerVert").children().size();	

	var movingDistance	    = 120;

	var $panels				= $('#sliderVert .scrollContainerVert > div');
	var $container			= $('#sliderVert .scrollContainerVert');

	$panels.css({'position' : 'relative'});
    
	$("#sliderVert").data("currentlyMoving", false);
	
	$container
		.css('height', ($panels[0].offsetHeight * $panels.length) + 120 )
		.css('top', "0");

	var scroll = $('#sliderVert .scrollVert').css('overflow', 'hidden');
	
	//direction true = right, false = left
	function change(direction) {
	  
	    //if not at the first or last panel
		if((direction && !(curPanel < totalPanelsVert)) || (!direction && (curPanel <= 1))) { return false; }	
        
        //if not currently moving
        if (($("#sliderVert").data("currentlyMoving") == false)) {
            
			$("#sliderVert").data("currentlyMoving", true);
			
			var next         = direction ? curPanel + 1 : curPanel - 1;
			var botValue    = $(".scrollContainerVert").css("top");
			var movement	 = direction ? parseFloat(botValue, 10) - movingDistance : parseFloat(botValue, 10) + movingDistance;
		
			$(".scrollContainerVert")
				.stop()
				.animate({
					"top": movement
				}, function() {
					$("#sliderVert").data("currentlyMoving", false);
				});
					
			curPanel = next;			
			//remove all previous bound functions
			$("#panelVert_"+(curPanel+1)).unbind();	
			
            //remove all previous bound functions															
			$("#panelVert_"+(curPanel-1)).unbind();
			
			//remove all previous bound functions
			$("#panelVert_"+curPanel).unbind();
		}
	}
	
	// Set up "Current" panel and next and prev
	
	var curPanel = 1;
	
	//when the left/right arrows are clicked
	$(".bot").click(function(){ change(true); });	
	$(".top").click(function(){ change(false); });
	
});
