function afficheMenu(obj){
	
	var idMenu     = obj.id;
	var idSousMenu = 'sous' + idMenu;
	var sousMenu   = document.getElementById(idSousMenu);
	
	/*****************************************************/
	/**	si le sous-menu correspondant au menu cliqué    **/
	/** est caché alors on l'affiche, sinon on le cache **/
	/*****************************************************/
	if(sousMenu.style.display == "none"){
		sousMenu.style.display = "block";
	}
	else{
		sousMenu.style.display = "none";
	}
	//setMainDivHeight();
	//resize();
}


function afficher(nom){ 
//alert(nom); 
document.getElementById(nom).style.display="block"; 


} 
function supprimer(nom){ 
//alert(nom); 
document.getElementById(nom).style.display="none"; 
} 



// JavaScript Document

function setMainDivHeight(){
	
	ScreenWidth = document.body.clientWidth;
	ScreenHeight = document.body.clientHeight;
	mainContenairWidth = window.document.getElementById("mainContenair").offsetWidth;
	NewsWidth = window.document.getElementById("News").offsetWidth;
	mainLeftHeight = window.document.getElementById("mainLeft").offsetHeight;
	mainRightHeight = window.document.getElementById("mainRight").offsetHeight;
	
	// Placement de la div News
	calculScreenWidth = ScreenWidth / 2;
	//alert(calculScreenWidth + " - " + NewsWidth + " - " + mainContenairWidth);
	calculmainContenanirWidth = mainContenairWidth / 2;
	calculNewsWidth = NewsWidth / 4;
	
	calculTotal = (calculScreenWidth +  calculmainContenanirWidth) - 125;
	//alert(calculTotal);
	
	
	
	
	
} // end function


function resize(){
	
	window.document.getElementById("News").style.left = calculTotal  + "px";
	window.document.getElementById("mainContenair").style.left = 200;
	if(mainLeftHeight > mainRightHeight){
		window.document.getElementById("main").style.height = mainLeftHeight  + "px";
	}else {
		window.document.getElementById("main").style.height = mainRightHeight  + "px";
	}
} // End Function




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

} // end function

function openNewWindow() {
 window.open("contactOk.html","_parent","_parent","");
 }


function verifFormulaire() {
	civilite = document.formulaire.civilite.value;
	organisme = document.formulaire.organisme.value;
	prenom = document.formulaire.prenom.value;
	nom = document.formulaire.nom.value;
	mail = document.formulaire.mail.value;
	telephone = document.formulaire.telephone.value;
	demande = document.formulaire.demande.value;
	adresse = document.formulaire.adresse.value;
	cp = document.formulaire.cp.value;
	ville = document.formulaire.ville.value;
	fax = document.formulaire.fax.value;
	
	
	
	if((civilite != "") && (prenom != "") && (nom != "") && (mail != "") && (telephone != "") && (demande != "")) {
		new AjaxConnector('sendMailSite.php', ["civilite=" + civilite,"organisme=" + organisme,"prenom=" + prenom, "nom=" + nom, "adresse=" + adresse, "cp=" + cp, "ville=" + ville,"mail=" + mail, "telephone=" + telephone,"fax=" + fax,  "demande=" + demande], openNewWindow, ajaxError)
	
	}else{
		tab = new Array();
		if(civilite == "") { tab.push("civilite"); document.formulaire.civilite.style.border = "thin solid #990000"; } else { document.formulaire.civilite.style.border = "thin solid #000000"; }
		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(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 changeTheme(id){
	new AjaxConnector('loadModule.php', ["theme_id=" + id], updateModuleList, ajaxError)
	
}

function updateModuleList(content){
	window.document.getElementById("listModule").innerHTML = content;
	
} 

function openModule(url){
	fw = window.open("ressources/pdf/"+url);	
	fw.focus();
	
}
