var initList = initList || [];

initList.push(function() {

	var secuenceScroll = $('.secuence-scrollable');

	var buttonPrev = secuenceScroll.find('.prev').css('display', 'none');
	var buttonNext = secuenceScroll.find('.next');

	var sections = secuenceScroll.find(".sections");
	var stage = 1;
	var pages = sections.find('.page');
	var num_sections = pages.length;
	var width_sections = parseInt(pages.css("width")) + parseInt(pages.css("marginRight")) + parseInt(pages.css("marginLeft"));
	var time_factor = 1.5 * width_sections;

	buttonPrev.click(clickBtnSecuence);
	buttonNext.click(clickBtnSecuence);

	var plane = $('.plane');

	function clickBtnSecuence() {

		sg.sound('success');

		var variation;
		var otherButton;
		if ($(this).hasClass("prev")) {
			variation = "+=";
			stage--;
			otherButton = buttonNext;
		} else {
			variation = "-=";
			stage++;
			otherButton = buttonPrev;
		}
		otherButton.fadeOut(50, function() {});
		$(this).fadeOut(50,
			function() {
				sections.animate({
					marginLeft: variation + width_sections
				}, time_factor, function() {
					if (stage > 1) buttonPrev.fadeIn();
					if (stage < num_sections) buttonNext.fadeIn();
				});
			});
	}

});
