function SetSect()
{
	var form = document.selop;
	form.P_secteur.value = form.selsect.selectedIndex;
//	alert(form.P_secteur.value);
	form.submit();
}
function checkco()
{
	var form = document.coinscr;
	var alertstr="";
	if(form.P_nom.value.length<3)
		alertstr = alertstr + "Le nom doit avoir au moins 3 caractères.\n";
	if(Check_MailString(form.P_mail.value))
		alertstr = alertstr + "L'adresse mail est incoherente.\n";
	if(form.P_tel.value.length<10)
		alertstr = alertstr + "Le telephone doit avoir au moins 10 caractères.\n";
	if(form.P_adr.value.length<10)
		alertstr = alertstr + "L'adresse doit avoir au moins 10 caractères.\n";
	if(form.P_cp.value.length<5)
		alertstr = alertstr + "Le code postal doit avoir au moins 5 caractères.\n";
	if(form.P_ville.value.length<4)
		alertstr = alertstr + "La ville doit avoir au moins 4 caractères.\n";
	if(form.P_codespam.value.length<5)
		alertstr = alertstr + "le champ antispam est incorrect.\n";
	else if(form.P_codespam.value!="7CMA8")
		alertstr = alertstr + "le champ antispam est incorrect.\n";
	if(alertstr.length>0){
		alert(alertstr);
	}else{
		form.P_info.value=form.P_demande.value;
		form.submit();
	}
}
function checknl()
{
	var form = document.nlinscr;
	var alertstr="";
	if(form.P_nom.value.length<3)
		alertstr = alertstr + "Le nom doit avoir au moins 3 caractères.\n";
	if(Check_MailString(form.P_mail.value))
		alertstr = alertstr + "L'adresse mail est incoherente.\n";
	if(form.P_tel.value.length<10)
		alertstr = alertstr + "Le telephone doit avoir au moins 10 caractères.\n";
	if(form.P_adr.value.length<10)
		alertstr = alertstr + "L'adresse doit avoir au moins 10 caractères.\n";
	if(form.P_cp.value.length<5)
		alertstr = alertstr + "Le code postal doit avoir au moins 5 caractères.\n";
	if(form.P_ville.value.length<4)
		alertstr = alertstr + "La ville doit avoir au moins 4 caractères.\n";
	if(alertstr.length>0){
		alert(alertstr);
	}else{
		if(form.check.checked){
			form.P_info.value=1;
//			alert(form.check.checked);
		}
		form.submit();
	}
}
function checkMPForm()
{
	var form = document.mpident;
	var alertstr="";
	if(form.P_noms.value.length<4)
		alertstr = alertstr + "Le nom doit avoir au moins 4 caractères.\n";
	if(Check_MailString(form.P_mail.value))
		alertstr = alertstr + "L'adresse mail est incoherente.\n";
	if(alertstr.length>0){
		alert(alertstr);
	}else
		form.submit();

}

function Check_MailString(theString)
{
 var err=1;
// 	alert(theString);
	for (var i=0; i<theString.length; i++){
		if(theString.charCodeAt(i)<48){
			err=1;
			if(theString.charCodeAt(i)==45) err=0;	// "-"
			if(theString.charCodeAt(i)==46) err=0;	// "."
			if(err)	break;
		}
		if(theString.charCodeAt(i)>57 && theString.charCodeAt(i)<64){ // included "@"
			err=1;
			break;
		}
		if(theString.charCodeAt(i)>90 && theString.charCodeAt(i)<97){
			err=1;
			if(theString.charCodeAt(i)==95) err=0;	// "_"
			if(err) break;
		}
		if(theString.charCodeAt(i)>122){ 
			err=1;
			break;
		}
	}
	return(err);
}
