﻿function b2L(url,qui)
{

obj = alias.getElementById(qui);

// ON EFFACE LE CONTENU DU DUV
obj.innerHTML = "";
if(window.XMLHttpRequest) // FIREFOX
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else
return(false);

// CONTROLE DE L'ETAT DE LA REQUETE
// CHAQUE CHANGEMENT D'ETAT AFFICHE UNE LIGNE DANS NOTRE DIV
xhr_object.onreadystatechange = function()
{
if(xhr_object.readyState == 1)
     //obj.innerHTML += "connexion établie<br />";
if(xhr_object.readyState == 2)
     //obj.innerHTML+= "requête reçue<br />";
if(xhr_object.readyState == 3)
     obj.innerHTML += "réponse en cours<br />";
if(xhr_object.readyState == 4)
{
     // ON CONTROLE LE STATUS (ERREUR 404, ETC)
if(xhr_object.status == 200){
//obj.innerHTML += "Fichier : " + xhr_object.responseText;
obj.innerHTML += xhr_object.responseText;

}else{
obj.innerHTML +="Error code " + xhr_object.status;}
}
};

// ON APPELLE LA PAGE
xhr_object.open("GET", url, true);
xhr_object.send(null);
}

function OpenPopin(url){
alias.getElementById('table_popin').style.display = 'block';
//b2L(url,'contenu_popin');
b2L('include.popin.php?url='+url,'contenu_popin');

}


function testmail()
	{
	form=document.forms["bon"];	
	
	if (form.email.value) {	
		mail = form.email.value;
		arobase = mail.indexOf("@");
		espace = mail.indexOf(" ");
		doublarob = mail.indexOf("@",arobase+1);
		right = mail.substring(arobase + 1,mail.length);
		point = right.lastIndexOf(".");
		test = right.length-point;			
		if ((espace==-1)&&(doublarob==-1)&&(arobase>1)&&(point>1)&&(test<6)&&(test>2))
			{
			form.submit();
			} 
			else {
			alert("Vous n'avez pas saisi correctement votre e-mail.");
			}
		}
	else {
		alert("Merci de compléter l'e-mail.");
		}
	}

function testmail_en()
	{
	form=document.forms["bon"];
	
	if (form.email.value) {
		mail = form.email.value;
		arobase = mail.indexOf("@");
		espace = mail.indexOf(" ");
		doublarob = mail.indexOf("@",arobase+1);
		right = mail.substring(arobase + 1,mail.length);
		point = right.lastIndexOf(".");
		test = right.length-point;
	
	
		if ((espace==-1)&&(doublarob==-1)&&(arobase>1)&&(point>1)&&(test<6)&&(test>2))
			{
			form.submit();
			} 
		else {
			alert("Your email is not valid.\n (there shall be no space in it).");
			}
		}
	else {
		alert("Email is required.");
		}
	}

function post_recrutement(){
alias.getElementById('recrutement').submit();
alias.getElementById('table_popin').style.display = 'block';	
}

function candidature(url){
	document.getElementById('frm_recrutement').contentWindow.document.location.href = url;
	alias.getElementById('table_popin').style.display = 'block';	
}

function ouvre(nom,win,par)
{
ouvrir= open(nom,win,par);
}	
