var initList = initList || []; 

initList.push(function(){
	var buttons1 = $(".buttons");
	var sections1 = $(".time_line");
    var stage1 = 1;
    var num_sections1 = 3;//sections.children().length;
    var width_sections1 = 658;//1014;//parseInt (sections.children().css("width")) + parseInt(sections.children().css("marginRight") )  + parseInt(sections.children().css("marginLeft") );
	var time_factor1 = 1.5 * width_sections1;

	buttons1.click(function(){
			var variation;

			if ($(this).hasClass("prev")){
				variation = "+=";
				stage1--;
			}else{
				variation = "-=";
				stage1++;				
			}

			$(this).fadeOut(50,
				function(){ 
			    	sections1.animate({
			    		marginLeft: variation+width_sections1
			    	}, time_factor1, function(){
								if (stage1 < 2) buttons1.last().fadeIn();
								if (stage1 < num_sections1 && stage1 > 1) buttons1.first().fadeIn();
			    	});		
			    });			
	  });

	var buttons2 = $(".buttons2");
	var sections2 = $(".time_line2");
    var stage2 = 1;
    var num_sections2 = 6;//sections.children().length;
    var width_sections2 = 1083;//parseInt (sections.children().css("width")) + parseInt(sections.children().css("marginRight") )  + parseInt(sections.children().css("marginLeft") );
	var time_factor2 = 1.5 * width_sections2;

	buttons2.click(function(){
			var variation;

			if ($(this).hasClass("prev")){
				variation = "+=";
				stage2--;
			}else{
				variation = "-=";
				stage2++;				
			}

			$(this).fadeOut(50,
				function(){ 
			    	sections2.animate({
			    		marginLeft: variation+width_sections2
			    	}, time_factor2, function(){
								if (stage2 < 5) buttons2.last().fadeIn();
								if (stage2 < num_sections2 && stage2 > 1) buttons2.first().fadeIn();
			    	});		
			    });			
	  });
});