function mod_skin(i) {
	nom_palette="palette" + String(i)  + ".css" ;
	top.f1.document.getElementsByTagName("link")[0].href = nom_palette ;
	
	var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { tester_skin(xhr); };
    xhr.open("GET", "params_skins.asp?p=" + i , true);
    xhr.send(null);
}

function mod_skin2(i) {
	nom_palette="palette" + String(i)  + ".css" ;
	document.getElementsByTagName("link")[0].href = nom_palette ;
	
	var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { tester_skin(xhr); };
    xhr.open("GET", "params_skins2.asp?p=" + i , true);
    xhr.send(null);
}

//////////////////////////////////////////
function tester_skin(xhr) {
	if (xhr.readyState==4) alert_ajax_skin(xhr);
	}

function alert_ajax_skin(xhr) {
	obj = document.getElementById("contenu_footer") ;
	obj.innerHTML = xhr.responseText ;
}

///////////////////////////
function aj_crit(id_metier, id_ecole, id_contrat)
{
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { tester_crit(xhr); };
    
    xhr.open("GET", "params_crit.asp?id_metier=" + id_metier + "&id_ecole=" + id_ecole + "&id_contrat=" + id_contrat, true);
    xhr.send(null);
}

function tester_crit(xhr) {
	if (xhr.readyState==4) alert_ajax_crit(xhr);
	}
	
function alert_ajax_crit(xhr)
{
	var txt = new String();
	txt =  xhr.responseText ;
	var reg=new RegExp("[|]", "g");
	var tb = txt.split(reg);	
	obj = document.getElementById("celres") ;	
	obj.innerHTML = tb[0]; ;
	obj = document.getElementById(tb[1]) ;	
	obj.innerHTML ="<img src='images/spacer.gif'>" ;
}

///////////////////////////
function supp_crit_metier(id_metier)
{
    var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { tester_sup_crit_metier(xhr, id_metier); };
    xhr.open("GET", "params_sup_crit.asp?id=" + id_metier + "&ty=metier", true);
    xhr.send(null);
}
function tester_sup_crit_metier(xhr, id_metier) {
	if (xhr.readyState==4) alert_ajax_sup_crit_metier(xhr, id_metier);
	}
	
function alert_ajax_sup_crit_metier(xhr, id_metier)
{
	var txt = new String();
	txt =  xhr.responseText ;
	var reg=new RegExp("[|]", "g");
	var tb = txt.split(reg);	
	obj = document.getElementById("celres") ;	
	obj.innerHTML = tb[0]; ;
	obj = document.getElementById(tb[1]) ;	
	obj.innerHTML ="<a href=\"#\" onclick=\"javascript:aj_crit('" + id_metier + "','','')\"><img src='images/plus_rech.jpg' border=0></a>" ;
}

///////////////////////////
function supp_crit_ecole(id_ecole)
{
    var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { tester_sup_crit_ecole(xhr, id_ecole); };
    xhr.open("GET", "params_sup_crit.asp?id=" + id_ecole + "&ty=ecole", true);
    xhr.send(null);
}
function tester_sup_crit_ecole(xhr, id_ecole) {
	if (xhr.readyState==4) alert_ajax_sup_crit_ecole(xhr, id_ecole);
	}
	
function alert_ajax_sup_crit_ecole(xhr, id_ecole)
{
	var txt = new String();
	txt =  xhr.responseText ;
	var reg=new RegExp("[|]", "g");
	var tb = txt.split(reg);	
	obj = document.getElementById("celres") ;	
	obj.innerHTML = tb[0]; ;
	obj = document.getElementById(tb[1]) ;	
	obj.innerHTML ="<a href=\"#\" onclick=\"javascript:aj_crit('','" + id_ecole + "','')\"><img src='images/plus_rech.jpg' border=0></a>" ;
}

///////////////////////////
function supp_crit_contrat(id_contrat)
{
    var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { tester_sup_crit_contrat(xhr, id_contrat); };
    xhr.open("GET", "params_sup_crit.asp?id=" + id_contrat + "&ty=contrat", true);
    xhr.send(null);
}
function tester_sup_crit_contrat(xhr, id_contrat) {
	if (xhr.readyState==4) alert_ajax_sup_crit_contrat(xhr, id_contrat);
	}
	
function alert_ajax_sup_crit_contrat(xhr, id_contrat)
{
	var txt = new String();
	txt =  xhr.responseText ;
	var reg=new RegExp("[|]", "g");
	var tb = txt.split(reg);	
	obj = document.getElementById("celres") ;	
	obj.innerHTML = tb[0]; ;
	obj = document.getElementById(tb[1]) ;	
	obj.innerHTML ="<a href=\"#\" onclick=\"javascript:aj_crit('','','" + id_contrat + "')\"><img src='images/plus_rech.jpg' border=0></a>" ;
}


///////////////////////
function raz_crit()
{
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { tester_raz(xhr); };
    
    xhr.open("GET", "params_raz_crit.asp", true);
    xhr.send(null);
}

function tester_raz(xhr) {
	if (xhr.readyState==4) alert_ajax_raz_crit(xhr);
	}
	
function alert_ajax_raz_crit(xhr)
{
	obj = document.getElementById("celres") ;
	obj.innerHTML = "<strong class=titrebleu13>Ajoutez des crit&egrave;res &agrave; votre recherche en cliquant sur <img src='images/plus_rech.jpg'/> et supprimez avec <img src='images/moins_rech.jpg' /></strong>" ;
	txt =  xhr.responseText ;
	var reg=new RegExp("[|]", "g");
	var tb = txt.split(reg);	
	var reg=new RegExp("[,]", "g");
	var tb2 = tb[0].split(reg);	
	for (j=0;j<tb2.length;j++) {
		cel = "im_met" + String(tb2[j]) ;
		obj = document.getElementById(cel) ;
		obj.innerHTML ="<a href=\"#\" onclick=\"javascript:aj_crit('" + tb2[j] + "','','')\"><img src='images/plus_rech.jpg' border=0></a>" ;
	}
	var tb2 = tb[1].split(reg);	
	for (j=0;j<tb2.length;j++) {
		cel = "im_ecole" + String(tb2[j]) ;
		obj = document.getElementById(cel) ;
		obj.innerHTML ="<a href=\"#\" onclick=\"javascript:aj_crit('','" + tb2[j] + "','')\"><img src='images/plus_rech.jpg' border=0></a>" ;
	}
	var tb2 = tb[2].split(reg);	
	for (j=0;j<tb2.length;j++) {
		cel = "im_cont" + String(tb2[j]) ;
		obj = document.getElementById(cel) ;
		obj.innerHTML ="<a href=\"#\" onclick=\"javascript:aj_crit('','','" + tb2[j] +"')\"><img src='images/plus_rech.jpg' border=0></a>" ;
	}
}	
	
////////////////////////////////////////
function ajax(l1,l2,l3,l4)
{
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { tester_reponse_drag(xhr); };
    
    xhr.open("GET", "reponse.asp?l1=" + l1 + "&l2=" + l2 + "&l3=" + l3 + "&l4=" + l4, true);
    xhr.send(null);
}

//////////////////////////////////////////
function tester_reponse_drag(xhr) {
	if (xhr.readyState==4) alert_ajax_drag(xhr);
	}

function alert_ajax_drag(xhr) {

}

//////////////////////////////////////////
function tester_reponse(xhr,act,id_question) {
	if (xhr.readyState==4) alert_ajax(xhr,act,id_question);
} 

//////////////////////////////////////////
function tester_reponse2(xhr) {

} 


var input = null;
//////////////////////////
function alert_ajax(xhr,act,id_question)
{
	if (act=="aj_reponse") {
		obj = document.getElementById("texte_new_question") ;
		obj.innerHTML = "<b>Q : " + xhr.responseText + "</b>";
	}	
	
	if (act=="aj_reponse")	obj = document.getElementById("pave_saisie") ;
	else {
		ch = "texte_reponse" + id_question ;
		obj = document.getElementById(ch) ;	
		}
		
	input = document.createElement("textarea");
	input.style.width = "400px";
	input.style.height = "50px";
	if (act=="mod_reponse")	{
		t =  xhr.responseText ;
		input.value =  strip_inv(t) ;
			}
	obj.replaceChild(input, obj.firstChild);
	
	if (act=="aj_reponse") {
		obj = document.getElementById("lien_maj") ;
		obj.style.visibility = "visible";
		}
	else {
		ch = "lien_mod" + id_question ;
		obj = document.getElementById(ch) ;	
		obj.innerHTML = "<a href=# class='gris' onclick='javascript:verif_reponse()'>Validez</a>" ;
	}
		

}

//////////////////////
function ouvrir_reponse(act, id_question, id_user) {
    var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.onreadystatechange = function() { tester_reponse(xhr, act,id_question); };
	ch = "params_espace_perso.asp?ACT=" + act + "&id_question=" + id_question + "&id_user=" + id_user;
    xhr.open("GET",ch , true);
    xhr.send(null);
}

//////////////////////
function ouvrir_descrip(id_user) {
    var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.onreadystatechange = function() { tester_reponse_descrip(xhr, id_user); };
	ch = "params_descrip_user.asp?id_user=" + id_user;
    xhr.open("GET",ch , true);
    xhr.send(null);
}

//////////////////////////////////////////
function tester_reponse_descrip(xhr, id_user) {
	if (xhr.readyState==4) alert_ajax_descrip(xhr,id_user);
} 

//////////////////////////
function alert_ajax_descrip(xhr,id_user)
{

	obj = document.getElementById("descrip_user") ;	
	input = document.createElement("textarea");
	input.style.width = "400px";
	input.style.height = "60px";
	input.value =  strip_inv(xhr.responseText) ;
	obj.replaceChild(input, obj.firstChild);
	
	ch = "lien_mod_descrip" ;
	obj = document.getElementById(ch) ;	
	obj.innerHTML = "<a href=# class='gris' onclick='javascript:verif_descrip()'>Validez</a>" ;
	

}

////////////////////////////////////
function verif_descrip() {
	d = document.forms['perso'] ;
	if (input.value=="") alert("Veuillez saisir le descriptif");
	else {
		d.texte_ref.value = input.value;
		d.action = "espace_perso.asp";
		d.ACT.value="mod_descrip" ;
		d.submit();
		input = null;
	}
}

////////////////////////////////////
function verif_pb() {
	d = document.forms['form_pb'] ;
	if ( (d.mail.value=="")|| (d.mail.value=="Votre adresse e-mail...") ) alert("Veuillez saisir votre adresse e-mail");
	else {
		var xhr=null;
		if (window.XMLHttpRequest) { 
			xhr = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) 
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
		xhr.onreadystatechange = function() { tester_reponse_pb(xhr); };
		ch = "params_pb.asp?mail=" + d.mail.value + "&descrip=" + d.descrip.value;
		xhr.open("GET",ch , true);
		xhr.send(null);
	}
}
//////////////////////////////////////////
function tester_reponse_pb(xhr, id_user) {
	if (xhr.readyState==4) alert_ajax_pb(xhr,id_user);
} 

//////////////////////////
function alert_ajax_pb(xhr,id_user)
{
	obj = document.getElementById("contenu_merci") ;
	obj.innerHTML = "<div align=center>Merci pour votre message</div>" ;
}




////////////////////////////////////
function verif_reponse() {
	d = document.forms['perso'] ;
	if (input.value=="") alert("Veuillez saisir la réponse à la question");
	else {
		d.texte_ref.value = input.value;
		d.action = "maj_reponse.asp";
		d.submit();
		input = null;
	}
}

//////////
function aff_reponse(id_reponse, id_question, id_user) {
    var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.onreadystatechange = function() { afficher_reponse(xhr, id_reponse, id_question, id_user); };
	ch = "params_reponse.asp?id_reponse=" + id_reponse;
    xhr.open("GET",ch , true);
    xhr.send(null);
}

//////////////////////////////////////////
function afficher_reponse(xhr,id_reponse, id_question, id_user) {
	if (xhr.readyState==4) alert_ajax3(xhr,id_reponse, id_question, id_user);
}

function alert_ajax3(xhr,id_reponse, id_question, id_user) {
		ch = "cell_reponse" + String(id_question) ;
		obj = document.getElementById(ch) ;
		obj.innerHTML = "R : " + xhr.responseText;

		ch = "cell_lien" + String(id_question) ;
		obj = document.getElementById(ch) ;
		obj.innerHTML = "<a href='liste_reponses.asp?rub=liste_rep&id_reponse=" + id_reponse + "&id_user=" + id_user + "&id_question=" + id_question + "' class=gris>voir d'autres réponses à cette question</a>";
}

/////////////////
function suggerer_on(val) {
	var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.onreadystatechange = function() { tester_reponse_moteur(xhr); };
	ch = "params_moteur.asp?motcle=" + val;
    xhr.open("GET",ch , true);
    xhr.send(null);
}

/////////////////
function suggerer_on2(val) {
	var xhr=null;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.onreadystatechange = function() { tester_reponse_moteur(xhr); };
	ch = "params_moteur2.asp?motcle=" + val;
    xhr.open("GET",ch , true);
    xhr.send(null);
}

//////////////////////////////////////////
function tester_reponse_moteur(xhr) {
	if (xhr.readyState==4) alert_ajax_moteur(xhr);
} 

//////////////////////////
function alert_ajax_moteur(xhr)
{
	if (xhr.responseText !="") {

		obj = document.getElementById("moteur") ;
		obj.style.zIndex  = 20 ; 
		obj.style.visibility = "visible";
		obj = document.getElementById("txt_sug") ;	
		obj.innerHTML = xhr.responseText  ;
	}
	else {
		obj = document.getElementById("moteur") ;
		obj.style.visibility = "hidden";
		}
}

/////////////////
function suggerer_off() {
	obj = document.getElementById("moteur") ;
	obj.style.visibility = "hidden";
	}


function affecter_moteur(mot) {
	document.forms["form_moteur"].motcle.value= mot ;
	obj = document.getElementById("moteur") ;
	obj.style.visibility = "hidden";
}

function affecter_moteur2(mot) {
	document.forms["perso"].new_mot.value= mot ;
	obj = document.getElementById("moteur") ;
	obj.style.visibility = "hidden";
}

function strip_inv(t) {
	t2 = t.replace(/&#233;/g,"é") ;
	t2 = t2.replace(/&#244;/g,"ô") ;
	t2 = t2.replace(/&#232;/g,"è") ; 
	t2 = t2.replace(/&#234;/g,"ê") ; 
	t2 = t2.replace(/&#224;/g,"à") ; 
	t2 = t2.replace(/&#249;/g,"ù") ; 
	t2 = t2.replace(/&#251;/g,"û") ; 
	t2 = t2.replace(/&#231;/g,"ç") ; 
	t2 = t2.replace(/&#238;/g,"î") ; 
	t2 = t2.replace(/&#231;/g,"ç") ; 
	t2 = t2.replace(/&quot;/g,"'") ; 
	return (t2);
}



