// JavaScript Document

function setMainDivHeight(){
	
	TestMenuLeftH = window.document.getElementById("mainMenuLeft").offsetHeight;
	TestMenuRightH = window.document.getElementById("mainMenuRight").offsetHeight;
	MenucssRight = window.document.getElementById("menucss").offsetWidth;
	
	ScreenWidth = document.body.clientWidth;
	ScreenHeight = document.body.clientHeight;
	

	
	//alert(TestMenuLeftH + " - " + TestMenuRightH);
} // end function


function resize(){
	
	//alert(MenucssRight + " - " + ScreenWidth);
	
	window.document.getElementById("menucss").style.left = (ScreenWidth / 2) - 280 + "px";
	
	if(TestMenuLeftH > TestMenuRightH){
		window.document.getElementById("main").style.height = TestMenuLeftH + "px";
		window.document.getElementById("mainMenuRight").style.height = TestMenuLeftH+ "px";
		//alert("gauche plus grand");
		
	}else if (TestMenuRightH > TestMenuLeftH){
		window.document.getElementById("main").style.height = TestMenuRightH + "px";
		window.document.getElementById("mainMenuLeft").style.height = TestMenuRightH + "px";
		//alert("droite plus grand");
		
	}
	
	
} // End Function



function imprimer(){
	window.print();
}





var url_server = "";

function getValue(value){
	switch(value){
		case "url_server": return url_server; break;
		case "CA_ID": return CA_ID; break;
		
	} // end switch
} // end function


// JavaScript Document
function ajaxError(code, message) {
	alert("Probleme de communication avec le serveur : " + code + " - " + message);

} // end function

function openNewWindow() {
 window.open("nous_rejoindre_ok.php","_parent","_parent","");
 }


function verifFormulaire() {
	organisme = document.formulaire.organisme.value;
	prenom = document.formulaire.prenom.value;
	nom = document.formulaire.nom.value;
	
	adresse = document.formulaire.adresse.value;
	cp = document.formulaire.cp.value;
	ville = document.formulaire.ville.value;
	fax = document.formulaire.fax.value;
	
	mail = document.formulaire.mail.value;
	telephone = document.formulaire.telephone.value;
	demande = document.formulaire.demande.value;
	
	
	
	if((prenom != "") && (nom != "") && (mail != "") && (telephone != "") && (organisme != "") && (demande != "")) {
		new AjaxConnector('sendMailRejoindre.php', ["prenom=" + prenom, "nom=" + nom, "organisme=" + organisme, "telephone=" + telephone, "mail=" + mail, "demande=" + demande, "adresse=" + adresse, "ville=" + ville, "cp=" + cp, "fax=" + fax], openNewWindow, ajaxError)
	
	}else{
		tab = new Array();
		
		if(nom == "") { tab.push("nom"); document.formulaire.nom.style.border = "thin solid #990000"; } else { document.formulaire.nom.style.border = "thin solid #000000"; }
		if(prenom == "") { tab.push("prenom"); document.formulaire.prenom.style.border = "thin solid #990000"; } else { document.formulaire.prenom.style.border = "thin solid #000000"; }
		if(organisme == "") { tab.push("entreprise"); document.formulaire.organisme.style.border = "thin solid #990000"; } else { document.formulaire.organisme.style.border = "thin solid #000000"; }
		if(mail == "") { tab.push("mail"); document.formulaire.mail.style.border = "thin solid #990000"; } else { document.formulaire.mail.style.border = "thin solid #000000"; }
		if(telephone == "") { tab.push("telephone"); document.formulaire.telephone.style.border = "thin solid #990000"; } else { document.formulaire.telephone.style.border = "thin solid #000000"; }
		if(demande == "") { tab.push("demande"); document.formulaire.demande.style.border = "thin solid #990000"; } else { document.formulaire.demande.style.border = "thin solid #000000"; }
		
		
		document.getElementById("erreur").innerHTML = "Veuillez remplir ces champs : " + tab.join(", ") + "<br /><br />";
		
	} // end if
} // end function

function recupIdentifiant(){
	new AjaxConnector('ressources/php/verifIdentifiant.php', ["mail=" + window.document.getElementById("chMail").value], feedbackVerif, ajaxError)
}

function feedbackVerif(data){
	window.document.getElementById("error").innerHTML = data;
	window.document.getElementById("chMail").value = "";
}
