/************************************************************************************
	Name: Cofradía de Nuestro Padre Jesús con la Cruz a Cuestas
	Author: Oscar Carballal Prego <oscar@oscarcp.com>
	Version: 1.0
	Tested on:
		Windows: Safari 3.2.1 - Firefox 3.0.5 - Internet Explorer 7
		GNU/Linux: Epyphany - Firefox 3.0.5 - Konqueror
		MacOS X: Firefox 3.0.5 - Minefield - Safari 3.2.1 - Webkit - Opera 9.60
	Date: 2009-January-28
	Finished: xxxx-xxxxxxxxxx-xx
	License: Copyright 2009 Cofradía de Nuestro Padre Jesús con la Cruz a Cuestas
************************************************************************************/

window.addEvent('domready', function() {
	
	// ScrollBar
	// var scroll = new MooScroll();
	
	// Array with all the content divs
	var myArray = [ 'bienvenida','historia','fines','cofrades','trono','actos','procesiones','organos','banda',
					'galeria','actualidad','colaboraciones','contacto','colabora' ];
					
	// Create Fx.Slide for every element					
	myArray.each(function(e) {
		var mySlide = new Fx.Slide(e, {duration: 500});
		
		// Store every Fx inside an array
		var fxArray = new Array();
		fxArray.include(mySlide);
		
		// Hide eveything
		mySlide.hide();
		
		// Display only "Bienvenida"
		$('bienvenida').slide('in');
	});
	
	// Array with the submenus
	var subArray = [ 'sub1','sub3','sub4','sub6','sub8','sub9','sub10' ];
	
	// Collapse all submenus on page load
	subArray.each(function(i) {
		var subSlide = new Fx.Slide(i, {duration: 500});
		subSlide.hide();
	});

	// Actions when clicking
				
	$('opt1').onclick = function() {
		myArray.erase('historia','sub1');
		myArray.each(function(div){
			$(div).slide('out'); // Iterates through the array and then closes everything
		});
		myArray.combine(['historia','sub1']); // Uses combine instead of include because it's an array, not a single element
		$('historia').slide('in');
		$('sub1').slide('in');
	};
	
	$('opt2').onclick = function() {
		myArray.erase('fines');
		myArray.each(function(div){
			$(div).slide('out'); // Iterates through the array and then closes everything
		});
		myArray.combine(['fines']); // Uses combine instead of include because it's an array, not a single element
		$('fines').slide('in');
	};
	
	$('opt3').onclick = function() {
		myArray.erase('cofrades','sub3');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['cofrades','sub3']);
		$('cofrades').slide('in');
		$('sub3').slide('in');
	};
	
	$('opt4').onclick = function() {
		myArray.erase('trono','sub4');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['trono','sub4']);
		$('trono').slide('in');
		$('sub4').slide('in');
	};
	
	$('opt5').onclick = function() {
		myArray.erase('actos');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['actos']);
		$('actos').slide('in');
	};
	
	$('opt6').onclick = function() {
		myArray.erase('procesiones','sub6');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['procesiones','sub6']);
		$('procesiones').slide('in');
		$('sub6').slide('in');
	};
	
	$('opt7').onclick = function() {
		myArray.erase('organos');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['organos',]);
		$('organos').slide('in');
	};
	
	$('opt8').onclick = function() {
		myArray.erase('banda','sub8');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['banda','sub8']);
		$('banda').slide('in');
		$('sub8').slide('in');
	};
	
	$('opt9').onclick = function() {
		myArray.erase('galeria','sub9');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['galeria','sub9']);
		$('galeria').slide('in');
		$('sub9').slide('in');
	};
	
	$('opt10').onclick = function() {
		myArray.erase('actualidad');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['actualidad']);
		$('actualidad').slide('in');
	};
	
	$('opt11').onclick = function() {
		myArray.erase('colaboraciones');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['colaboraciones']);
		$('colaboraciones').slide('in');
	};
	
	$('opt12').onclick = function() {
		myArray.erase('colabora','sub10');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['colabora','sub10']);
		$('colabora').slide('in');
		$('sub10').slide('in');
	};
	
	$('opt13').onclick = function() {
		myArray.erase('contacto');
		myArray.each(function(div){
			$(div).slide('out');
		});
		myArray.combine(['contacto']);
		$('contacto').slide('in');
	};
	
});
