
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//////////////////////////////////////////////////////////////////////////////////////

function VerifInscriptNews(){
	if(AllTrim(document.forms['FormNewsletter'].nom.value) ==""){
		alert("Merci de préciser le champ NOM");
		document.forms['FormNewsletter'].nom.focus();
		return false;
	}
	if(AllTrim(document.forms['FormNewsletter'].email.value) ==""){
		alert("Merci de préciser le champ EMAIL");
		document.forms['FormNewsletter'].email.focus();
		return false;
	}
	if(!goodmail(document.forms['FormNewsletter'].email.value)){
		alert("Merci de vérifier le champ EMAIL");
		document.forms['FormNewsletter'].email.focus();
		return false;
	}
	
	return true;
	
}


function PopupCentrer(page,largeur,hauteur,options) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}


//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
function ValidMail(){
	//FormContact
	
	envoi = true;
	
	if(AllTrim(document.forms['FormContact'].nom.value) == ""){
		envoi = false;
		alert("Merci de préciser votre nom.");
		document.forms['FormContact'].nom.focus();
		return false;
	}
	
	if(AllTrim(document.forms['FormContact'].tel.value) == ""){
		envoi = false;
		alert("Merci de préciser votre téléphone");
		document.forms['FormContact'].tel.focus();
		return false;
	}
	
	if(AllTrim(document.forms['FormContact'].email.value) == ""){
	 	envoi = false;
		alert("Merci de spécifier votre adresse email");
		document.forms['FormContact'].email.focus();
		return false;
	}else{
		if(!goodmail(document.forms['FormContact'].email.value)){
		    envoi = false;
			alert("Votre adresse email n'a pas un format valide");
			document.forms['FormContact'].email.focus();
			return false;
		}
	}
	
	if(AllTrim(document.forms['FormContact'].msg.value) == ""){
		 
		alert("Merci de préciser votre demande");
		document.forms['FormContact'].msg.focus();
		return false;
	}	
	
	if(envoi)
	{
		document.forms['FormContact'].submit();
	}
	
}

function VerifPart(){
	
	envoi = true;
	
	if(AllTrim(document.forms['FormPart'].raison_soc.value) == ""){
		envoi = false;
		alert("Merci de préciser la raison sociale de votre organisme.");
		document.forms['FormPart'].raison_soc.focus();
		return false;
	}
	
	if(AllTrim(document.forms['FormPart'].nom.value) == ""){
		envoi = false;
		alert("Merci de préciser votre nom.");
		document.forms['FormPart'].nom.focus();
		return false;
	}
	
	if(AllTrim(document.forms['FormPart'].tel.value) == ""){
		envoi = false;
		alert("Merci de préciser votre téléphone.");
		document.forms['FormPart'].tel.focus();
		return false;
	}
	
	if(AllTrim(document.forms['FormPart'].email.value) == ""){
		envoi = false;
		alert("Merci de préciser votre E-mail.");
		document.forms['FormPart'].email.focus();
		return false;
	}
	
	if(AllTrim(document.forms['FormPart'].specialites.value) == ""){
		envoi = false;
		alert("Merci de préciser vos spécialités.");
		document.forms['FormPart'].specialites.focus();
		return false;
	}
	
	if(AllTrim(document.forms['FormPart'].nb_interv.value) == ""){
		envoi = false;
		alert("Merci de préciser le nombre d'intervenants dans votre organisme.");
		document.forms['FormPart'].nb_interv.focus();
		return false;
	}
	
	if(envoi) document.forms['FormPart'].submit();
}


function  VerifImmo(){
	// FormImmo
	if(AllTrim(document.forms['FormImmo'].nom.value) == ""){
		envoi = false;
		alert("Le champ nom est obligatoire, merci");
		document.forms['FormImmo'].nom.focus();
		return false;
	}
	if(AllTrim(document.forms['FormImmo'].prenom.value) == ""){
		alert("Le champ prénom est obligatoire, merci");
		document.forms['FormImmo'].prenom.focus();
		return false;
	}
	if(AllTrim(document.forms['FormImmo'].email.value) == ""){
		alert("Le champ e-mail est obligatoire, merci");
		document.forms['FormImmo'].email.focus();
		return false;
	}else if (!goodmail(document.forms['FormImmo'].email.value)){
		alert("Le champ e-mail n'est pas valide");
		document.forms['FormImmo'].email.focus();
		return false;
	}
	if(AllTrim(document.forms['FormImmo'].description.value) == ""){
		alert("Le champ description de l'offre est obligatoire, merci");
		document.forms['FormImmo'].description.focus();
		return false;
	}
	
}







function ValidCandidature(){
	//FormCand
 
 	if(AllTrim(document.forms['FormCand'].nom.value) == ""){
		alert("Merci de préciser votre nom");
		document.forms['FormCand'].nom.focus();
		return false;
	}	
 
 	if(AllTrim(document.forms['FormCand'].prenom.value) == ""){
		alert("Merci de préciser votre prénom");
		document.forms['FormCand'].prenom.focus();
		return false;
	}	
	if(AllTrim(document.forms['FormCand'].rue.value) == ""){
		alert("Merci de préciser votre rue");
		document.forms['FormCand'].rue.focus();
		return false;
	}
	if(AllTrim(document.forms['FormCand'].cp.value) == ""){
		alert("Merci de préciser votre code postal");
		document.forms['FormCand'].cp.focus();
		return false;
	}
	if(AllTrim(document.forms['FormCand'].ville.value) == ""){
		alert("Merci de préciser votre ville");
		document.forms['FormCand'].ville.focus();
		return false;
	}
	if(AllTrim(document.forms['FormCand'].date_naiss.value) == ""){
		alert("Merci de préciser votre date de naissance");
		document.forms['FormCand'].date_naiss.focus();
		return false;
	}
	if(AllTrim(document.forms['FormCand'].situation_fami.value) == ""){
		alert("Merci de préciser votre situation de famille");
		document.forms['FormCand'].situation_fami.focus();
		return false;
	}
	if(AllTrim(document.forms['FormCand'].tel.value) == ""){
		alert("Merci de préciser votre numéro de téléphone");
		document.forms['FormCand'].tel.focus();
		return false;
	}
	
	
	
 
	if(AllTrim(document.forms['FormCand'].email.value) == ""){
		alert("Merci de spécifier votre adresse email");
		document.forms['FormCand'].email.focus();
		return false;
	}else{
		if(!goodmail(document.forms['FormCand'].email.value)){
			alert("Votre adresse email n'a pas un format valide");
			document.forms['FormCand'].email.focus();
			return false;
		}
	}
	
	
	if(AllTrim(document.forms['FormCand'].form1_deb.value) == "" || AllTrim(document.forms['FormCand'].form1_fin.value) == "" || AllTrim(document.forms['FormCand'].form1_ecole.value) == "" || AllTrim(document.forms['FormCand'].form1_dipl.value) == ""   ){
		alert("Merci de préciser au moins une de vos formations");
		document.forms['FormCand'].form1_deb.focus();
		return false;
	}

	 return true;
	
}





//////////////////////////////////////////////////////////////////////////////////////

function goodmail(chaine)
{
	var userid;
	if ((chaine.length>8) && (chaine.length<130)) {
		userid = chaine.substring(0,chaine.indexOf("@"));
		if (userid.length>=2 && userid.length<64) {
			FQDN = chaine.substr(chaine.indexOf("@")+1);
			if (FQDN.length>2 && FQDN.length<64) {
				domainname = FQDN.substring(0,FQDN.indexOf("."));
				if (domainname.length>=2) {
					TLD = FQDN.substr(FQDN.indexOf(".")+1);
					if (TLD.length>=2)
						return true;
				}
			}
		}
	}
	return false;
}


//////////////////////////////////////////////////////////////////////////////////////

function AllTrim(chaine) {
	  temp = chaine.replace(/(^\s*)|(\s*$)/g, "");
      return temp; 
}

//////////////////////////////////////////////////////////////////////////////////////

function DynDiv(){
	var msg = "";
	msg = document.getElementById("mydiv").innerHTML;
	document.getElementById("mydiv").innerHTML = ""
	document.getElementById("cont_div").innerHTML = "";
	document.getElementById("cont_div").innerHTML   = msg ;

}

//////////////////////////////////////////////////////////////////////////////////////
// Log extranet

function logExtra()
{
	var envoi = true;
	if(AllTrim(document.forms['FormLoginExtra'].login.value) == "")
	{
		envoi = false;
		alert("Le login est obligatoire.");
		document.forms['FormLoginExtra'].login.focus();
		return;
	}
	
	if(AllTrim(document.forms['FormLoginExtra'].passwd.value) == "" || AllTrim(document.forms['FormLoginExtra'].passwd.value) == "12345678")
	{
		envoi = false;
		alert("Le mot de passe est obligatoire.");
		document.forms['FormLoginExtra'].login.focus();
		return;
	}
	
	if(envoi)
	{
		document.forms['FormLoginExtra'].submit();
	}
}

//////////////////////////////////////////////////////////////////////////////////////
// Candidature Spontanée

function postuler_recrut(){
	envoi = true;
	if(document.forms['FormCreaCandidat'].civilite.value == 0){
		envoi = false;
		alert("La civilité est obligatoire !");
		document.forms['FormCreaCandidat'].civilite.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].nom.value) == ""){
		envoi = false;
		alert("Le champ Nom est obligatoire !");
		document.forms['FormCreaCandidat'].nom.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].prenom.value) == ""){
		envoi = false;
		alert("Le champ Prénom est obligatoire !");
		document.forms['FormCreaCandidat'].prenom.focus();
		return;
	}
	if(!goodmail(document.forms['FormCreaCandidat'].email.value)){
		envoi = false;
		alert("Le champ E-mail n'est pas valide !");
		document.forms['FormCreaCandidat'].email.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].adresse.value) == ""){
		envoi = false;
		alert("Le champ Adresse est obligatoire !");
		document.forms['FormCreaCandidat'].adresse.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].code_postal.value) == ""){
		envoi = false;
		alert("Le champ Code postal est obligatoire !");
		document.forms['FormCreaCandidat'].code_postal.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].ville.value) == ""){
		envoi = false;
		alert("Le champ Ville est obligatoire !");
		document.forms['FormCreaCandidat'].ville.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].tel.value) == ""){
		envoi = false;
		alert("Le champ Téléphone est obligatoire !");
		document.forms['FormCreaCandidat'].tel.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].cv.value) == ""){
		envoi = false;
		alert("Le CV est obligatoire !");
		document.forms['FormCreaCandidat'].cv.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].lettre_motiv.value) == ""){
		envoi = false;
		alert("La lettre de motivation est obligatoire !");
		document.forms['FormCreaCandidat'].lettre_motiv.focus();
		return;
	}
	if(AllTrim(document.forms['FormCreaCandidat'].poste_spont.value) == ""){
		envoi = false;
		alert("Veuillez entrer le poste que vous recherchez.");
		document.forms['FormCreaCandidat'].poste_spont.focus();
		return;
	}
	if((AllTrim(document.forms['FormCreaCandidat'].message.value) == "") || (AllTrim(document.forms['FormCreaCandidat'].message.value) == "Expliquez en quelques mots vos motivations")){
		envoi = false;
		alert("Veuillez donnez vos motivations pour ce poste.");
		document.forms['FormCreaCandidat'].message.focus();
		return;
	}
	
	if(envoi) document.forms['FormCreaCandidat'].submit();
}