function verifySelect(champ, num, nb_col){
	var selectForm = document.getElementById("select_" + champ + "[" + num + "]");
	var textForm = document.getElementById("text_" + champ + "[" + num + "]");
	textForm.title = document.getElementById("select_" + champ + "[" + num + "]").value;
	if ( selectForm.value == -2 ){
		if (textForm.disabled == true){
			textForm.disabled = false;
			textForm.value = '';		
			textForm.focus();
		}
	}
	else{
		textForm.disabled = true;				
		textForm.value = selectForm.options[selectForm.selectedIndex].text;	
	}
}




function calcSum(champ, id, num){
	var sum = 0;	
	var textTot = document.getElementById("tot_" + champ + "[" + id + "]");
	
	for (i=0; i<num; i++){
		var textForm = document.getElementById(champ + "[" + i + "][" + id + "]");
		if (isNaN(textForm.value) && textForm.value.length){
			alert("Ceci n'est pas un nombre");
			textForm.value = '';
		}
		else if (textForm.value.length)
			sum = sum + parseInt(textForm.value);
	}
	textTot.value = sum;
}




function changeSumMDT(){
	var sum1 = 0;
	var temp1 = 0;
	var sum2 = 0;
	var temp2 = 0;
	
	temp1 = document.getElementById('eff_musique');
	if (isNaN(temp1.value) && temp1.value.length) notANumber(temp1);
	else if(temp1.value.length) sum1 = sum1 + parseInt(temp1.value);	
	temp2 = document.getElementById('eff_musique_ext');
	if (isNaN(temp2.value) && temp2.value.length) notANumber(temp2);
	else if(temp2.value.length) sum2 = sum2 + parseInt(temp2.value);
	
	
	temp1 = document.getElementById('eff_danse');
	if (isNaN(temp1.value) && temp1.value.length) notANumber(temp1);
	else if(temp1.value.length) sum1 = sum1 + parseInt(temp1.value);	
	temp2 = document.getElementById('eff_danse_ext');
	if (isNaN(temp2.value) && temp2.value.length) notANumber(temp2);
	else if(temp2.value.length) sum2 = sum2 + parseInt(temp2.value);
	
	
	temp1 = document.getElementById('eff_theatre');
	if (isNaN(temp1.value) && temp1.value.length) notANumber(temp1);
	else if(temp1.value.length) sum1 = sum1 + parseInt(temp1.value);	
	temp2 = document.getElementById('eff_theatre_ext');
	if (isNaN(temp2.value) && temp2.value.length) notANumber(temp2);
	else if(temp2.value.length) sum2 = sum2 + parseInt(temp2.value);
	
	
	document.getElementById('eff_MDT').value = sum1;
	document.getElementById('eff_MDT_ext').value = sum2;
	document.getElementById('eff_MDT_2').value = sum1;
	document.getElementById('cotis').value = (sum1 * 0.80).toFixed(2) + " €";
}
	
	


function notANumber(field){
	alert("Ceci n'est pas un nombre");
	field.value = '';
}




function calcSumTot2(champ, id, num, res){
	var sum = 0;
	
	for (i=0; i<num; i++){
		var temp = document.getElementById(champ + '[' + id + '][' + i + ']');
		if (isNaN(temp.value) && temp.value.length) notANumber(temp);
		else if(temp.value.length) sum = sum + parseInt(temp.value); 
	}
		
	document.getElementById(champ + '[' + id + '][' + res + ']').value = sum;
}



function updateHeureTot(){
	var sum = 0;
	var montant = 0;
	var total = new Array();
	total[0] = 'instru[6]';
	total[1] = 'fg[2]';
	total[2] = 'pc[2]';
	total[3] = 'danse[2]';
	total[4] = 'theatre[2]';

	for (var i in total)
	{
		montant = parseInt(document.getElementById('tot_'+total[i]).value);
		sum += montant;
		document.getElementById('tot_heures_'+total[i]).value = format_minutes(montant);
	}

	document.getElementById('nb_heures_tot').value = format_minutes(sum);
	document.getElementById('nb_heures_hide').value = format_minutes(sum);
}

function format_heures(temps)
{
	explose = temps.split(':');
	heures = parseInt(explose[0]);
	minutes = !isNaN(parseInt(explose[1])) ? parseInt(explose[1]) : 0;
	retour = heures * 60 + minutes;
	if (!retour) retour = "0";
	return retour;
}

function format_minutes(temps)
{
	heures = Math.floor(temps / 60);
	minutes = temps % 60;
	retour = heures+":"+minutes;
	return retour;
}