function onMenu(nom, element, event) {
	element.src = '/medias/images/menu_'+nom+'_'+event+'.jpg';
	document.getElementById('img_feuille_'+nom).style.visibility = event == 'over' ? 'visible' : 'hidden';
}
function onBtQte(element, nom, event) {
	element.src = '/medias/images/bouton_'+nom+'_'+event+'.jpg';
}

var quantite = new Array;

function onCheck(section, ligne) {
	var iptQte = document.getElementById('reservation_qte_'+section+'_'+ligne);
	var iptCheck = document.getElementById('reservation_check_'+section+'_'+ligne);
	if(iptCheck.checked == true) { if(iptQte.value < 1) { iptQte.value = 1; } } else { iptQte.value = 0; }
	verifQuantite(section, ligne);
}
function checkReservation(section, ligne) {
	var iptQte = document.getElementById('reservation_qte_'+section+'_'+ligne);
	var iptCheck = document.getElementById('reservation_check_'+section+'_'+ligne);
	iptCheck.checked = iptQte.value == 0 ? false : true;
}
function verifQuantite(section, ligne) {
	var iptQte = document.getElementById('reservation_qte_'+section+'_'+ligne), isNumPositif = /^\d+$/;
	if(!quantite[section]) { quantite[section] = new Array; }
	if(iptQte.value.match(isNumPositif)) { quantite[section][ligne] = iptQte.value; } else { iptQte.value = quantite[section][ligne]; }
	checkReservation(section, ligne); calculPrix(section, ligne) ;
}
function changeQuantite(section, ligne, op) {
	verifQuantite(section, ligne);
	var iptQte = document.getElementById('reservation_qte_'+section+'_'+ligne);
	if(op == '+') { iptQte.value++; } else if(iptQte.value > 0) { iptQte.value--; }
	checkReservation(section, ligne); calculPrix(section, ligne) ;
}
function calculPrix(section, ligne) {
	var iptPrix = document.getElementById('reservation_prix_'+section+'_'+ligne), posEuro = iptPrix.value.indexOf(" €");
	var valPrix = (iptPrix.value.substr(0, posEuro)).valueOf(), iptQte = document.getElementById('reservation_qte_'+section+'_'+ligne);
	var iptTotal = document.getElementById('reservation_total_'+section+'_'+ligne), valTotal = valPrix * iptQte.value;

	iptTotal.value = valTotal == 0 ? "-" : ((valTotal.toFixed(2)).toString())+" €";

	var tableReservation = document.getElementById('reservation_table'), prixTotal = 0;
	if(Browser.Engine.trident) { var nbSections = (tableReservation.childNodes.length)/2; }
	else { var nbSections = (tableReservation.childNodes.length-1)/4; }

	for (var i = 0; i < nbSections; i++) {

		if(Browser.Engine.trident) { var tableSection = tableReservation.childNodes[(i*2)+1].childNodes[0];}
		else { var tableSection = tableReservation.childNodes[((i*4)+3)].childNodes[1]; }
		var nbLignes = tableSection.rows.length;
		for(var j = 0; j < nbLignes; j++) {
			var iptPrixLigne = tableSection.rows[j].cells[3].childNodes[(Browser.Engine.trident ? 0 : 1)].value;
			var valPrixLigne = (iptPrixLigne.substr(0, iptPrixLigne.indexOf(" €") )).valueOf();
			prixTotal = prixTotal+Math.floor(valPrixLigne*100);
		}
	}
	var iptPrixTotal = document.getElementById('reservation_total');
	iptPrixTotal.value = prixTotal == 0 ? "-" : (((prixTotal/100).toFixed(2)).toString())+" €";
}

