function chargeFormulaire(aff_client) {
	document.title="Consulter le guide de la communication Construcom";
	aff_chargement('Chargement en cours...');
	var XHR = new XHRConnection();		
	XHR.setRefreshArea('framerecherche');
	XHR.sendAndLoad("guide/consultation-form.php?aff_client="+aff_client, "GET");
	//XHR.sendAndLoad("http://www.construcom.com/construcom/guide/consultation-form.php", "GET");
	window.setTimeout("chargeArbo()",100);
}
function goAcc(){
	document.location.href="index.php?page=guide/consultation-guide";
}
function chargeRecherche() {
	var XHR = new XHRConnection();		
	XHR.setRefreshArea('framerecherche');
	XHR.sendAndLoad("guide/consultation-recherche.php", "GET");
}
function aff_chargement(txt){
	msg="<div align='center' class='messageCouriergris'>"+txt+"</div>";
	document.getElementById('framerecherche').innerHTML = msg;
}

function recherche_libre(){
	document.title="Résultat de votre recherche sur le nom";
	//
	nom = Remplacer(document.forms['formlibre'].elements['nom'].value);	
	ville = document.forms['formlibre'].elements['ville'].value;	
	cp = document.forms['formlibre'].elements['cp'].value;	
	categorie = document.forms['formlibre'].elements['categorie'].options[document.forms['formlibre'].elements['categorie'].selectedIndex].value;	
	sess = document.forms['formlibre'].elements['sess'].value;	
	
	pays="";
	if (categorie==-1){
		souscategorie=-1;
	}
	else{
		souscategorie= document.forms['formlibre'].elements['souscategorie'].value;	
		if(souscategorie==16){
			pays = document.forms['formlibre'].elements['pays'].options[document.forms['formlibre'].elements['pays'].selectedIndex].value;	
		}
	}
	
	aff_chargement('Recherche en cours...');
	/*var XHR = new XHRConnection();		
	XHR.setRefreshArea('framerecherche');
	XHR.sendAndLoad("http://dev2.batiactu.com/cap_construcom/http/consultation-contenu.php?mode=libre&nom="+nom+"&ville="+ville+"&cp="+cp+"&categorie="+categorie+"&souscategorie="+souscategorie, "GET");*/
	document.location.href="index.php?page_in=cap_construcom%2Fhttp%2Fconsultation-contenu.php%3Fmode%3Dlibre%26nom%3D"+nom+"%26ville%3D"+ville+"%26cp%3D"+cp+"%26categorie%3D"+categorie+"%26souscategorie%3D"+souscategorie+"%26pays%3D"+pays+"%26valid_session%3D"+sess;
}
function Remplacer(a){

 var tmp;
 tmp = "";
 
 for(var i = 0; i < a.length; i++)
 {
 	
  
     if (a.charAt(i) == '&')
     {
     	tmp = tmp + '[ET]';
	 }
	 else{
	 	tmp = tmp + a.charAt(i);
	 }
 }
  
 return tmp;

}
function recherche_libre_pager(start){
	nom = document.forms['formlibre'].elements['nom'].value;	
	ville = document.forms['formlibre'].elements['ville'].value;	
	cp = document.forms['formlibre'].elements['cp'].value;	
	categorie = document.forms['formlibre'].elements['categorie'].value;	
	souscategorie = document.forms['formlibre'].elements['souscategorie'].value;	
	pays = document.forms['formlibre'].elements['pays'].value;	
	
	aff_chargement('Chargement de la page en cours...');
	var XHR = new XHRConnection();		
	XHR.setRefreshArea('framerecherche');
	XHR.sendAndLoad("cap_construcom/http/consultation-contenu.php?mode=libre&start="+start+"&nom="+nom+"&ville="+ville+"&cp="+cp+"&categorie="+categorie+"&souscategorie="+souscategorie+"&pays="+pays, "GET");
}
function recherche_cat(nom, cat_file,page){
	document.title="Fiches de la catégorie : "+nom;
	
	
	var XHR = new XHRConnection();		
	XHR.setRefreshArea('framerecherche');
	if(page==1){
		XHR.sendAndLoad('guide/categories/'+cat_file+".php", "GET");
		/*sess = document.forms['formlibre'].elements['sess'].value;	
		aff_chargement('Chargement en cours...');
		document.location.href="index.php?page_in=guide%2Fcategories%2F"+cat_file+".php%3Fvalid_session%3D"+sess;*/
	}
	else{
		XHR.sendAndLoad('guide/categories/'+cat_file+"-page-"+page+".php", "GET");
	}
	
}
function recherche_contact(){
	document.title="Résultat de votre recherche sur les contacts";
	nom = document.forms['formcontact'].elements['nom'].value;	
	prenom = document.forms['formcontact'].elements['prenom'].value;	
	sess = document.forms['formlibre'].elements['sess'].value;	
	
	aff_chargement('Recherche en cours...');
	/*var XHR = new XHRConnection();		
	XHR.setRefreshArea('framerecherche');
	XHR.sendAndLoad("http://dev2.batiactu.com/cap_construcom/http/consultation-contenu.php?mode=contact&nom="+nom+"&prenom="+prenom, "GET");*/

	document.location.href="index.php?page_in=cap_construcom%2Fhttp%2Fconsultation-contenu.php%3Fmode%3Dcontact%26nom%3D"+nom+"%26prenom%3D"+prenom+"%26valid_session%3D"+sess;
}
function recherche_contact_pager(start){
	nom = document.forms['formlibre'].elements['nom'].value;	
	prenom = document.forms['formlibre'].elements['prenom'].value;	
	aff_chargement('Chargement de la page en cours...');
	var XHR = new XHRConnection();		
	XHR.setRefreshArea('framerecherche');
	XHR.sendAndLoad("cap_construcom/http/consultation-contenu.php?mode=contact&mode=libre&start="+start+"&nom="+nom+"&prenom="+prenom, "GET");
}
function chargeArbo(){

	if(document.getElementById('divarbo')!=null){
		var XHR = new XHRConnection();	
		XHR.setRefreshArea('divarbo');
		XHR.sendAndLoad("guide/consultation-arbo.php", "GET");
		
		var XHR = new XHRConnection();	
		XHR.setRefreshArea('divcombo');
		XHR.sendAndLoad("guide/consultation-combo.php", "GET");
	}
	else{ 
		//alert('Erreur sur le div !!!');
		window.setTimeout("chargeArbo()",100);
	}

}
function chargeSousCat(){

	categorie = document.forms['formlibre'].elements['categorie'].options[document.forms['formlibre'].elements['categorie'].selectedIndex].value;	
	
	if(categorie==-1){
		document.getElementById('lignecombo2').style['visibility']='hidden';
		document.getElementById('lignecombo2').style['position']='absolute';
	}
	else{
		var XHR = new XHRConnection();	
		XHR.setRefreshArea('divcombo2');
		XHR.sendAndLoad("cap_construcom/http/consultation-combo2.php?id_cat="+categorie, "GET");

		document.getElementById('lignecombo2').style['visibility']='visible';
		document.getElementById('lignecombo2').style['position']='relative';
	}
}
function chargePays(){

	scategorie = document.forms['formlibre'].elements['souscategorie'].options[document.forms['formlibre'].elements['souscategorie'].selectedIndex].value;	
	
	if(scategorie!=16){
		document.getElementById('lignecombo3').style['visibility']='hidden';
		document.getElementById('lignecombo3').style['position']='absolute';
	}
	else{
		var XHR = new XHRConnection();	
		XHR.setRefreshArea('divcombo3');
		XHR.sendAndLoad("guide/consultation-combo-pays.php", "GET");

		document.getElementById('lignecombo3').style['visibility']='visible';
		document.getElementById('lignecombo3').style['position']='relative';
	}
}
function ouvreFiche(url){
	if(document.getElementById('url_back')!=null){
		val_retour=document.getElementById('url_back').value;
	}
	else{
		val_retour = "";
	}
	document.location.href="index.php?fiche="+url+"&url_back="+val_retour;
}
function pas_le_droit(){
	//window.alert('Pas de droit\nEnattendant un message dans un popup');
	pop = 	window.open("./guide/pas_le_droit.php","pas_le_droit","width=400, height=400 ,menubar=no");
	pop.focus();
	
}
function open_formulaire(url){
	pop = window.open("./forms/"+url,"formulaire","width=600, height=800 ,menubar=no");
	pop.focus();
}