var GLOBALS_path='http://www.placedelaformation.com/';

function nb_aleatoire(nb)
{
nombre= Math.floor(Math.random() * nb)+1;
return nombre;
} 

function getClientLogo() {
	var tabImg = new Array ("aelia.gif",
	"ag2rlamondiale_60.gif",
	"airliquide_60.gif", 
	"aprolis.gif",
	"astria.gif",
	"avis_60.gif",
	"axa_60.gif",
	"bestwestern.gif",
	"bmw_60.gif",
	"bollore.gif",
	"bt_60.gif",
	"cahpp_60.gif",
	"carrefour_60.gif",
	"clubmed.gif",
	"cocacola_60.gif",
	"danone_60.gif",
	"draka_60.gif",
	"emmaus.gif",
	"environnement_sa_60.gif",
	"fff_60.gif",
	"forclum_60.gif",
	"groupe_schiever_60.gif",
	"hachette_60.gif",
	"heytens_60.gif",
	"honeywell.gif",
	"ingdirect_60.gif",
	"ipsos.gif",
	"jpmorgan_60.gif",
	"keolis_60.gif",
	"koxka.gif",
	"kuehnenagel_60.gif",
	"lafarge_60.gif",
	"lainedelau_60.gif",
	"laser.gif",
	"leaseplan.gif",
	"legendre_60.gif",
	"lhoist_60.gif",
	"mcdonald.gif",
	"mediametrie.gif",
	"moet_chandon.gif",
	"monster_60.gif",
	"nmpp_60.gif",
	"norinco.gif",
	"nsk_60.gif",
	"packard-bell.gif",
	"pagepersonnel.gif",
	"panasonic_60.gif",
	"pierrevacances.gif",
	"renault.gif",
	"spencerstuart.gif",
	"stade.gif",
	"stars_service_60.gif",
	"surcouf_60.gif",
	"the_body_shop_60.gif",
	"tns_sofres_60.gif",
	"total.gif",
	"toyota.gif",
	"ucanss.gif",
	"uic.gif",
	"valeo.gif",
	"veolia_water.gif",
	"vivendi.gif");
	var dimtab=tabImg.length;
	var link_debut='<a title="Clients - Place de la Formation" href="'+GLOBALS_path+'clients.htm">';
	link_debut+='<img height="50" width="50" src="'+GLOBALS_path+'includes/img/clients/small/';
	var link_fin='" /></a>';
	var indicedepart;
	indicedepart=parseInt(nb_aleatoire(dimtab),10);
	if(indicedepart>=(dimtab-4)) { indicedepart=dimtab-4; }
	document.getElementById('clients_blocimg_1').innerHTML=link_debut+tabImg[indicedepart]+link_fin;
	document.getElementById('clients_blocimg_2').innerHTML=link_debut+tabImg[indicedepart+1]+link_fin;
	document.getElementById('clients_blocimg_3').innerHTML=link_debut+tabImg[indicedepart+2]+link_fin;
	document.getElementById('clients_blocimg_4').innerHTML=link_debut+tabImg[indicedepart+3]+link_fin;
}

function switchClientLogo(direction, indice) {
	

	
	var img1 = document.getElementById('img_client_1');
	var img2 = document.getElementById('img_client_2');
	var img3 = document.getElementById('img_client_3');
	
	var divleft = document.getElementById('img_client_arrow_left');
	var divright = document.getElementById('img_client_arrow_right');
	
	var tabImg = new Array ("aelia.gif",
	"airliquide_60.gif", 
	"alti.gif", 
	"aprolis.gif",
	"BBMconsulting.gif",
	"bestwestern.gif",
	"biesterfeld.gif",
	"bollore.gif",
	"cahpp_60.gif",
	"carpenter.gif",
	"chaletlac.gif",
	"clubmed.gif",
	"convictionrhs.gif",
	"cousin_biotech.gif",
	"cvdunet.gif",
	"dalet.gif",
	"emmaus.gif",
	"forclum_60.gif",
	"fretindustrie.gif",
	"fuji.gif",
	"getty.gif",
	"gisi.gif",
	"honeywell.gif",
	"infotem.gif",
	"ingdirect_60.gif",
	"innospec.gif",
	"internaltional-moduling.gif",
	"intertek.gif",
	"ipsos.gif",
	"itsgroup.gif",
	"japell.gif",
	"jcp-entreprise.gif",
	"keolis_60.gif",
	"koxka.gif",
	"krief.gif",
	"lafarge_60.gif",
	"laser.gif",
	"ld_a.gif",
	"leaseplan.gif",
	"leguide.gif",
	"lladro.gif",
	"manudax.gif",
	"mcdonald.gif",
	"mediametrie.gif",
	"megadyne.gif",
	"minnice.gif",
	"moet_chandon.gif",
	"net2s.gif",
	"netsize.gif",
	"norinco.gif",
	"ohsa.gif",
	"packard-bell.gif",
	"pagepersonnel.gif",
	"panda.gif",
	"parcours.gif",
	"pierrevacances.gif",
	"Prettre-sa.gif",
	"renault.gif",
	"roger_viollet.gif",
	"sames.gif",
	"schiever_60.gif",
	"semoflex_60.gif",
	"spencerstuart.gif",
	"stade.gif",
	"temis.gif",
	"terapharm.gif",
	"total.gif",
	"touflet.gif",
	"toyota.gif",
	"ucanss.gif",
	"uic.gif",
	"valeo.gif",
	"veolia_water.gif",
	"vivendi.gif");
	
	var dimtab = tabImg.length;

	switch (direction) {
		
	case "preload" :
	imageObj = new Image();
	for(i=0; i<=dimtab; i++)
     {
          imageObj.src=tabImg[i];
     }
	break;
	
	case "init":
	
	
	var indicedepart;
	indicedepart = nb_aleatoire(dimtab);
	if(indicedepart>=(dimtab-4)) { indicedepart=dimtab-4; }
	
	img1.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indicedepart] + '" /></a>';
	img2.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indicedepart+1] + '" /></a>';
	img3.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indicedepart+2] + '" /></a>';
	divleft.innerHTML = '<a title="Clients - Place de la Formation" href="javascript:switchClientLogo(\'left\',\''+indicedepart+'\');"><<</a>';
	divright.innerHTML = '<a title="Clients - Place de la Formation" href="javascript:switchClientLogo(\'right\',\''+indicedepart+'\');">>></a>';	
	break;
	
	case "left" :
	
	if (indice<=0) {
	while (indice<=0) {
		indice += dimtab;
		}
	}
	
	var indice1 =(parseInt(indice,10) - parseInt('1',10)) % (parseInt(dimtab,10));
	var indice2 = (parseInt(indice,10)) % (parseInt(dimtab,10));
	var indice3 = (parseInt(indice,10) + parseInt('1',10)) % (parseInt(dimtab,10));
	img1.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indice1] + '" /></a>';
	img2.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indice2] + '" /></a>';
	img3.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indice3] + '" /></a>';
	
	divleft.innerHTML = '<a title="Clients - Place de la Formation" href="javascript:switchClientLogo(\'left\',\''+(indice1)+'\');"><<</a>';
	divright.innerHTML = '<a title="Clients - Place de la Formation" href="javascript:switchClientLogo(\'right\',\''+(indice1)+'\');">>></a>';
	
	break;
	
	case "right":
	var indice1 = ((parseInt(indice,10) + parseInt('1',10)) % (parseInt(dimtab,10)));
	var indice2 = ((parseInt(indice,10) + parseInt('2',10)) % (parseInt(dimtab,10)));
	var indice3 = ((parseInt(indice,10) + parseInt('3',10)) % (parseInt(dimtab,10)));
	img1.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indice1] + '" /></a>';
	img2.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indice2] + '" /></a>';
	img3.innerHTML = '<a title="Clients - Place de la Formation" href="http://www.placedelaformation.com/clients.htm"><img height="50" width="50" src="includes/img/clients/small/' + tabImg[indice3] + '" /></a>';
	divleft.innerHTML = '<a title="Clients - Place de la Formation" href="javascript:switchClientLogo(\'left\',\''+(indice1)+'\');"><<</a>';
	divright.innerHTML = '<a title="Clients - Place de la Formation" href="javascript:switchClientLogo(\'right\',\''+(indice1)+'\');">>></a>';
	break;
	
	}
	
}

function xhr_send_formateur(method,file,file_args) {
	xhr_object_tab=new Array();
	var file=GLOBALS_pathformateur+file;
	var xhr_object;
	var flag_ready=false;
	if( window.XMLHttpRequest ) {
		xhr_object = new XMLHttpRequest();
		if (xhr_object.overrideMimeType) {
			xhr_object.overrideMimeType('text/xml');
		}
	} else if( window.ActiveXObject ) {
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		xhr_object_tab[0]='ko';
		xhr_object_tab[1]='Erreur : le navigateur ne supporte pas l objet xmlhttprequest';
		return xhr_object_tab;
	}
	if( method=='POST' ) {
		xhr_object.open("POST",file, false);
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(file_args);
		while( !flag_ready ) {
			if( xhr_object.readyState==4 ) {
				flag_ready=true;	
			}		
		}
		xhr_object_tab[0]='ok';
		xhr_object_tab[1]=xhr_object.responseText;
		return xhr_object_tab;
	} else if ( method=='GET' ) {
		xhr_object.open("GET",file+file_args, false);
		xhr_object.send(null);
		while( !flag_ready ) {
			if( xhr_object.readyState==4 ) {
				flag_ready=true;	
			}		
		}
		xhr_object_tab[0]='ok';
		xhr_object_tab[1]=xhr_object.responseText;
		return xhr_object_tab;
	} else {
		xhr_object_tab[0]='ko';
		xhr_object_tab[1]='Erreur : erreur argument method';
		return xhr_object_tab;
	}
}

function valid_inscription(type) {
	var valid=true;
	var data="?type="+type;
	
	switch (type)
	{
		
		case "formateur":
			
			var fields = new Array("societe","prenom","nom","mail","motdepasse1","motdepasse2");
			var n = fields.length;   // nombre de valeurs

			if (!(document.getElementById('cdu').checked))
			{
			//	alert (document.getElementById('cdu').checked);
				document.getElementById('etat_condition').innerHTML="Vous devez accepter les conditions ";
				valid=false;
			}
			else if(document.getElementById('cdu').checked=="true")
			{
				document.getElementById('etat_condition').innerHTML="";
				valid=true;
			}
			
			
			
			for (i=0; i<n; i++) {
		
			
				if(fields[i]!="telephone" && fields[i]!="portable")
					{
						if (document.getElementById("etatformateur_"+fields[i]).innerHTML != "" || document.getElementById(fields[i]).value == "") 
						{
							document.getElementById(fields[i]).style.border = "solid 2px #c93d1d";							
							valid=false;
						}
						else
						{
							document.getElementById(fields[i]).style.border = "solid 2px #46db34";
							
						}
					}
					
				data=data+"&"+fields[i]+"="+document.getElementById(fields[i]).value;
			
			}
						
			if(valid==true)
			{
				telfixe=document.getElementById('telephone').value;
				telportable=document.getElementById('portable').value;
				
				if (document.getElementById('civilite').options.selectedIndex>=0) 
				{
				var civilite;
				civilite=document.getElementById('civilite').options[document.getElementById('civilite').options.selectedIndex].value,document.getElementById('civilite').options[document.getElementById('civilite').options.selectedIndex].value;
				if( civilite==0 ) { return alert('Veuillez sélectionner une civilité'); }
				}
				if (document.getElementById('fonction').options.selectedIndex>=0) 
				{
				var fonction;	fonction=document.getElementById('fonction').options[document.getElementById('fonction').options.selectedIndex].value,document.getElementById('fonction').options[document.getElementById('fonction').options.selectedIndex].value;
				if( fonction==0 ) { return alert('Veuillez sélectionner une fonction'); }
				}
				data=data+ "&telephone="+telfixe+"&portable="+telportable+"&civilite="+civilite+"&fonction="+fonction;
				
				href="webformateur/save_inscription.php"+data
				
				ok=file(href);
				
				alert ('Inscription Validée');
				document.location.href="espace-formateur.htm";
				alert ('Bienvenue dans votre Espace Formateur');
				
			}	
			
		break; 
		
	
		
		
		

	}
	
	
}


function file(fichier) // permet d'executer un fihicer sans rafraichir la page exemple : file('page.php?variable1=valeur1&variable2=valeur2 ....');
{
var xhr_object=false;
	if(window.XMLHttpRequest)
	{
		// FIREFOX
		xhr_object = new XMLHttpRequest();
		if (xhr_object.overrideMimeType)
		{
		   xhr_object.overrideMimeType('text/xml');
		}
	}
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);

	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
	
}

function checkData_inscriptionFormateur(type,value) {

	div=document.getElementById('etat'+type);
	switch (type)
	{
		case  "formateur_prenomnom":
		break;
	}

}

function checkData(type,value)
{
	div=document.getElementById('etat'+type);
	switch (type)
	{
		case  "formateur_prenomnom":
		
			 var prenom=document.getElementById('prenom').value;
			var nom=document.getElementById('nom').value;
			var societe=document.getElementById('societe').value;
			var div1=document.getElementById('etatformateur_prenom');
			var div2=document.getElementById('etatformateur_nom');
			ok=file('checkdata.php?type='+type+'&nom='+nom+'&prenom='+prenom+'&societe='+societe);
				
			if(ok==0)
			{
				document.getElementById('nom').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_nom').innerHTML="Le nom ne peut être vide";
			}
			else if(ok==1)
			{
				document.getElementById('prenom').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_prenom').innerHTML="Le prénom ne peut être vide";
			}
			else if(ok==2)
			{
				document.getElementById('nom').style.border = "solid 2px #c93d1d";
				document.getElementById('prenom').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_nom').innerHTML="Cette personne est déjà référencée chez nous";
				
			}
			else if(ok==3)
			{
				document.getElementById('nom').style.border = "solid 2px #46db34";
				document.getElementById('prenom').style.border = "solid 2px #46db34";
				document.getElementById('etatformateur_nom').innerHTML="";
				document.getElementById('etatformateur_prenom').innerHTML="";

			}
		break;
		
		case "formateur_mdp1":
		
			var mdp1=document.getElementById('motdepasse1').value;
			var mdp2=document.getElementById('motdepasse2').value;
			var div1=document.getElementById('etatformateur_mdp1');
			var div2=document.getElementById('etatformateur_mdp2');
			type="formateur_mdp";
			ok=file('checkdata.php?type='+type+'&mdp1='+mdp1+'&mdp2='+mdp2);
			if(ok==0)
			{
				document.getElementById('motdepasse1').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_motdepasse1').innerHTML="Le mot de passe ne peut être vide";
			}
			else if(ok==1)
			{
				document.getElementById('motdepasse1').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_motdepasse1').innerHTML="Le mot de passe doit contenir 6 caractères minimum";
			}
			else if(ok==2)
			{
				document.getElementById('motdepasse1').style.border = "";
				document.getElementById('etatformateur_motdepasse1').innerHTML="";
			}
			else if(ok==4)
			{
				document.getElementById('motdepasse2').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_motdepasse2').innerHTML="La confirmation du mot de passe n'est pas correcte";
			}

		break;
		
		case "formateur_mdp2":
		
			var mdp1=document.getElementById('motdepasse1').value;
			var mdp2=document.getElementById('motdepasse2').value;
			//alert(mdp1);
			type="formateur_mdp";
			ok=file('checkdata.php?type='+type+'&mdp1='+mdp1+'&mdp2='+mdp2);
			if(ok==0)
			{
				document.getElementById('motdepasse1').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_motdepasse1').innerHTML="Le mot de passe ne peut être vide";
			}
			else if(ok==2)
			{
				document.getElementById('motdepasse2').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_motdepasse2').innerHTML="La confirmation de mot de passe ne peut être vide";
			}
			else if(ok==4)
			{
				document.getElementById('motdepasse2').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_motdepasse2').innerHTML="La confirmation du mot de passe n'est pas correcte";
			}
			else if(ok==5)
			{
				document.getElementById('motdepasse1').style.border = "solid 2px #46db34";
				document.getElementById('motdepasse2').style.border = "solid 2px #46db34";
				document.getElementById('etatformateur_motdepasse1').innerHTML="";
				document.getElementById('etatformateur_motdepasse2').innerHTML="";
			}
		break;
		
		case "formateur_mail":
		ok=file('checkdata.php?type='+type+'&value='+value);
			if(ok==0)
			{
				document.getElementById('mail').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_mail').innerHTML="L'e-mail ne peut être vide";
			}
			else if(ok==1)
			{
				document.getElementById('mail').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_mail').innerHTML="L'adresse e-mail entrée n'est pas valide";
			}
			else if(ok==2)
			{
				document.getElementById('mail').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_mail').innerHTML="Cette adresse e-mail est déjà référencée";
			}
			else if(ok==3)
			{
				document.getElementById('mail').style.border = "solid 2px #46db34";
				document.getElementById('etatformateur_mail').innerHTML="";
			}
			
		break;
		
		
		case "formateur_telfixe":
		ok=file('checkdata.php?type='+type+'&value='+value);
			if(ok==0)
			{
				document.getElementById('telephone').style.border = "";
				document.getElementById('etatformateur_telephone').innerHTML="";
			}
			else if(ok==1)
			{
				document.getElementById('telephone').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_telephone').innerHTML="Le numéro de téléphone ne peut contenir que des chiffres";
			}
			else if(ok==2)
			{
				document.getElementById('telephone').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_telephone').innerHTML="Le numéro de téléphone doit contenir 10 chiffres";
			}
			else if(ok==3)
			{
				document.getElementById('telephone').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_telephone').innerHTML="Le numéro de téléphone doit commencer par 0";
			}
			else if(ok==4)
			{
				document.getElementById('telephone').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_telephone').innerHTML="L'indicatif doit être compris entre 1 et 5";
			}
			else if(ok==5)
			{
				document.getElementById('telephone').style.border = "solid 2px #46db34";
				document.getElementById('etatformateur_telephone').innerHTML="";
			}
			
		break;
		
		case "formateur_telportable":
		ok=file('checkdata.php?type='+type+'&value='+value);
			if(ok==0)
			{
				document.getElementById('portable').style.border = "";
				document.getElementById('etatformateur_portable').innerHTML="";
			}
			else if(ok==1)
			{
				document.getElementById('portable').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_portable').innerHTML="Le numéro de téléphone ne peut contenir que des chiffres";
			}
			else if(ok==2)
			{
				document.getElementById('portable').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_portable').innerHTML="Le numéro de téléphone doit contenir 10 chiffres";
			}
			else if(ok==3)
			{
				document.getElementById('portable').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_portable').innerHTML="Le numéro de téléphone doit commencer par 0";
			}
			else if(ok==4)
			{
				document.getElementById('portable').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_portable').innerHTML="L'indicatif doit être compris entre 1 et 5";
			}
			else if(ok==5)
			{
				document.getElementById('portable').style.border = "solid 2px #46db34";
				document.getElementById('etatformateur_portable').innerHTML="";
			}

		break;
		
		case "formateur_societe":
		ok=file('checkdata.php?type='+type+'&value='+value);
			if(ok==0)
			{
				document.getElementById('societe').style.border = "solid 2px #c93d1d";
				document.getElementById('etatformateur_societe').innerHTML="La société ne peut être vide";
			}
			else if(ok==1)
			{
				document.getElementById('societe').style.border = "solid 2px #46db34";
				document.getElementById('etatformateur_societe').innerHTML="";
			}
		break;
		
		case "mail":
		ok=file('checkdata.php?type='+type+'&value='+value);
			if(ok==0)
			{
				document.getElementById('login').style.border = "solid 2px #c93d1d";
				document.getElementById('etatlogin').innerHTML="E-mail vide";
			}
			else if(ok==1)
			{
				document.getElementById('login').style.border = "solid 2px #c93d1d";
				document.getElementById('etatlogin').innerHTML="E-mail invalide";
			}
			else if(ok==2)
			{
				document.getElementById('login').style.border = "solid 2px #c93d1d";
				document.getElementById('etatlogin').innerHTML="<a href='' >Inscrivez vous >></a>";
			}
			else if(ok==3)
			{
				document.getElementById('etatlogin').innerHTML="";
			}
			
		break;
		
		case "mdp":

			ok=file('checkdata.php?type='+type+'&mdp='+value+'&email='+document.getElementById('login').value);
			
			if(ok==0)
			{
				document.getElementById('mdp').style.border = "solid 2px #c93d1d";
				document.getElementById('etatmdp').innerHTML="E-mail vide";
			}
			else if(ok==1)
			{
				document.getElementById('mdp').style.border = "solid 2px #c93d1d";
				document.getElementById('etatmdp').innerHTML="Mot de passe vide";
			}
			else if(ok==2)
			{
				document.getElementById('mdp').style.border = "solid 2px #c93d1d";
				document.getElementById('etatmdp').innerHTML="6 caractères minimum";
			}
			else if(ok==3)
			{
				document.getElementById('mdp').style.border = "solid 2px #c93d1d";
				document.getElementById('etatmdp').innerHTML="Mot de passe incorrect";
			}
			else if(ok==4)
			{
				document.getElementById('etatmdp').innerHTML="";
			}

		break;
		
		default:
			
		break;
	}
}

function ajaxDiv(zone, method, href, data){

	// /!\attention ne pas mettre de virgules ni des 2 points dans vos post/get/valeurs!!!! /!\

	var zone;
	var method;
	var data;
	var href;
	
	// Firefox
	if( window.XMLHttpRequest )
	{
		xhr_object = new XMLHttpRequest();
		if (xhr_object.overrideMimeType)
		{
		   xhr_object.overrideMimeType('text/xml');
		}
	}
	// IE
	else if( window.ActiveXObject ) { xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); }
	
	var tabTwo = new Array();
	var tabOne = new Array();
	

	tabOne = data.split(',');
	data = "";

	var n = tabOne.length;

	for (i=0; i<n; i++) {		
		tabTwo = tabOne[i].split(':');
		data += tabTwo[0] + "=" + tabTwo[1] + "&";		
	}
	
	data = data.substring(0, data.length-1);
	//alert(data);	


	xhr_object.open(method, href, false);
	
	if(method == "POST"){
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
	}

	xhr_object.send(data);
	

	if(xhr_object.readyState == 4){			
		var div = document.getElementById(zone);
		div.innerHTML = xhr_object.responseText;
	}
	
} 

function ajaxDivByGet(zone, href){

	// /!\attention ne pas mettre de virgules ni des 2 points dans vos post/get/valeurs!!!! /!\

	var zone;
	var href;
	
	//alert(href);

	// Firefox
	if( window.XMLHttpRequest )
	{
		xhr_object = new XMLHttpRequest();
		if (xhr_object.overrideMimeType)
		{
		   xhr_object.overrideMimeType('text/xml');
		}
	}
	// IE
	else if( window.ActiveXObject ) { xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); }

	xhr_object.open("GET", href, false);
	
	xhr_object.send(null);
	
	if(xhr_object.readyState == 4){			
		var div = document.getElementById(zone);
		div.innerHTML = xhr_object.responseText;
	}
	
}

function changeStyle(event,idDiv)
{
	switch (event)
	{
		case 'onmouseover' :
			if( !(document.getElementById(idDiv).style.backgroundColor=='rgb(241, 210, 178)') )
			{
				document.getElementById(idDiv).style.backgroundColor='#e8edef';
			}
		break;

		case 'onmouseout' :
			if( !(document.getElementById(idDiv).style.backgroundColor=='rgb(241, 210, 178)') )
			{
				document.getElementById(idDiv).style.backgroundColor='white';
			}
		break;

		case 'onclick' :
			if( document.getElementById(idDiv).style.backgroundColor=='white' || document.getElementById(idDiv).style.backgroundColor==''
			|| document.getElementById(idDiv).style.backgroundColor=='rgb(232, 237, 239)' )
			{
				document.getElementById(idDiv).style.backgroundColor='#f1d2b2';
			}
			else
			{
				document.getElementById(idDiv).style.backgroundColor='white';
			}
		break;
	}

}

function changeStyleLinkMoyen(idDiv)
{
	document.getElementById(idDiv).style.backgroundColor='#888888';
	if( idDiv=='f_tbd_block_form_formation_linkinter' )
	{
		if( document.getElementById('f_tbd_block_form_formation_linkintra') )
		{
			document.getElementById('f_tbd_block_form_formation_linkintra').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkelearn') )
		{
			document.getElementById('f_tbd_block_form_formation_linkelearn').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linktel') )
		{
			document.getElementById('f_tbd_block_form_formation_linktel').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkvideo') )
		{
			document.getElementById('f_tbd_block_form_formation_linkvideo').style.backgroundColor='#CED9DC';
		}
	}
	if( idDiv=='f_tbd_block_form_formation_linkintra' )
	{
		if( document.getElementById('f_tbd_block_form_formation_linkinter') )
		{
			document.getElementById('f_tbd_block_form_formation_linkinter').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkelearn') )
		{
			document.getElementById('f_tbd_block_form_formation_linkelearn').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linktel') )
		{
			document.getElementById('f_tbd_block_form_formation_linktel').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkvideo') )
		{
			document.getElementById('f_tbd_block_form_formation_linkvideo').style.backgroundColor='#CED9DC';
		}
	}
	if( idDiv=='f_tbd_block_form_formation_linkelearn' )
	{
		if( document.getElementById('f_tbd_block_form_formation_linkinter') )
		{
			document.getElementById('f_tbd_block_form_formation_linkinter').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkintra') )
		{
			document.getElementById('f_tbd_block_form_formation_linkintra').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linktel') )
		{
			document.getElementById('f_tbd_block_form_formation_linktel').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkvideo') )
		{
			document.getElementById('f_tbd_block_form_formation_linkvideo').style.backgroundColor='#CED9DC';
		}
	}
	if( idDiv=='f_tbd_block_form_formation_linktel' )
	{
		if( document.getElementById('f_tbd_block_form_formation_linkinter') )
		{
			document.getElementById('f_tbd_block_form_formation_linkinter').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkintra') )
		{
			document.getElementById('f_tbd_block_form_formation_linkintra').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkelearn') )
		{
			document.getElementById('f_tbd_block_form_formation_linkelearn').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkvideo') )
		{
			document.getElementById('f_tbd_block_form_formation_linkvideo').style.backgroundColor='#CED9DC';
		}
	}
	if( idDiv=='f_tbd_block_form_formation_linkvideo' )
	{
		if( document.getElementById('f_tbd_block_form_formation_linkinter') )
		{
			document.getElementById('f_tbd_block_form_formation_linkinter').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkintra') )
		{
			document.getElementById('f_tbd_block_form_formation_linkintra').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linkelearn') )
		{
			document.getElementById('f_tbd_block_form_formation_linkelearn').style.backgroundColor='#CED9DC';
		}
		if( document.getElementById('f_tbd_block_form_formation_linktel') )
		{
			document.getElementById('f_tbd_block_form_formation_linktel').style.backgroundColor='#CED9DC';
		}
	}
}

function sleep(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 


/* FUNCTIONS FORMULAIRE WEBFORM  */ 


function url_get_contact_add() {
var url = "webformateur/contacts.add.php?nom=" + document.getElementById("nom") + "&prenom=" + document.getElementById("prenom") + "&mail=" + document.getElementById("mail")  + "&tel1=" + document.getElementById("tel1") + "&tel2=" + document.getElementById("tel2") + "&fonction=" + document.getElementById("fonction") + "&password=" + document.getElementById("password") + "&password2=" + document.getElementById("password2") + "&commentaire=" + document.getElementById("commentaire") ;  

return url;
	}
	
function validCGU() {
	data="action=cguvalid";
	href="webformateur/espace-formateur.act.php?"+data			
	ok=file(href);
	alert('Conditions générales d utilisation validées');
	window.location="espace-formateur.htm";
}

/* -------------------------------------------------- CHECK ------------------------------------------------------------------------ */

EMail=function(email) {
	this.email=email;
	this.isValid=function() {
		var ValidMail=new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]{1,}([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,3}$', 'i');
		if(ValidMail.test(this.email)) return true;
		else return false;
	}
}

DATE=function(date) {
	this.date=date;
	this.isValid=function() {
		// Cette fonction vérifie le format JJ/MM/AAAA saisi et la validité de la date.
		// Le séparateur est défini dans la variable separateur
		var currentTime = new Date()
		
		var annee=currentTime.getFullYear();
		var mois=currentTime.getMonth() + 1;
		var jour=currentTime.getDate();
		var separateur="/"; // separateur entre jour/mois/annee
		var j=(this.date.substring(0,2));
		var m=(this.date.substring(3,5));
		var a=(this.date.substring(6));
		var ok=1;
		if ( ((this.date.substring(2,3)!=separateur)||(this.date.substring(5,6)!=separateur)) && (ok==1) ) {
		   ok=0;
		}
		// KR
		if(isNaN(a)||isNaN(m)||isNaN(j)) { ok=0 }
		else {
			if(a<annee) { ok=0 }
			else {
				if(a==annee && (m<mois||m<1||m>12)) { ok=0; }
				else if(a>annee && (m<1||m>12)) { ok=0; }
				else if(a==annee && m==mois && (j<jour||j<1||j>31)) { ok=0; }
				else if(j<1||j>31) { ok=0; }
			}
		}
		// KR end
		/*
		if ( ((isNaN(a))||(a<annee)) && (ok==1) ) {
		   ok=0;
		}
		if ( ((isNaN(m))||((m<1)||(m>12)) || m<mois) && (ok==1) ) {
		   ok=0;
		}
		if ( ((isNaN(j))||((j<1)||(j>31)) || j<jour) && (ok==1) ) {
		   ok=0;
		}
		*/
		if (ok==1) {
		   var d2=new Date(a,m-1,j);
			j2=d2.getDate();
			m2=d2.getMonth()+1;
			a2=d2.getFullYear();
			if (a2<=100) {a2=1900+a2}
			if ( (j!=j2)||(m!=m2)||(a!=a2) ) {
				ok=0;
			}
		}
		if(ok==1){
			return true;
		}
		else{
			return false;
		}
	}
}

NOMBRE=function(nombre) {
	this.nombre=nombre;
	this.isValid=function() {
		var ValidNombre=new RegExp('^[0-9]*$','i');
		if(ValidNombre.test(this.nombre)) return true;
		else return false;
	}
	this.notEmptyANDisValid=function() {
		var ValidNombre=new RegExp('^[0-9]+$','i');
		if(ValidNombre.test(this.nombre)) return true;
		else return false;
	}
	this.notEmptyANDisValidANDnozeroleft=function() {
		var ValidNombre=new RegExp('^[1-9][0-9]*$','i');
		if(ValidNombre.test(this.nombre)) return true;
		else return false;
	}
	this.isPrix=function() {
		var ValidNombre=new RegExp('^[1-9][0-9]*((\.|,)[0-9][0-9])?$','i');
		if(ValidNombre.test(this.nombre)) return true;
		else return false;
	}
	this.isPrix0=function() {
		var ValidNombre=new RegExp('^[0-9]*((\.|,)[0-9][0-9])?$','i');
		if(ValidNombre.test(this.nombre)) return true;
		else return false;
	}
}

Check=function() {
	this.element=function(type,value) {
		var retour=new Array(
		"0",
		""
		);
		switch(type.split("-")[0]) {
		case 'text' :
			switch(type.split("-")[1]) {
				case 'facultatif' :
					break;
				case 'nonVide' :
					if(value=="") {
						retour[0]="-1";
						retour[1]="obligatoire";
					}
					break;
				case 'emailValide' :
					var email=new EMail(value);
					if(!email.isValid()) {
						retour[0]="-1";
						retour[1]="email non valide";
					}
					break;
				case 'email_nonVideANDValide' :
					var email=new EMail(value);
					if(!email.isValid()) {
						retour[0]="-1";
						retour[1]="obligatoire et doit être valide";
					}
					break;
				case 'nombre_facultatif' :
					var nombre=new NOMBRE(value);
					if(!nombre.isValid()) {
						retour[0]="-1";
						retour[1]="doit contenir que des chiffres";
					}
					break;
				case 'nombre_nonVideANDValide' :
					var nombre=new NOMBRE(value);
					if(!nombre.notEmptyANDisValid()) {
						retour[0]="-1";
						retour[1]="obligatoire et doit contenir que des chiffres";
					}
					break;
				case 'nombre_notEmptyANDisValidANDnozeroleft' :
					var nombre=new NOMBRE(value);
					if(!nombre.notEmptyANDisValidANDnozeroleft()) {
						retour[0]="-1";
						retour[1]="obligatoire, doit contenir que des chiffres et pas de zéro a gauche";
					}
					break;
				case 'nombre_nonVideANDprixValide' :
					var nombre=new NOMBRE(value);
					if(!nombre.isPrix()) {
						retour[0]="-1";
						retour[1]="non valide \n";
						retour[1]+="exemples valides : 1500 ; 1800,39 ; 2000.50 ";
					}
					break;
				case 'nombre_prixValide' :
					var nombre=new NOMBRE(value);
					if(value!='' && !nombre.isPrix()) {
						retour[0]="-1";
						retour[1]="non valide \n";
						retour[1]+="exemples valides : 1500 ; 1800,39 ; 2000.50 ";
					}
					break;
				case 'nombre_prixValideANDaccept0' :
					var nombre=new NOMBRE(value);
					if(value!='' && !nombre.isPrix0()) {
						retour[0]="-1";
						retour[1]="non valide \n";
						retour[1]+="exemples valides : 1500 ; 1800,39 ; 2000.50 ";
					}
					break;
				case 'date_nonVideANDValide' :
					var date=new DATE(value);
					if(value=='' || date.isValid()==false) {
						var currentTime = new Date()
		
						var annee=currentTime.getFullYear();
						var mois=currentTime.getMonth() + 1;
						var jour=currentTime.getDate();
						retour[0]="-1";
						retour[1]="non valide \n";
						retour[1]+="exemple valide : >= "+jour+"/"+mois+"/"+annee;
					}
					break;	
				default :
					retour[0]="-1";
					retour[1]="Type <"+type+"> n existe pas";
					break;
			}
			break;
		case 'hidden' :
			switch(type.split("-")[1]) {
			case 'nombre_nonVideANDValide' :
					var nombre=new NOMBRE(value);
					if(!nombre.notEmptyANDisValid()) {
						retour[0]="-1";
						retour[1]="obligatoire et doit contenir que des chiffres";
					}
					break;
			}
			break;
		case 'select' :
			switch(type.split("-")[1]) {
				case 'facultatif' :
					break;
				case 'nonVide' :
					if(value=="") {
						retour[0]="-1";
						retour[1]="sélection obligatoire";
					}
					break;
			}
			break;
		case 'password' :
			switch(type.split("-")[1]) {
				case 'min6Char' :
					if(value=="" || value.length<6) {
						retour[0]="-1";
						retour[1]="obligatoire et doit avoir au moins 6 caractères";
					}
					break;
			}
			break;
		default :
			retour[0]="-1";
			retour[1]="Type <"+type+"> n existe pas";
			break;
		}
		return retour;
	}
	
}

function bloc_webformateur_actu_effet()
{
	if(document.getElementById('webformateur_actu_toeffet')) 
	{
		var tcolor=new Array(
		'b1442c',
		'c8644e',
		'db998a',
		'e8c7c0',
		'ffffff'
		);
		var tcolor_len=tcolor.length;
		var i=0;
		var timeout=1000;
		for(i;i<tcolor_len;i++) 
		{
			setTimeout("document.getElementById('webformateur_actu_toeffet').style.color='#"+tcolor[i]+"'",timeout);
			timeout=parseInt(timeout)+60;
		}
		i--;
		for(i;i>=0;i--) 
		{
			setTimeout("document.getElementById('webformateur_actu_toeffet').style.color='#"+tcolor[i]+"'",timeout);
			timeout=parseInt(timeout)+60;
		}
		i++;
		for(i;i<tcolor_len;i++) 
		{
			setTimeout("document.getElementById('webformateur_actu_toeffet').style.color='#"+tcolor[i]+"'",timeout);
			timeout=parseInt(timeout)+60;
		}
		i--;
		for(i;i>=0;i--) 
		{
			setTimeout("document.getElementById('webformateur_actu_toeffet').style.color='#"+tcolor[i]+"'",timeout);
			timeout=parseInt(timeout)+60;
		}
	}
}
