
function cascade(cascadeGroup){
   var elements = $('[cascade='+cascadeGroup+']');
   var firstGroup = $('[cascade='+cascadeGroup+'][parent=0]');
   var restGroup = $('[cascade='+cascadeGroup+'][parent!=0]');
   var toggleElements = $('[cascade='+cascadeGroup+'][cascadeToggle]');

    restGroup.hide(); // Leave only initial show elements  (parent =0)

    toggleElements.each(function(){
        $(this).on('click', function(){
            var keyToggle = $(this).attr('cascadeToggle');
            var childs = $('[cascade='+cascadeGroup+'][parent='+keyToggle+']');
            childs.toggle("fold");
           // $(this).unbind('click');
            sg.sound('success-low');
        })

    })
}



function page1() {
	//Hide text
	$('.section-p1').hide();

	//Click on intriduccion
	$('#img1-p3, #img1-p6').click(function(){
		console.log('1');
		$('.section-p1').hide();
		$('#section1-p1').fadeIn();
		sg.sound('success-low');
	});
	//Click on desarrollo
	$('#img1-p4, #img1-p7').click(function(){
		console.log('2');
		$('.section-p1').hide();
		$('#section2-p1').fadeIn();
		sg.sound('success-low');
	});
	//Click on 
	$('#img1-p9, #img1-p8').click(function(){
		console.log('3');
		$('.section-p1').hide();
		$('#section3-p1').fadeIn();
		sg.sound('success-low');
	});
}



function lastPage (){
    pages = $('div[data-sg-id="item-page"]');
    // Iterate  and hide all pages
    pages.each(function(){
        $(this).css('display','none');
    })
    // Show last page
    $(pages[pages.length -1 ]).css('display','block');
    console.log('REMOVE IN PRODUCTION BEFORE PACK LO');
}



function init() {
	cascade(1);
	lastPage();

}
