function menu(lien){
     var teste = document.getElementById("teste");
alert (teste.className); 
   var mesinputs = document.getElementsByTagName('li');
    for (var i=0; i<mesinputs.length; i++) {
	mesinputs[i].className="active";
    }

alert (teste.type); 
  teste.className = "active";
  test.visible = false;
alert (teste.className); 
}


function editeur_annonceur(){
  var sel = document.getElementById('abn_droits');
  var droit = sel.options[sel.selectedIndex].value;
  if (droit==3)
    document.getElementById("annonc_edit").innerHTML = "Quel type d'annonceur êtes-vous ?";
  else
    document.getElementById("annonc_edit").innerHTML = "Quel type d'editeur êtes-vous ?";
}

//verifie la validation du form
function verif(etape){
  if (etape == 1){
      var cpostal = document.getElementById('abn_cpostal');
      if (isNaN(cpostal.value) || cpostal.value.length !=5) {
	  alert ("Ce code postal n'est pas valide");
	  return false;
      }
  }else{
      if (etape == 2){
	    var tel = document.getElementById('abn_telephone');
	    var mobile = document.getElementById('abn_mobile');
	    if (tel.value == "") {
		alert ("Ce numéro de telephone n'est pas valide");
		return false;
	    }
	    if (mobile.value  == "") {
		alert ("Ce numéro de mobile n'est pas valide");
		return false;
	    }
      }
  }
  return true;
}


//Si un client est un particulier on ne demande pas de siret....
function masque_info_societe() {
  var typ = document.getElementById('id_societe_type');
  var typ2 = typ.options[typ.selectedIndex].value; 
  if(typ2 == 3){
    document.getElementById("info_societe").innerHTML = "";
  }else{
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                 document.getElementById("info_societe").innerHTML = xhr.responseText;	 
              else 
                 document.getElementById("info_societe").innerHTML="Error code " + xhr.status;
         }
    }; 

   xhr.open( "GET", "info_societe_tpl.php",  true); 
   xhr.send(null);
  }
}

//---coche tout les element pour la case cocher tout---
function checkUncheckAll(theElement) {
    var theForm = theElement.form, z = 0;
    for(z=0; z<theForm.length;z++){
	if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	    theForm[z].checked = theElement.checked;
	}
    }
}

//---charge l'element pour assigner un manager---
function getListeManager()
{ 
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                 document.getElementById("zone").innerHTML = "Vous voulez assignez ces contacts à" + xhr.responseText;	 
              else 
                 document.getElementById("zone").innerHTML="Error code " + xhr.status;
         }
    }; 

   xhr.open( "GET", "assigner_tpl.php",  true); 
   xhr.send(null); 
}


//---charge l'element pour assigner un manager---
function getListeSite(num)
{ 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }

    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
		  document.getElementById("zoneListe").innerHTML = xhr.responseText;	 
              else 
                 document.getElementById("zoneListe").innerHTML="Error code " + xhr.status;
         }
    }; 


   xhr.open("POST", "listeSite.php",  true); 
   xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
  xhr.send('annonceur=' + num);

}



//---envoie les case cocher et recupere le tableau a afficher---
function changeManager(adr, chmp, manager,typ)
{ 

    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }

    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                getTableauContact();
				// document.getElementById("zonetableau").innerHTML = "Vous voulez assignez ces contacts à:" + xhr.responseText;	 
              else 
                 document.getElementById("zonetableau").innerHTML="Error code " + xhr.status;
         }
    }; 

   xhr.open("POST", adr,  true); 
   xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
   var cb = document.getElementsByName(chmp);
   var ids = new Array();
  for(var i=0; i<cb.length;i++) {
		if(cb[i].checked) ids[ids.length] = cb[i].value ;
  }
  var sel = document.getElementById('manager');
  var idmanager = sel.options[sel.selectedIndex].value;
  xhr.send('champ=' + ids.join(',')+'&manager=' + idmanager+ '&typ=' +typ);
  //xhr.send('champ=' + ids.join(','));
}
   

 

//---Pour créer la chaine a envoyer a la page php---
function getChaine( champ ){
   var cb = document.getElementsByName(champ);
   var ids = new Array();
   for(var i=0; i<cb.length;i++) {
      if(cb[i].checked) ids[ids.length] = cb[i].value;
   }
   
   return ids.join(',');
} 

//---Pour créer la chaine a envoyer a la page php aussi MAIS utilise id (utile pour bouton radio) ---
function getChaineid( champ ){
   var mesinputs = document.getElementsByTagName(champ);
   var nom = new Array();
   var actif = new Array();
    for (var i=0; i<mesinputs.length; i++) {
      if (mesinputs[i].type.toLowerCase()=="radio" ) { 
	  if(mesinputs[i].name.substring(0,3)=="abn"){
	      if(mesinputs[i].checked){
		nom[nom.length] = mesinputs[i].name.substr(4,3);
		actif[actif.length] = mesinputs[i].value ;
	      }
	  }
      }
    }
  var chaine = 'nom=' + nom.join(',') + '&actif=' + actif.join(',');
  return chaine;
} 
//---envoie les case cocher et recupere le tableau a afficher---
function getTableauContact() { 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }

    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                 document.getElementById("zonetableau").innerHTML ="Voici les resultats :" +  xhr.responseText;	 
              else 
                 document.getElementById("zonetableau").innerHTML="Error code " + xhr.status;
         }
    }; 

   xhr.open("POST", "tableau_contact_tpl.php",  true); 
   xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
   var chaine = 'champ=' + getChaine("tab");
   chaine += '&type=' + getChaine("type");
   chaine += '&actif=' + getChaine("actif");
   chaine += '&manager=' + getChaine("manager");
   xhr.send(chaine);
}

//---envoie les case cocher et recupere le tableau a afficher---
function getTableau(adr) { 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }

    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                 document.getElementById("zonetableau").innerHTML =  xhr.responseText;	 
              else 
                 document.getElementById("zonetableau").innerHTML="Error code " + xhr.status;
         }
    }; 

   xhr.open("POST", adr,  true); 
   xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
   var chaine = 'champ=' + getChaine("tab");
   xhr.send(chaine);
}

function gestion_inscription(){
    if(confirm("Etre-vous sûr de vouloir modifier le status ?")) gestion_inscription2();
    else getTableauContact();
}
//---appelle la page administration_gestion_inscription.php
function gestion_inscription2(){

      try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
      catch (e) 
      {
	  try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
	  catch (e2) 
	  {
	    try {  xhr = new XMLHttpRequest();     }
	    catch (e3) {  xhr = false;   }
	  }
      }

      xhr.onreadystatechange  = function()
      { 
	  if(xhr.readyState  == 4)
	  {
		if(xhr.status  == 200) 
		  // document.getElementById("zonetableau").innerHTML="thss = " + xhr.responseText;
		  getTableauContact();
		  //alert("ok");
		else 
		  document.getElementById("zonetableau").innerHTML="Error code " + xhr.status;
	  }
      }; 

    xhr.open("POST", "administration_gestion_inscription.php",  true); 
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
      var chaine = getChaineid("input");
    xhr.send(chaine);
  }

function modif_inscription(id){
  window.open('modif_inscription.php?id=' + id ,'pop_up', ' width=555 height=800 scrollbars=no location=no directories=no menubar=no toolbar=no status=no onclose=getTableauContact()' );
 }

function inscription(){
  window.open('inscription_manager.php' ,'pop_up', ' width=555 height=800 scrollbars=no location=no directories=no menubar=no toolbar=no status=no' );
}

function modif_campagne(id){
  window.open('creation_campagne2.php?id=' + id ,'pop_up', ' width=555 height=800 scrollbars=no location=no directories=no menubar=no toolbar=no status=no' );
}

function ajout_campagne(){
  window.open('creation_campagne3.php' ,'pop_up', ' width=555 height=800 scrollbars=no location=no directories=no menubar=no toolbar=no status=no' );
}

function afficheCgv(type){
	if(type==1){
		window.open('bk-CGV.php' ,'pop_up', ' width=555 height=800 scrollbars=no location=no directories=no menubar=no toolbar=no status=no' );
	}else{
		window.open('bk-CGV2.php' ,'pop_up', ' width=555 height=800 scrollbars=no location=no directories=no menubar=no toolbar=no status=no' );
	}
  
}

