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

$chansonReq = new Array ()
$chansonOpen = 0;
$currOpen = 0;

if ($album == "pyjama"){
$chansons_table = new Array(""
													 , "01_en_pyjama_court"
													 , "02_le_hoquet"
													 , "03_deux_maisons"
													 , "04_je_veux_pas_dormi"
													 , "05_tes_amis"
													 , "06_moi_et_moi"
													 , "07_professeur_zozozetetique"
													 , "08_grand_papa"
													 , "09_ayayayaye"
													 , "10_quand_je_chante"
													 , "12_je_suis_un_ange"
													 , "13_au_mois_daout"
													 )	
}

if ($album == "vacances"){
$chansons_table = new Array(""
													 , "01_la_marmotte_en_vacances"
													 , "02_calor_la_vida"
													 , "03_un_tour_de_manege"
													 , "04_un_maringouin64"
													 , "05_le_beluga_et_la_sardine"
													 , "06_au_lac_patate"
													 , "07_le_retour_du_marigouin"
													 , "08_ca_demenage"
													 , "09_au_zoo"
													 , "10_doue_pour_le_bonheur"
													 , "11_chocolat"
													 , "12_la_fin_dun_maringouin"
													 , "14_jevolue_vert"
													 , "15_y_para_que"
													 , "16_il_pleut"
													 )	
}
	
/*=========================================== INTERACTIONS DES CHANSONS ===============================================
---------------------------------------------------------------------------------------------------------------------*/

function chansonItemMouseAct($li, $selecteur, $chansonNo){	
			$($li).addEvent('mouseenter', function(){		
				if ($chansonNo != $currOpen){
					if ($is_ie6 == 0){
						$($li).setStyle('color', "#ffffff");
						$($li).setStyle('list-style-image', "url(images/design/disque_icone_son_2.gif)");
						$($selecteur).setStyle('display', "block");
					} else {
						$($li).setStyle('text-decoration', "underline");						
					}
				}
			});
			
			$($li).addEvent('mouseleave', function(){	
				if ($chansonNo != $currOpen){
					if ($is_ie6 == 0){
					$($li).setStyle('color', "#000000");
					$($li).setStyle('list-style-image', "url(images/design/disque_icone_son_1.gif)");
					$($selecteur).setStyle('display', "none");
					} else {
						$($li).setStyle('text-decoration', "none");						
					}
				}
			});	
}

function chansonItemOpen($li, $selecteur, $chansonNo){		
		$($li).addEvent('click', function(){	
			if($currOpen == $chansonNo){				
				$($li).setStyle('list-style-image', "url(images/design/disque_icone_son_1.gif)");
				if ($is_ie6 == 0){
					$($li).setStyle('color', "#000000");
					$($selecteur).setStyle('display', "none");
				} else {
						$($li).setStyle('text-decoration', "none");						
				}
				$chansonOpen = 0;
				$currOpen = 0;
				$('chansons_play').set('text', '');				
			} else {
				if ($currOpen != 0){
					$li_old = "chanson_"+$currOpen
					$selecteur_old = "selecteur_"+$currOpen					
					$($li_old).setStyle('list-style-image', "url(images/design/disque_icone_son_1.gif)");
					if ($is_ie6 == 0){
						$($li_old).setStyle('color', "#000000");
						$($selecteur_old).setStyle('display', "none");
					} else {
						$($li_old).setStyle('text-decoration', "none");								
					}	
				}	
				if ($is_ie6 == 0){
					$($li).setStyle('color', "#ffffff");
					$($li).setStyle('list-style-image', "url(images/design/disque_icone_son_3.gif)");
					$($selecteur).setStyle('display', "block");			
				} else {
					$($li).setStyle('list-style-image', "url(images/design/disque_icone_son_3b.gif)");	
					$($li).setStyle('text-decoration', "underline");						
				}
				$chansonOpen = 1
				$currOpen = $chansonNo;
				$chansonReq[$chansonNo].send()
			}
		});
}


function callFicheChansonFunct ($chansonNo) {
	$bt_off = "bt_"+$chansonNo+"_off"
	$li = "chanson_"+$chansonNo
	$selecteur = "selecteur_"+$chansonNo
	
	
	$chansonReq[$chansonNo] = new Request.HTML({url:'scripts/php/chansons_req.php?album='+$album+'&chanson='+$chansons_table[$chansonNo]+'&is_ie6='+$is_ie6+'', 
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
			$('chansons_play').set('text', '');
			//Inject the new DOM elements into the results div.
			$('chansons_play').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() {
			$('chansons_play').set('text', 'The request failed.');
		}
	});
	
	
	chansonItemMouseAct($li, $selecteur, $chansonNo)
	chansonItemOpen($li, $selecteur, $chansonNo)
	/*chansonItemBt($ficheBt, $ficheNo)*/
	
};

function loadChansonItems($qteChansons){	
		for ($chansonNo = 1; $chansonNo <= $qteChansons ; $chansonNo++){
			callFicheChansonFunct($chansonNo);
		}
}

window.addEvent('load', function() {		
	loadChansonItems($chansons_table.length-1)	

});



	
