var initList = initList || []; 

initList.push(function(){
	var buttons = $(".buttons");
	var sections = $(".sections");
    var stage = 1;
    var num_sections = 2;
    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();
			    	});		
			    });			
	  });




	/* SCROLL SECTIONS */
	$(".sections li").append("<span class='sub_buttons'></span>");
	$(".sub_buttons").bind("click", subir);

	function subir(){
		$(this).unbind("click", subir).addClass("open").bind("click", bajar);
		$(this).parent().addClass("scroll");
	}
	function bajar(){
		$(this).unbind("click", bajar).removeClass("open").bind("click", subir);
		$(this).parent().removeClass("scroll");
	}

});

