// JavaScript Document



function DynDiv(){

	var msg = "";

	

	msg = document.getElementById("mydiv").innerHTML;

	document.getElementById("mydiv").innerHTML = ""

	

	document.getElementById("cont_div").innerHTML = "";

	document.getElementById("cont_div").innerHTML   = msg ;

}







function mailing(who,sujet){

	domaine = "comet-studio.com";

	document.location.href="mailto:"+who+"@"+domaine+"?subject="+sujet;

}



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 valid_contact(){

//FormContact

	envoi = true;

	

	if (AllTrim(document.forms['FormContact'].nom.value) == ""){

		envoi = false;

		alert("Merci de saisir le champ NOM.");

		document.forms['FormContact'].nom.focus();

		return;

	}
	
	if(document.forms['FormContact'].demande.value ==  3 ){
		envoi = false;
		alert("Désolé, notre équipe étant complète pour le moment,\r\nnous ne recrutons plus d'employés ou stagiaires");
		return;
	}

	if (AllTrim(document.forms['FormContact'].email.value) == ""){

		envoi = false;

		alert("Merci de saisir le champ EMAIL.");

		document.forms['FormContact'].email.focus();

		return;

	}else{

		if(!goodmail(document.forms['FormContact'].email.value)){

			envoi = false;

			alert("Le champ EMAIL n'est pas valide, merci de vérifier votre adresse email.");

			document.forms['FormContact'].email.focus();

			return;

		}

	}

	

	if (AllTrim(document.forms['FormContact'].message.value) == ""){

		envoi = false;

		alert("Merci de saisir le champ MESSAGE.");

		document.forms['FormContact'].message.focus();

		return;

	}



	if(envoi) document.forms['FormContact'].submit();

}