/*function openConditions(){
	window.open("condition_utilistions.php", "legal", "width=300, height=400,scrollbars=yes");
}*/

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit){ // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		alert("Tu as dépassé les " + maxlimit + " caractères permis.");
	}
		// otherwise, update 'characters left' counter
	//else 
		//countfield.value = maxlimit - field.value.length;
}

function hide_show(div){
	var el = MM_findObj(div);
//	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
	
	/*var theDiv = MM_findObj(div);
	
	alert(theDiv.style.display);
	if (theDiv.style.display == "none"){
		theDiv.style.display = "block";
	}else{
		theDiv.style.display = "none";
	}*/
}

function validateConcoursForm(f, arFlds, msgErreur){
	var valid = true;
	
	for(i=0; i<arFlds.length; i++){
		var fld = f[arFlds[i]];
		if(fld.value == ""){
			valid = false;
			unvalidFld = fld;
		}
	} 

	if (valid){
		return true;
	}else{
		alert(msgErreur);
		unvalidFld.focus();
		return false;
	}
}

function checkValid(mandatory_flds){
	var arFlds = split(mandatory_flds, ",");
	
	var f = document.forms[0];
	
	for(i=0; i<arFlds.length; i++){
		if(f.elements[arFlds[i]].value == ""){
			valid = false;
			unvalidFld = f.elements[arFlds[i]];
		}
	} 

	if (valid){
		return true;
	}else{
		alert("One or more mandatory fields are empty.");
		alert(unvalidFld.name);
		unvalidFld.focus();
		return false;
	}
}