
// accueil invisible sur home page


function apparaitre( targetId_1,targetId_2,targetId_3 )
	
{
if (document.getElementById)

	{
	target_1 = document.getElementById( targetId_1 );
	target_2 = document.getElementById( targetId_2 );
	target_3 = document.getElementById( targetId_3 );

	if (target_1.style.display == "none") /* si zone recherche non affiche */

		{target_1.style.display = "";target_2.style.display = "none";target_3.style.display = "none";} 
	else 
		{target_1.style.display = "none";}
	}
}



function hauteur()
{
vari1G = "tableGauche";
vari1D = "tableDroite";

vari2G = "hauteurTableG";
vari2D = "hauteurTableD";

ag = document.getElementById(vari1G).clientHeight;
ad = document.getElementById(vari1D).clientHeight;

if (ag > ad)
	{document.getElementById(vari2D).height = ag;}

if (ag < ad)
	{document.getElementById(vari2G).height = ad;}

}



// navigation boutons

imago0 = new Image();
imago6 = new Image();
imago7 = new Image();
imago8 = new Image();
imago9 = new Image();
imago10 = new Image();

imagf0 = new Image();
imagf6 = new Image();
imagf7 = new Image();
imagf8 = new Image();
imagf9 = new Image();
imagf10 = new Image();

imago0.src = 'imag/bandeau/bt_accueil_on.gif';
imago6.src = 'imag/bandeau/bt_actualite_on.gif';
imago7.src = 'imag/bandeau/bt_agenda_on.gif';
imago8.src = 'imag/bandeau/bt_rech-presta_on.gif';
imago9.src = 'imag/bandeau/bt_contact_on.gif';
imago10.src = 'imag/bandeau/bt_achatguide_on.gif';

imagf0.src = 'imag/bandeau/bt_accueil_off.gif';
imagf6.src = 'imag/bandeau/bt_actualite_off.gif';
imagf7.src = 'imag/bandeau/bt_agenda_off.gif';
imagf8.src = 'imag/bandeau/bt_rech-presta_off.gif';
imagf9.src = 'imag/bandeau/bt_contact_off.gif';
imagf10.src = 'imag/bandeau/bt_achatguide_off.gif';


function chg(n)
{
eval("document.getElementById('bouton_"+n+"').src = imago"+n+".src");
}

function ro(n)
{
eval("document.getElementById('bouton_"+n+"').src = imagf"+n+".src");
}


function modifstyle(n)
{

if (n == 1)
	{colo ="#E60003";debcadre1 = 0;debcadre2 = 155;}
if (n == 2)
	{colo = "#977A80";debcadre1 = 135;debcadre2 = 290;}
if (n == 3)
	{colo = "#F78408";debcadre1 = 285;debcadre2 = 440;}
if (n == 4)
	{colo = "#998216";debcadre1 = 231;debcadre2 = 386;}

var div1 = document.getElementById("menav1_"+n);
div1.style.background = colo;
div1.style.left= debcadre1 +'px';

var div2 = document.getElementById("menav2_"+n);
div2.style.background = colo;
div2.style.left= debcadre2 +'px';
	
}

var demu;

function voirPdf(x)
{
if (demu)
	{window.demu.close();}
demu = window.open('vpdf.asp?nsect='+ x +'','voirpdf','scrollbars=yes,resizable=yes,width=700,height=400,left=50,top=10,screenX=50,screenY=10,innerWidth=700,innerHeight=400');
}


function browsx()
{

brow = 0;

//tpnav = navigator.appName;
xagent = navigator.userAgent;

tpnav1 = xagent.search("MSIE");
if (tpnav1 > 0)
	{brow = 1; return brow;}

tpnav2 = xagent.search("Firefox");
if (tpnav2 > 0)
	{brow = 2; return brow;}

tpnav3 = xagent.search("Safari");
if (tpnav3 > 0)
	{brow = 3; return brow;}

//alert("tpnav3 = "+ tpnav3);
	
}


var essaifiche = 0 // voir plus bas testAnnonceur


function gererfiche()
{

if (essaifiche < 4)
	{

	typnavig = browsx(); // test navigateur

	//alert("typnavig = "+ typnavig);

	if (typnavig == 1)
		{document.getElementById("lignedebut").style.filter = "alpha(opacity=40)";}

	if ((typnavig == 2) || (typnavig == 3))
		{document.getElementById("lignedebut").style.opacity = "0.4";}

	document.getElementById("zoneFiche").style.display = "block";

	}
else
	{alert("plus d'essai possible de connexion à la fiche");}
}


function fermerfiche()
{

typnavig = browsx(); // test navigateur

if (typnavig == 1)
	{document.getElementById("lignedebut").style.filter = "alpha(opacity=100)";}

if ((typnavig == 2) || (typnavig == 3))
	{document.getElementById("lignedebut").style.opacity = "1";}

document.getElementById("zoneFiche").style.display = "none";

}


function recherchePresta()
{

typnavig = browsx(); // test navigateur

//alert("typnavig = "+ typnavig);

if (typnavig == 1)
	{document.getElementById("lignedebut").style.filter = "alpha(opacity=40)";}

if ((typnavig == 2) || (typnavig == 3))
	{document.getElementById("lignedebut").style.opacity = "0.4";}

document.getElementById("zoneRecherche").style.display = "block";
document.getElementById("resultRech").style.display = "none";

divBT = document.getElementById('btRechPresta');
divBT.innerHTML = "<img id='bouton_8' src='imag/bandeau/bt_rech-presta_on.gif' width='250' height='38'>";

}

function fermerRech()
{

typnavig = browsx(); // test navigateur

if (typnavig == 1)
	{document.getElementById("lignedebut").style.filter = "alpha(opacity=100)";}

if ((typnavig == 2) || (typnavig == 3))
	{document.getElementById("lignedebut").style.opacity = "1";}

document.getElementById("zoneRecherche").style.display = "none";
document.getElementById("formRech").style.display = "block";
document.getElementById("resultRech").style.display = "none";

document.getElementById("barrevertic1").height = 220;
document.getElementById("barrevertic2").height = 220;


divBT = document.getElementById('btRechPresta');
divBT.innerHTML = "<a href='javascript:recherchePresta();' onMouseOver = 'chg(8);' onMouseOut = 'ro(8);'><img id='bouton_8' src='imag/bandeau/bt_rech-presta_off.gif' width='250' height='38'></a>";
}


/*******************************************************/
/* test ajax sur objet xmlhttprequest selon navigateur */
/*******************************************************/

function oXmlhttp()
{

var xhr_object1 = null;   
   
if(window.XMLHttpRequest) // Firefox
	{   
    	xhr_object1 = new XMLHttpRequest(); 
    	return xhr_object1;
	}
  
else if(window.ActiveXObject) // Internet Explorer   
    	{
	xhr_object1 = new ActiveXObject("Microsoft.XMLHTTP");
        return xhr_object1;
	}
   
else 
	{ // XMLHttpRequest non supporté par le navigateur   
    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");   
    	return;   
 	}
}


/*******************************************************/
/*             gerer votre fiche                       */
/*******************************************************/

function testAnnonceur(n)
{

essaifiche = essaifiche + 1;

if (essaifiche < 4)
	{

	zloga = document.getElementById("loga").value;
	zpassa = document.getElementById("passa").value;

	if (zloga == "")
		{alert("Veuillez saisir votre Login; merci");return;}
	if (zpassa == "")
		{alert("Veuillez saisir votre Mot de Passe; merci");return;}

	else

		{

		xhr_object = oXmlhttp(); // test ajax/navigateur 
   
		xhr_object.open("GET", "testAnnonceur.asp?num1="+zloga+"&num2="+zpassa+"&num3="+n, false);   
		xhr_object.send("");   
		//if(xhr_object.readyState == 4) alert("Requête effectuée !");

		retourTexte = xhr_object.responseText;

		if (retourTexte == 0)
			{

			if (essaifiche == 1)
				{textessai = "veuillez recommencer : votre 2è essai";}
			if (essaifiche == 2)
				{textessai = "veuillez recommencer : votre 3è et <b>dernier essai</b>";}
			if (essaifiche == 3)
				{textessai = "plus d'essai possible";fermerfiche();}

			divA = document.getElementById('nbessai');
			divA.innerHTML = textessai;

			alert("Vos éléments sont erronés, "+ textessai +"; merci");
			document.getElementById("loga").value = "";
			document.getElementById("passa").value = "";

			if (essaifiche == 3)
				{essaifiche = 4;fermerfiche();}

			}

		else
			{
			essaifiche = 0
			document.fiche.t1.value = zloga;
			document.fiche.t2.value = zpassa;
			document.fiche.submit();
			}

		}
	}

else
	{fermerfiche();}

}


/*******************************************************/
/*             recherche un prestataire                */
/*******************************************************/

function lookPresta()
{
a1 = document.checknom.presta.value;
a2 = a1.length;


if (a1 == "")
	{alert("Veuillez saisir le nom ou le début du nom d'un prestataire; merci");return;}
if (a2 < 3)
	{alert("Veuillez saisir au minimum 3 caractères pour le nom ou le début du nom d'un prestataire; merci");return;}

else
	{

	newa1 = a1.replace("'","&#39;")

//alert("newa1 = "+ newa1);

	xhr_object = oXmlhttp(); // test ajax/navigateur 
   
	xhr_object.open("GET", "testPrestataire.asp?nomx="+newa1, false);   
	xhr_object.send("");   
//if(xhr_object.readyState == 4) alert("Requête effectuée !");

	retourTexte = xhr_object.responseText;


	if (retourTexte == 0) 
		{
		alert("il n'y a pas de prestataire du nom de '"+ newa1 +"' ou commençant par '"+ newa1 +"', veuillez recommencer; merci");
		document.checknom.presta.value = "";
		}

	else
		{
		//alert(retourTexte);

		document.getElementById("formRech").style.display = "none";
		document.getElementById("resultRech").style.display = "block";


		var affichage = "";
		var haut = 0;

		affichage = "&nbsp;<br>"

		vari = retourTexte.split("|");
		// vari[0] = qte prestataire


		var nsoci = new Array(vari[0]);
		var xsoci = new Array(vari[0]);
		var xsocijava = new Array(vari[0]);
		var nsect = new Array(vari[0]);
		var xsect = new Array(vari[0]);
		var nmeti = new Array(vari[0]);
		var verspage = new Array(vari[0]); 
		var numeroP = new Array(vari[0]);
		var numeroM = new Array(vari[0]); 
		var fich = new Array(vari[0]); 

		
		i = 1;

		for (j=0; j < vari[0]; j++)
			{ 
			nsoci[j] = vari[i]; // numero prestataire
			xsoci[j] = vari[i + 1]; // nom prestataire
			nsect[j] = vari[i + 2]; // numero secteur
			xsect[j] = vari[i + 3]; // nom secteur
			nmeti[j] = vari[i + 4]; // numero metier
			typdoc = vari[i + 5]; // 1 = fiche 2 = lienweb 3 =adrestel

			xsoci[j] = xsoci[j].replace("&amp;","&");
			xsoci[j] = xsoci[j].replace("&amp;#39;","'");
			xsoci[j] = xsoci[j].replace("&amp;#201;","É");
			xsoci[j] = xsoci[j].replace("&amp;#174;","®");

			xsocijava[j] = xsoci[j].replace(/ /g,'-');
			xsocijava[j] = xsocijava[j] +".asp";


//alert("xsoci[j] = "+ xsoci[j]);
//alert("xsocijava[j] = "+ xsocijava[j]);


			if (typdoc > 0)
				//{verspage[j] = "fiche-Prestataire.asp";numeroP[j] = "nprest";numeroM[j] = "nmetier";fich[j] = " (avec fiche)";}
				//{verspage[j] = "<a href='javascript:rechercheFicheDetail(&#39;"+ xsocijava[j] +"&#39;,"+ nsoci[j] +","+ nmeti[j] +")'>";


				{verspage[j] = "<a href='prestataire/"+ xsocijava[j] +"?m="+ nmeti[j] +"&p="+ nsoci[j] +"'>";
				//alert("adresse = "+ verspage[j]);
				}

			else
				{verspage[j] = "prestataire.asp";numeroP[j] = "numsoc";numeroM[j] = "nummet";fich[j] = "";}

//alert(nsoci[j] +"-"+ xsoci[j] +"-"+ nsect[j] +"-"+ xsect[j]);

			i = i + 6;


			if (typdoc > 0)

				{affichage = affichage + verspage[j] + xsoci[j] +"</a> "+ xsect[j] + " (avec fiche)" +"<br>";
				//alert("affichage = "+ affichage);
				}


			else

				{affichage = affichage +"<a href='"+ verspage[j] +"?nsecteur="+ nsect[j] +"&rech=1&"+ numeroP[j] +"="+ nsoci[j] +"&"+ numeroM[j] +"="+ nmeti[j] +"'>"+ xsoci[j] +"</a> "+ xsect[j] + fich[j] +"<br>";}

			haut = haut + 12;

			}
	
		haut = haut + 220;

		document.getElementById("barrevertic1").height = haut;
		document.getElementById("barrevertic2").height = haut;

		divBZ = document.getElementById("prestaResult");
		divBZ.innerHTML = affichage;

		}
	}

}


/***  contact ***/

function verifmail()
{

a1 = document.envo.nom.value;
a2 = document.envo.prenom.value;
a3 = document.envo.emal.value;
a4 = document.envo.messa.value;

if (a1=="")
	{alert("Veuillez indiquer votre nom; merci");return;}
if (a2=="")
	{alert("Veuillez indiquer votre prénom; merci");return;}
if (a3=="")
	{alert("Veuillez indiquer votre adresse mail; merci");return;}
if (a4=="")
	{alert("Veuillez indiquer votre message; merci");return;}

mvaleur = new String (a3)
mArobas = mvaleur.indexOf("@")
mPoint = mvaleur.indexOf(".")

if ((a3 != "") && ((mArobas == -1) || (mPoint == -1)))
	{alert("Votre adresse e-mail est incorrecte");return;}

else
	{document.envo.submit();}
}


/*********************************************/
/***                google                 ***/
/*********************************************/

/***  encodage Chaine ***/


function UTF8_tool(string)
{

var string = string.replace(/\r\n/g,"\n");;
var utftext = "";

for (var n = 0; n < string.length; n++) 
	{
	var c = string.charCodeAt(n);

	if (c < 128) utftext += String.fromCharCode(c);

	else if((c > 127) && (c < 2048)) 
		{
		utftext += String.fromCharCode((c >> 6) | 192);
		utftext += String.fromCharCode((c & 63) | 128);
		}
	else {
		utftext += String.fromCharCode((c >> 12) | 224);
		utftext += String.fromCharCode(((c >> 6) & 63) | 128);
		utftext += String.fromCharCode((c & 63) | 128);
		}
	}
return utftext;

}


function rechercheG()
{

a1 = document.getElementById("qGoggle").value;

//alert("a1 = "+ a1);

ChaineCodee = UTF8_tool(a1);

//alert("ChaineCodee = "+ ChaineCodee);

document.Rgoogle.q.value = ChaineCodee;
document.Rgoogle.submit();
}


function motcle()
{
document.getElementById("qGoggle").value = "";
}




/*********************************************/
/***         devenez annonceur             ***/
/*********************************************/

var demoge;

function voirextrait(n,m)
{
if (n == 1) // lien web
	{fichier = "extraitLien.asp?numo="+m;}
if (n == 2) // 1/2 page
	{fichier = "extraitDemipage.asp?numo="+m;}
if (n == 3) // 1 page
	{fichier = "extraitUnepage.asp?numo="+m;}
if (n == 4) // pub horizon
	{fichier = "extraitpubHorizon.asp?numo="+m;}
if (n == 5) // pub carre
	{fichier = "extraitpubCarre.asp?numo="+m;}
if (n == 6) // pub video
	{fichier = "extraitpubVideo.asp?numo="+m;}

if (demoge)
	{window.demoge.close();}
demoge = window.open(fichier,'voirextrait','scrollbars=yes,resizable=yes,width=750,height=550,left=50,top=10,screenX=50,screenY=10,innerWidth=750,innerHeight=550');

	
}



