var initList = initList || []; 

initList.push(function(){

	var buttons = $(".buttons");
	var sections = $(".sections");
    var stage = 1;
    var num_sections = sections.children().length;
    var width_sections = parseInt (sections.children().css("width")) + parseInt(sections.children().css("marginRight") )  + parseInt(sections.children().css("marginLeft") );
	var time_factor = 1.5 * width_sections;

	buttons.click(function(){
			var variation;

			if ($(this).is(".last")){
				variation = "+=";
				stage--;
			}else{
				variation = "-=";
				stage++;				
			}

			$(this).fadeOut(50,
				function(){ 
			    	sections.animate({
			    		marginLeft: variation+width_sections
			    	}, time_factor, function(){
								if (stage > 1) {
									buttons.last().fadeIn();
								}
								if (stage < num_sections) {
									buttons.first().fadeIn();
								}
			    	});		
			    });			

			/* adiciones particulares, no se usan */
			if (stage == 4){
				$(".act_subtitle h2").fadeOut();
				$(".tres_uno .act_subtitle > span").text("Compartamos las ideas con la clase.");
			}
			if (stage == 3){
				$(".act_subtitle h2").fadeIn();
				$(".tres_uno .act_subtitle > span").text("Trabajo en parejas.");
			}
	  });

});

