var xhr = null;
function getXhr(){
if(window.XMLHttpRequest) // Firefox et autres
xhr = new XMLHttpRequest(); 
else if(window.ActiveXObject){ // Internet Explorer 
   try {
    xhr = new ActiveXObject("Msxml2.XMLHTTP"); 
   } catch (e) {
     xhr = new ActiveXObject("Microsoft.XMLHTTP"); 
  }
}
else { // XMLHttpRequest non supporté par le navigateur 
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
}

function removeLeadingAndTrailingChar (inputString, removeChar) 
{
	var returnString = inputString;
	if (removeChar.length)
	{
	  while(''+returnString.charAt(0)==removeChar)
		{
		  returnString=returnString.substring(1,returnString.length);
		}
		while(''+returnString.charAt(returnString.length-1)==removeChar)
	  {
	    returnString=returnString.substring(0,returnString.length-1);
	  }
	}
	return returnString;
}
		
		function Fade_la_une(action,total,chaine) {
			  var tab=chaine.split("/");
			  if(action=="S"){
				  current_div++;
				  if(current_div>total)current_div=0;
				  
			  }else if(action=="P"){
				  current_div--;
				  if(current_div==-1)current_div=total;
				  
			  }
			  
			  
		      $("#div_la_une").slideUp("slow",function(){
                 document.getElementById("div_la_une").innerHTML=document.getElementById("div_article_"+tab[current_div]).innerHTML;
                });
			  $("#div_la_une").slideDown("slow");
			  
			  //var lien_detail_article="interne.php?page=article.php&idarticle="+tab[current_div];
			  //document.getElementById("lien_lire_la_suite").innerHTML="<a href=\""+lien_detail_article+"\" class=\"lien_la_une_over\" >Lire la suite </a>";
			  
		}
		

function Contacter(idcompetence){
  
  var nom=removeLeadingAndTrailingChar (document.getElementById("nom").value, " ");
  var commentaire=removeLeadingAndTrailingChar (document.getElementById("commentaire").value, " ");
  var ville=removeLeadingAndTrailingChar (document.getElementById("ville").value, " ");
  var telephone=removeLeadingAndTrailingChar (document.getElementById("telephone").value, " ");
  var email=removeLeadingAndTrailingChar (document.getElementById("email").value, " ");
  var objet=removeLeadingAndTrailingChar (document.getElementById("objet").value, " "); 
  if(nom=="" || commentaire=="" || ville=="" || objet=="" || email=="")alert("Tous les champs en (*) sont obligatoires");
  else{
   
     getXhr();
     // On défini ce qu'on va faire quand on aura la réponse 
	  xhr.onreadystatechange = function(){
			 // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
				if(xhr.readyState == 4 && xhr.status == 200){ 
				   var leselect = xhr.responseText; 
				   //alert(leselect);
				   var reponse = eval('(' + leselect + ')');
				   
				   if(reponse.erreur=="oui"){
					document.getElementById("resultat").innerHTML = reponse.message;
				   }else{
					document.getElementById('resultat').innerHTML = reponse.message;
					document.getElementById("div_formulaire").style.display="none";
				   }			   
				} 
	}
	  
     // Ici on va voir comment faire du post 
     xhr.open("POST","envoyer_contact.php",true); // ne pas oublier ça pour le post 
     xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     // ne pas oublier de poster les arguments // 
     xhr.send("nom="+nom+"&commentaire="+commentaire+"&ville="+ville+"&objet="+objet+"&email="+email+"&telephone="+telephone+"&idcompetence="+idcompetence);
  	 //alert("titre="+titre+"&commentaire="+commentaire+"&idarticle="+idarticle+"&email="+email+"&pseudo="+pseudo);
      document.getElementById('resultat').innerHTML="<span style='color:red'><b>Traitement encours ... veuillez patienter !</b></span>";

  }
}



		function Afficher_Lien_la_une(){
		
		      document.getElementById("madiv").style.display='inline';
			  document.getElementById("madiv2").style.display='inline';
			  if (navigator.appName=="Microsoft Internet Explorer"){document.getElementById("madiv").style.top="457px";document.getElementById("madiv2").style.top="457px";}
		      else {document.getElementById("madiv").style.top="450px";document.getElementById("madiv2").style.top="450px";}
		}
		
		function Cacher_Lien_la_une(){
		
			  document.getElementById("madiv").style.display='none';
			  document.getElementById("madiv2").style.display='none';

		
		}
		
		function Reduire_developper(action,iddiv,liste){
		      var tab=liste.split("/");
              if(action=="R"){
				  $("#"+iddiv).slideUp("normal");
				  document.getElementById("libelle_"+iddiv).innerHTML="Afficher contenu";
				  document.getElementById("lien_"+iddiv).href="javascript:Reduire_developper('D','"+iddiv+"','"+liste+"')";
			  }
			  if(action=="D"){
				    for(i=0; i<tab.length; i++){
				   
				       
					   document.getElementById("libelle_div_menu_"+tab[i]).innerHTML="Afficher contenu";
					   $("#div_menu_"+tab[i]).slideUp("normal");
					   document.getElementById("lien_div_menu_"+tab[i]).href="javascript:Reduire_developper('D','div_menu_"+tab[i]+"','"+liste+"')";
					   
				       
			        }

				    $("#"+iddiv).slideDown("normal");
					document.getElementById("libelle_"+iddiv).innerHTML="Cacher contenu";
					document.getElementById("lien_"+iddiv).href="javascript:Reduire_developper('R','"+iddiv+"','"+liste+"')";
					
					
			  }

		
		}
			
function Rechercher_flash(){
	
   getXhr();
  
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
	
	
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
       //document.getElementById('liste').innerHTML = leselect;
	   $("#Div_info").slideUp("slow",function(){
         document.getElementById("Div_info").innerHTML=leselect;
       });
	   $("#Div_info").slideDown("slow");

    } 
  }
  
  // Ici on va voir comment faire du post 
  xhr.open("POST","fiche_article_flash.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  xhr.send("test=yes");
  document.getElementById('Div_info').innerHTML="<p>&nbsp;</p><b>Chargement en cours,  veuillez patienter ... </b>"
 
}

		
		function Fade_Blague_accueil(action,total,chaine) {
			  var tab=chaine.split("/");
			  if(action=="S"){
				  current_div_blague++;
				  if(current_div_blague>total)current_div_blague=0;
				  
			  }else if(action=="P"){
				  current_div_blague--;
				  if(current_div_blague==-1)current_div_blague=total;
				  
			  }
			  
			  
		      $("#div_la_une_blague").animate("slow", 0.1,function(){
                 document.getElementById("div_la_une_blague").innerHTML=document.getElementById("div_blague_"+tab[current_div_blague]).innerHTML;
                });
			  $("#div_la_une_blague").fadeTo("slow", 1);
			  
			  
		}

 function Fermer(){
	  
      document.getElementById("div_recherche").style.display='none';
	  document.getElementById('article').style.display='none';
	  //document.getElementById('div_recherche').style.display='none';
 
	 
 }
 
 function afficher(maDiv, idarticle){
  var x_left=(document.body.clientWidth-950)/2; 
  document.getElementById(maDiv).style.left=x_left+"px";
  document.getElementById(maDiv).style.width="950px";
  document.getElementById(maDiv).style.top="100px";
  
  document.getElementById("div_recherche").style.width=document.body.clientWidth+"px";
  document.getElementById("div_recherche").style.height=document.getElementById("page").offsetHeight+"px";
  
  document.getElementById("div_recherche").style.display='inline';
  document.getElementById(maDiv).style.display='inline';
  document.getElementById("div_menu").style.display='none';
  document.getElementById("div_rechercher").style.display='none';
  new Effect.ScrollTo('page',{delay:0.5,duration:1});
  document.getElementById(maDiv).innerHTML="<img src='images/attente.gif' vspace='300' hspace='400' style='position:absolute'><span style='color:red'>Chargement encours ...</span>";
   getXhr();
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
	  document.getElementById('article').innerHTML = leselect;
	  new Effect.Grow ('div_commentaire', { direction: 'right',duration: 1.5,delay:0.0 });

    } 
  }
  // Ici on va voir comment faire du post 
  xhr.open("POST","commentaire.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  
  xhr.send("idarticle="+idarticle);
}



function afficher_ami(maDiv, idarticle){
  
  var x_left=(document.body.clientWidth-950)/2; 
  document.getElementById(maDiv).style.left=x_left+"px";
  document.getElementById(maDiv).style.width="950px";
  document.getElementById(maDiv).style.top="100px";
  
  document.getElementById("div_recherche").style.width=document.body.clientWidth+"px";
  document.getElementById("div_recherche").style.height=document.getElementById("page").offsetHeight+"px";
  
  document.getElementById("div_recherche").style.display='inline';
  document.getElementById(maDiv).style.display='inline';
  document.getElementById("div_menu").style.display='none';
  document.getElementById("div_rechercher").style.display='none';
  new Effect.ScrollTo('page',{delay:0.5,duration:1});
  document.getElementById(maDiv).innerHTML="<img src='images/attente.gif' vspace='300' hspace='400' style='position:absolute'><span style='color:red'>Chargement encours ...</span>";
   getXhr();
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
	  document.getElementById('article').innerHTML = leselect;
      new Effect.Grow ('div_ami', { direction: 'right',duration: 1.5,delay:0.0 });
	   
    } 
  }
  // Ici on va voir comment faire du post 
  xhr.open("POST","ami.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  
  xhr.send("idarticle="+idarticle);
}


function Commenter(idarticle){
  var titre=removeLeadingAndTrailingChar (document.getElementById("titre").value, " ");
  var commentaire=removeLeadingAndTrailingChar (document.getElementById("commentaire").value, " ");
  var email=removeLeadingAndTrailingChar (document.getElementById("email").value, " ");
  var pseudo=removeLeadingAndTrailingChar (document.getElementById("pseudo").value, " ");
  
  if(titre=="" || commentaire=="" || email=="" || pseudo=="")alert("Tous les champs sont obligatoires");
  else{
  
     getXhr();
     // On défini ce qu'on va faire quand on aura la réponse 
     xhr.onreadystatechange = function(){
     // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
        if(xhr.readyState == 4 && xhr.status == 200){ 
           var leselect = xhr.responseText; 
	        //alert(leselect);
	        document.getElementById('resultat').innerHTML = leselect;
			document.getElementById("formulaire_commentaire").reset();
	   
        } 
      }
     // Ici on va voir comment faire du post 
     xhr.open("POST","insetion_commentaire.php",true); // ne pas oublier ça pour le post 
     xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     // ne pas oublier de poster les arguments // 
     xhr.send("titre="+titre+"&commentaire="+commentaire+"&idarticle="+idarticle+"&email="+email+"&pseudo="+pseudo);
     document.getElementById('resultat').innerHTML="<span style='color:red'><b>Chargement encours ... veuillez patienter !</b></span>";

  }
}


function Envoyer(idarticle){

  var nom=removeLeadingAndTrailingChar (document.getElementById("nom").value, " ");
  var commentaire=removeLeadingAndTrailingChar (document.getElementById("commentaire").value, " ");
  var emetteur=removeLeadingAndTrailingChar (document.getElementById("emetteur").value, " ");
  var destinataire=removeLeadingAndTrailingChar (document.getElementById("destinataire").value, " ");
  
  if(nom=="" || emetteur=="" || destinataire=="")alert("Tous les champs en (*) sont obligatoires");
  else{
  
     getXhr();
     // On défini ce qu'on va faire quand on aura la réponse 
     xhr.onreadystatechange = function(){
     // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
        if(xhr.readyState == 4 && xhr.status == 200){ 
           var leselect = xhr.responseText; 
	        //alert(leselect);
	        document.getElementById('resultat').innerHTML = leselect;
			document.getElementById("formulaire_commentaire").reset();
	   
        } 
      }
     // Ici on va voir comment faire du post 
     xhr.open("POST","envoyer_ami.php",true); // ne pas oublier ça pour le post 
     xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     // ne pas oublier de poster les arguments // 
     xhr.send("nom="+nom+"&commentaire="+commentaire+"&idarticle="+idarticle+"&emetteur="+emetteur+"&destinataire="+destinataire);
  	 //alert("titre="+titre+"&commentaire="+commentaire+"&idarticle="+idarticle+"&email="+email+"&pseudo="+pseudo);
      document.getElementById('resultat').innerHTML="<span style='color:red'><b>Chargement encours ... veuillez patienter !</b></span>";

  }
}

function Rechercher(){

   var mot=removeLeadingAndTrailingChar (document.getElementById("mot").value, " ");
   var menu=removeLeadingAndTrailingChar (document.getElementById("menu").value, " ");
   var url="interne.php?page=recherche.php&mot="+mot+"&idmenu="+menu;
   if(mot=="")alert("Vous devez saisir un mot clé");
   else  self.location=url;
   
   
}

function Change_boutton(bouton){
	
   if(bouton=="activite"){
	    document.getElementById('recherche_r1_c3').src='images/recherche_r1_c3.png';  
/*		document.getElementById("div_recherche_nom").style.display="none";
		document.getElementById("div_recherche_ville").style.display="none";
		document.getElementById("div_recherche_activite").style.display="inline";
*/
        document.getElementById("recherche").innerHTML=document.getElementById("div_recherche_activite").innerHTML;
   }
   if(bouton=="nom"){
   document.getElementById('recherche_r1_c3').src='images/survol_nom.png';	
/*			document.getElementById("div_recherche_nom").style.display="inline";
		document.getElementById("div_recherche_ville").style.display="none";
		document.getElementById("notre_selection2").style.display="none";
*/		document.getElementById("recherche").innerHTML=document.getElementById("div_recherche_nom").innerHTML;
   }
   if(bouton=="ville"){
	   document.getElementById('recherche_r1_c3').src='images/survol_ville.png';	
/*		document.getElementById("div_recherche_nom").style.display="none";
		document.getElementById("div_recherche_ville").style.display="inline";
		document.getElementById("notre_selection2").style.display="none";
*/		document.getElementById("recherche").innerHTML=document.getElementById("div_recherche_ville").innerHTML;
   }
}




function getScrollPosition()
{
    return Array((document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft,(document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop);
}

function afficher_contact(idcompetence,etat){
  maDiv="article";
  var x_left=(document.body.clientWidth-1000)/2; 
  document.getElementById(maDiv).style.left=x_left+"px";
  document.getElementById(maDiv).style.width="1000px";
  document.getElementById(maDiv).style.top="50px";
  
  document.getElementById("div_recherche").style.width=document.body.clientWidth+"px";
  document.getElementById("div_recherche").style.height=document.getElementById("page").offsetHeight+"px";
  
  document.getElementById("div_recherche").style.display='inline';
  document.getElementById(maDiv).style.display='inline';
  
  
  document.getElementById(maDiv).innerHTML="<table width='100%'  border='0'>  <tr>    <td height='70' align='center' valign='middle' class='titre_la_une' style='color:white'>Chargement en cours ... Veuillez patienter <br>    <img src='images/loadinfo.net.gif' width='24' height='24'></td>  </tr></table>";
  //new Effect.ScrollTo('page',{delay:0.5,duration:1});
  window.scrollTo(0,0);
   getXhr();
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
	  document.getElementById('article').innerHTML = leselect;
	   
    } 
  }
  // Ici on va voir comment faire du post 
  xhr.open("POST","contacter_competence.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  
  xhr.send("idcompetence="+idcompetence+"&etat="+etat);
}
function Select_tv(){
   
   var categorie=document.getElementById("categorie").value;
   var url="webtv.php?idcategorie_tv="+categorie;
   if(categorie!="0")self.location=url;
   
   
}

function afficher_detail_competence(idcompetence,etat){
  maDiv="article";
  var x_left=(document.body.clientWidth-1000)/2; 
  document.getElementById(maDiv).style.left=x_left+"px";
  document.getElementById(maDiv).style.width="1000px";
  document.getElementById(maDiv).style.top="50px";
  
  document.getElementById("div_recherche").style.width=document.body.clientWidth+"px";
  document.getElementById("div_recherche").style.height=document.getElementById("page").offsetHeight+"px";
  
  document.getElementById("div_recherche").style.display='inline';
  document.getElementById(maDiv).style.display='inline';
  
  document.getElementById(maDiv).innerHTML="<table width='100%'  border='0'>  <tr>    <td height='70' align='center' valign='middle' class='titre_la_une' style='color:white'>Chargement en cours ... Veuillez patienter <br>    <img src='images/loadinfo.net.gif' width='24' height='24'></td>  </tr></table>";
  //new Effect.ScrollTo('page',{delay:0.5,duration:1});
  window.scrollTo(0,0);
   getXhr();
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
	  document.getElementById('article').innerHTML = leselect;
	   
    } 
  }
  // Ici on va voir comment faire du post 
  xhr.open("POST","detail_competence.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  
  xhr.send("idcompetence="+idcompetence+"&etat="+etat);
}


function afficher_detail_photo(idcompetence,etat){
  maDiv="article";
  var x_left=(document.body.clientWidth-1000)/2; 
  document.getElementById(maDiv).style.left=x_left+"px";
  document.getElementById(maDiv).style.width="1000px";
  document.getElementById(maDiv).style.top="50px";
  
  document.getElementById("div_recherche").style.width=document.body.clientWidth+"px";
  document.getElementById("div_recherche").style.height=document.getElementById("page").offsetHeight+"px";
  
  document.getElementById("div_recherche").style.display='inline';
  document.getElementById(maDiv).style.display='inline';
  
  document.getElementById(maDiv).innerHTML="<table width='100%'  border='0'>  <tr>    <td height='70' align='center' valign='middle' class='titre_la_une' style='color:white'>Chargement en cours ... Veuillez patienter <br>    <img src='images/loadinfo.net.gif' width='24' height='24'></td>  </tr></table>";
  //new Effect.ScrollTo('page',{delay:0.5,duration:1});
  window.scrollTo(0,0);
   getXhr();
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
	  
	  document.getElementById('article').innerHTML = leselect;
	   $(function() {
		  $(".laune").jCarouselLite({
			  auto: 2000,
			  speed: 500,
			  visible:1,
		  });
	  });

    } 
  }
  // Ici on va voir comment faire du post 
  xhr.open("POST","detail_photo.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  
  xhr.send("idcompetence="+idcompetence+"&etat="+etat);
}

function Select_scategorie(){
   getXhr();

  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
	
	
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
      document.getElementById('div_scategorie').innerHTML = leselect;
    } 
  }
  
  // Ici on va voir comment faire du post 
  xhr.open("POST","fiche-filtre-liste-scategorie.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  //alert("kkkhk");
  var idcategorie = document.getElementById('categorie').value; 

 
  xhr.send("idcategorie="+idcategorie);
  document.getElementById('div_scategorie').innerHTML="<b>Chargement en cours,  veuillez patienter ... </b>"

 
}


function Recherche_activite(){
  var idcategorie = document.getElementById('categorie').value; 
  var idscategorie = document.getElementById('scategorie').value; 
  self.location="recherche.php?idcategorie="+idcategorie+"&zone=recherche_r1_c3.png&idscategorie="+idscategorie;
 
}

function Recherche_nom(){
  var nom =removeLeadingAndTrailingChar (document.getElementById("nom_cherche").value, " ");
  if(nom=="")alert("Vous devez saisir tout ou une partie du nom/prénom recherché");
  else self.location="recherche.php?nom="+nom+"&zone=survol_nom.png";
 
}

function Recherche_ville(){
  var quartier = document.getElementById('quartier').value; 
  var idville = document.getElementById('ville').value; 
  if(quartier=="" && idville=="0")alert("Vous devez selectionner une ville ou saisi un quartier");
  else self.location="recherche.php?quartier="+quartier+"&zone=survol_ville.png&idville="+idville;
 
}


function Change_boutton2(bouton){
	
   if(bouton=="activite"){
	    document.getElementById('recherche_r1_c3').src='images/recherche_r1_c3.png';  
/*		document.getElementById("div_recherche_nom").style.display="none";
		document.getElementById("div_recherche_ville").style.display="none";
		document.getElementById("div_recherche_activite").style.display="inline";
*/
        document.getElementById("recherche2").innerHTML=document.getElementById("div_recherche_activite").innerHTML;
   }
   if(bouton=="nom"){
   document.getElementById('recherche_r1_c3').src='images/survol_nom.png';	
/*			document.getElementById("div_recherche_nom").style.display="inline";
		document.getElementById("div_recherche_ville").style.display="none";
		document.getElementById("notre_selection2").style.display="none";
*/		document.getElementById("recherche2").innerHTML=document.getElementById("div_recherche_nom").innerHTML;
   }
   if(bouton=="ville"){
	   document.getElementById('recherche_r1_c3').src='images/survol_ville.png';	
/*		document.getElementById("div_recherche_nom").style.display="none";
		document.getElementById("div_recherche_ville").style.display="inline";
		document.getElementById("notre_selection2").style.display="none";
*/		document.getElementById("recherche2").innerHTML=document.getElementById("div_recherche_ville").innerHTML;
   }
}

function afficher_contact2(){
  maDiv="article";
  var x_left=(document.body.clientWidth-1000)/2; 
  document.getElementById(maDiv).style.left=x_left+"px";
  document.getElementById(maDiv).style.width="1000px";
  document.getElementById(maDiv).style.top="50px";
  
  document.getElementById("div_recherche").style.width=document.body.clientWidth+"px";
  document.getElementById("div_recherche").style.height=document.getElementById("page").offsetHeight+"px";
  
  document.getElementById("div_recherche").style.display='inline';
  document.getElementById(maDiv).style.display='inline';
  //document.getElementById("mon_menu").style.display='none';
  
  document.getElementById(maDiv).innerHTML="<table width='100%'  border='0'>  <tr>    <td height='70' align='center' valign='middle' class='titre_la_une' style='color:white'>Chargement en cours ... Veuillez patienter <br>    <img src='images/loadinfo.net.gif' width='24' height='24'></td>  </tr></table>";
  //new Effect.ScrollTo('page',{delay:0.5,duration:1});
  window.scrollTo(0,0);
   getXhr();
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
	  document.getElementById('article').innerHTML = leselect;
	   
    } 
  }
  // Ici on va voir comment faire du post 
  xhr.open("POST","page_contact.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  
  xhr.send("");
}


function Nous_Contacter(){
  
  var nom=removeLeadingAndTrailingChar (document.getElementById("nom").value, " ");
  var commentaire=removeLeadingAndTrailingChar (document.getElementById("commentaire").value, " ");
  var ville=removeLeadingAndTrailingChar (document.getElementById("ville").value, " ");
  var telephone=removeLeadingAndTrailingChar (document.getElementById("telephone").value, " ");
  var email=removeLeadingAndTrailingChar (document.getElementById("email").value, " ");
  var objet=removeLeadingAndTrailingChar (document.getElementById("objet").value, " "); 
  if(nom=="" || commentaire=="" || ville=="" || objet=="" || email=="")alert("Tous les champs en (*) sont obligatoires");
  else{
   
     getXhr();
     // On défini ce qu'on va faire quand on aura la réponse 
     xhr.onreadystatechange = function(){
     // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
        if(xhr.readyState == 4 && xhr.status == 200){ 
           var leselect = xhr.responseText; 
	        
	        document.getElementById('resultat').innerHTML = leselect;
			document.getElementById("formulaire_contact").reset();
			//alert(leselect);
	   
        } 
      }
	  
     // Ici on va voir comment faire du post 
     xhr.open("POST","envoyer_contact2.php",true); // ne pas oublier ça pour le post 
     xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     // ne pas oublier de poster les arguments // 
     xhr.send("nom="+nom+"&commentaire="+commentaire+"&ville="+ville+"&objet="+objet+"&email="+email+"&telephone="+telephone);
  	 //alert("titre="+titre+"&commentaire="+commentaire+"&idarticle="+idarticle+"&email="+email+"&pseudo="+pseudo);
      document.getElementById('resultat').innerHTML="<span style='color:red'><b>Traitement encours ... veuillez patienter !</b></span>";

  }
}


function afficher_appreciation(idcompetence,etat){
  maDiv="article";
  var x_left=(document.body.clientWidth-1000)/2; 
  document.getElementById(maDiv).style.left=x_left+"px";
  document.getElementById(maDiv).style.width="1000px";
  document.getElementById(maDiv).style.top="50px";
  
  document.getElementById("div_recherche").style.width=document.body.clientWidth+"px";
  document.getElementById("div_recherche").style.height=document.getElementById("page").offsetHeight+"px";
  
  document.getElementById("div_recherche").style.display='inline';
  document.getElementById(maDiv).style.display='inline';
  
  document.getElementById(maDiv).innerHTML="<table width='100%'  border='0'>  <tr>    <td height='70' align='center' valign='middle' class='titre_la_une' style='color:white'>Chargement en cours ... Veuillez patienter <br>    <img src='images/loadinfo.net.gif' width='24' height='24'></td>  </tr></table>";
  //new Effect.ScrollTo('page',{delay:0.5,duration:1});
  window.scrollTo(0,0);
   getXhr();
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
	  document.getElementById('article').innerHTML = leselect;
	  //document.getElementById('login').innerHTML =  document.getElementById('connect').innerHTML
    } 
  }
  // Ici on va voir comment faire du post 
  xhr.open("POST","apprecier_competence.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  
  xhr.send("idcompetence="+idcompetence+"&etat="+etat);
}




function callPublish(msg, attachment, action_link) {
  FB.ensureInit(function () {
    FB.Connect.streamPublish('', attachment, action_link);
  });
}

function Laisser_commentaire(idcompetence,competence){
  
  var nom=addslashes(removeLeadingAndTrailingChar (document.getElementById("nom_comp").value, " "));
  var commentaire=addslashes(removeLeadingAndTrailingChar (document.getElementById("commentaire_comp").value, " "));
  var ville=addslashes(removeLeadingAndTrailingChar (document.getElementById("ville_comp").value, " "));
  var telephone=addslashes(removeLeadingAndTrailingChar (document.getElementById("telephone_comp").value, " "));
  var email=addslashes(removeLeadingAndTrailingChar (document.getElementById("email_comp").value, " "));
  var note=addslashes(removeLeadingAndTrailingChar (document.getElementById("note").value, " "));
  if(nom=="" || commentaire=="" || ville=="" || email=="")alert("Tous les champs en (*) sont obligatoires");
  else{
   
     getXhr();
     // On défini ce qu'on va faire quand on aura la réponse 
     xhr.onreadystatechange = function(){
     // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
        if(xhr.readyState == 4 && xhr.status == 200){ 
           var leselect = xhr.responseText; 
	        
			//alert(leselect);
			 var reponse = eval('(' + leselect + ')');
			 
			 if(reponse.erreur=="oui"){
			  document.getElementById("resultat").innerHTML = reponse.message;
			 }else{
				  document.getElementById('resultat').innerHTML = reponse.message;
				  document.getElementById("div_formulaire").style.display="none";
				  if(document.getElementById("partager").checked==true){ 
					callPublish('',{'name':''+nom+' a commenté le profil de '+competence+' sur SAWAMARKET.COM','href':'http://sawamarket.com/index.php','description':''+commentaire+'','media':[{'type':'image','src':'http://sawamarket.com/images/logo_bas.png','href':'http://sawamarket.com/index1.php'}]},[{'text':'Sawamarket:la Vitrine des petits Metiers','href':'http://sawamarket.com/index.php'}]);
				  }
				  
				  
			 }			   
	   
        } 
      }
	  
     // Ici on va voir comment faire du post 
     xhr.open("POST","envoyer_appreciation.php",true); // ne pas oublier ça pour le post 
     //xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	 xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1');

     //// ne pas oublier de poster les arguments // 
	 //alert("nom="+nom+"&commentaire="+commentaire+"&ville="+ville+"&email="+email+"&telephone="+telephone+"&idcompetence="+idcompetence+"&note="+note);
     xhr.send("nom="+nom+"&commentaire="+commentaire+"&ville="+ville+"&email="+email+"&telephone="+telephone+"&idcompetence="+idcompetence+"&note="+note);
  	 //alert("titre="+titre+"&commentaire="+commentaire+"&idarticle="+idarticle+"&email="+email+"&pseudo="+pseudo);
      document.getElementById('resultat').innerHTML="<span style='color:red'><b>Traitement encours ... veuillez patienter !</b></span>";

  }
}


 function addslashes( str ) {  
      return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");  
} 

function afficher_inscription(){
  maDiv="article";
  var x_left=(document.body.clientWidth-1000)/2; 
  document.getElementById(maDiv).style.left=x_left+"px";
  document.getElementById(maDiv).style.width="1000px";
  document.getElementById(maDiv).style.top="50px";
  
  document.getElementById("div_recherche").style.width=document.body.clientWidth+"px";
  document.getElementById("div_recherche").style.height=document.getElementById("page").offsetHeight+"px";
  
  document.getElementById("div_recherche").style.display='inline';
  document.getElementById(maDiv).style.display='inline';
  //document.getElementById("mon_menu").style.display='none';
  
  document.getElementById(maDiv).innerHTML="<table width='100%'  border='0'>  <tr>    <td height='70' align='center' valign='middle' class='titre_la_une' style='color:white'>Chargement en cours ... Veuillez patienter <br>    <img src='images/loadinfo.net.gif' width='24' height='24'></td>  </tr></table>";
  //new Effect.ScrollTo('page',{delay:0.5,duration:1});
  window.scrollTo(0,0);
   getXhr();
  // On défini ce qu'on va faire quand on aura la réponse 
  xhr.onreadystatechange = function(){
    // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){ 
     var leselect = xhr.responseText; 
	  //alert(leselect);
	  document.getElementById('article').innerHTML = leselect;
	   
    } 
  }
  // Ici on va voir comment faire du post 
  xhr.open("POST","page_inscription.php",true); // ne pas oublier ça pour le post 
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  // ne pas oublier de poster les arguments // 
  
  xhr.send("");
}


function Inscription(){
  
  var nom=removeLeadingAndTrailingChar (document.getElementById("nom").value, " ");
  var commentaire=removeLeadingAndTrailingChar (document.getElementById("commentaire").value, " ");
  var ville=removeLeadingAndTrailingChar (document.getElementById("ville").value, " ");
  var telephone=removeLeadingAndTrailingChar (document.getElementById("telephone").value, " ");
  var email=removeLeadingAndTrailingChar (document.getElementById("email").value, " ");
  var objet=removeLeadingAndTrailingChar (document.getElementById("objet").value, " "); 
  if(nom=="" || commentaire=="" || ville=="" || objet=="" || email=="")alert("Tous les champs en (*) sont obligatoires");
  else{
   
     getXhr();
     // On défini ce qu'on va faire quand on aura la réponse 
     xhr.onreadystatechange = function(){
     // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
        if(xhr.readyState == 4 && xhr.status == 200){ 
           var leselect = xhr.responseText; 
				   var reponse = eval('(' + leselect + ')');
				   
				   if(reponse.erreur=="oui"){
					document.getElementById("resultat").innerHTML = reponse.message;
				   }else{
					document.getElementById('resultat').innerHTML = reponse.message;
			        document.getElementById("formulaire_contact").reset();
				   }			   
			//alert(leselect);
	   
        } 
      }
	  
     // Ici on va voir comment faire du post 
     xhr.open("POST","envoyer_inscription.php",true); // ne pas oublier ça pour le post 
     xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     // ne pas oublier de poster les arguments // 
     xhr.send("nom="+nom+"&commentaire="+commentaire+"&ville="+ville+"&objet="+objet+"&email="+email+"&telephone="+telephone);
  	 //alert("titre="+titre+"&commentaire="+commentaire+"&idarticle="+idarticle+"&email="+email+"&pseudo="+pseudo);
      document.getElementById('resultat').innerHTML="<span style='color:red'><b>Traitement encours ... veuillez patienter !</b></span>";

  }
}



