var xhr = null;
var cmpt=0;

//fonction de cr�ation d'objet XMLHttRequest
function get_Xhr()
 {
  if(window.XMLHttpRequest)
   {
    xhr = new XMLHttpRequest();
   }
  else if(window.ActiveXOject)
   {
    try
     {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch(e)
     {
      try
       {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
       }
      catch(el)
       {
        xhr = null;
       }
     }
   }
  else
   {
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest\nVeuillez le mettre � jour");
   }
  return xhr;
 }

///////////////////////// AJOUTE UN FORMULAIRE PRODUIT /////////////////////////////////////
function ajoutprod(fo, id)
 {
  get_Xhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
      document.getElementById(fo).innerHTML = xhr.responseText;
     }
   }

  xhr.open("GET",'../ajax/ajouterprod.php?id='+id,true);
  xhr.setRequestHeader('Content-Type','x-www-form-urlencoded');

  xhr.send(null);
 } 
 
///////////////////////// AJOUTE UN FORMULAIRE DOCUMENT /////////////////////////////////////
function ajoutdoc(fo, id)
 {
  get_Xhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
      document.getElementById(fo).innerHTML = xhr.responseText;
     }
   }

  xhr.open("GET",'../ajax/ajouterdoc.php?id='+id,true);
  xhr.setRequestHeader('Content-Type','x-www-form-urlencoded');

  xhr.send(null);
 } 
 
 
///////////////////////// AJOUTE DES PHOTO DU DIAPO PRODUIT/////////////////////////////////////
function photo(fo, nb,aff,typeImg)
 {
  get_Xhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
      document.getElementById(fo).innerHTML = xhr.responseText;
     }
   }

  xhr.open("GET",'ajax/photo_a.php?nb='+nb+'&aff='+aff+'&typeImg='+typeImg,true);
  xhr.setRequestHeader('Content-Type','x-www-form-urlencoded');

  xhr.send(null);
 }
 ///////////////////////// AJOUTE DES PHOTO DU DIAPO MENU/////////////////////////////////////
function diapo(fo, nb,f,typeImg)
 {
  get_Xhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
      document.getElementById(fo).innerHTML = xhr.responseText;
     }
   }

  xhr.open("GET",'ajax/diapo_a.php?nb='+nb+'&aff='+f+'&,typeImg='+typeImg,true);
  xhr.setRequestHeader('Content-Type','x-www-form-urlencoded');

  xhr.send(null);
 }
  ///////////////////////// SUPPRIMERLOGO FILIALE /////////////////////////////////////
function logo(nb, nom, id)
 {
  get_Xhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
      document.getElementById(nb).innerHTML = xhr.responseText;
     }
   }


  xhr.open("GET",'ajax/logo_s.php?id='+id+'&nb='+nb+'&nom='+nom,true);
  xhr.setRequestHeader('Content-Type','x-www-form-urlencoded');


  xhr.send(null);
 }
 function getNewPwd(id){
	 get_Xhr();
	  xhr.onreadystatechange = function()
	   {
	    if(xhr.readyState == 4 && xhr.status == 200)
	     {
	      document.getElementById(id).value = xhr.responseText;
	     }
	   }

	  xhr.open("GET",'ajax/getNewPwd.php?',true);
	  xhr.setRequestHeader('Content-Type','x-www-form-urlencoded');

	  xhr.send(null);
 }
 function Suggest(mot,lang,type,id){
     document.getElementById('tradMot_'+id).style.cursor = "wait";
	 get_Xhr();
	  xhr.onreadystatechange = function()
	   {
	    if(xhr.readyState == 4 && xhr.status == 200)
	     {
	        reponseSuggestNom(xhr.responseText);
	    
	     }
	   }
	  xhr.open("GET",'ajax/generation-mot-cle.php?mot='+mot+'&lang='+lang+'&type='+type+'&idSel='+id,true);
	  xhr.setRequestHeader('Content-Type','x-www-form-urlencoded');

	  xhr.send(null);
 }
 function addRub(type,idElt,idRub){
	 content=document.getElementById(idElt).innerHTML;
	 rub='<p style="margin-left:80px;">';
	 rub+='<input id="asrub" type="text" value="Français" name="arub_fr[]" onfocus="if(this.value==\'Français\')this.value=\'\';" onblur="if(this.value==\'\')this.value=\'Français\';"/>';
	 rub+='<input id="asrub" type="text" value="Anglais" name="arub_uk[]"  onfocus="if(this.value==\'Anglais\')this.value=\'\';" onblur="if(this.value==\'\')this.value=\'Anglais\';" />';
	 rub+='<input id="asrub" type="text" value="Espagnol" name="arub_es[]" onfocus="if(this.value==\'Espagnol\')this.value=\'\';" onblur="if(this.value==\'\')this.value=\'Espagnol\';"/>';
	 rub+='<input id="asrub" type="text" value="Allemand" name="arub_de[]" onfocus="if(this.value==\'Allemand\')this.value=\'\';" onblur="if(this.value==\'\')this.value=\'Allemand\';"/>';
	 rub+='<input id="asrub" type="text" value="Chinois" name="arub_cn[]" onfocus="if(this.value==\'Chinois\')this.value=\'\';" onblur="if(this.value==\'\')this.value=\'Chinois\';"/>';
	 rub+='<img height="16" width="16" alt="Page vierge" src="picto/page_white_delete.png"/>';
	 rub+='<input type="radio" checked="checked" value="0" name="koi'+cmpt+'"/>';
	 rub+='<img src="picto/page.png"/>';
	 rub+='<input id="asrub" type="radio" value="1" name="koi'+cmpt+'" checked="checked"/>';
	 rub+='<img src="picto/image.png"/>';
	 rub+='<input id="asrub" type="radio" value="2" name="koi'+cmpt+'"/>';
	 rub+='<input id="" type="hidden" value="42" name="aki[]"/>';
	 rub+='</p>';
	 document.getElementById(idElt).innerHTML=content+rub;
	 cmpt++;
 }
 