/*=========================================== INITIALISATION DES VARIABLES ============================================
---------------------------------------------------------------------------------------------------------------------*/
if (!window.demo_path) window.demo_path = '';
var demo_path = window.demo_path;
// --

$instructionsReq = new Array ()
$instructionsOpen = 0;
$currOpen = 0;

$instructions_table = new Array(""
													 , "casse_tete"
													 , "dessins_colorier"
													 , "fons_decran"
													 )	
	
/*=========================================== INTERACTIONS DES CHANSONS ===============================================
---------------------------------------------------------------------------------------------------------------------*/

function instructionsItemOpen($bouton_ouvre, $instructionsNo){	
		$($bouton_ouvre).addEvent('click', function(){	
			if($instructionsOpen == 0){
				$('popup_fenetre').setStyle('z-index', "10");
				$instructionsReq[$instructionsNo].send()
				$instructionsOpen = 1
			} 
		});
}

function callFicheInstructionsFunct ($instructionsNo) {
	$bouton_ouvre = "inscructions_bt_"+$instructionsNo
	$instructionsReq[$instructionsNo] = new Request.HTML({url:'scripts/php/instructions_req.php?instructions='+$instructions_table[$instructionsNo]+'', 
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
			$('popup_fenetre_content').set('text', '');
			//Inject the new DOM elements into the results div.
			$('popup_fenetre_content').adopt(html);
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('popup_fenetre_content').set('text', 'The request failed.');
		}
	});
	instructionsItemOpen($bouton_ouvre, $instructionsNo)
	
};

function loadInstructionsItems($qteInstructions){	
	for ($instructionsNo = 1; $instructionsNo <= $qteInstructions ; $instructionsNo++){
		callFicheInstructionsFunct($instructionsNo);
	}	
	
	activate_Popup()

}

window.addEvent('load', function() {	
	loadInstructionsItems($instructions_table.length-1)	
});