// JavaScript Document

var xhr = null;
 
// Fonction de creation de l'objet XMLHttpRequest qui resservira pour chaques fonctions AJAX
function getXhr()
 {
  if(window.XMLHttpRequest) {xhr = new XMLHttpRequest();} 
  else if(window.ActiveXObject)
   {  
    try
     {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch (e)
     {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
   }
  else 
   { 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest, veuillez le mettre  jour"); 
    xhr = false; 
   } 
 }
 

  pas=0;
  
  function go_droite()
{
	if (pas==9){
		
	}
	else{
		
		new Effect.MoveBy('pano_centre', 0, -210, {duration:1, fps:25, from:0.0, to:1.0, beforeStart:out, afterFinish:retour});
		pas=pas+1;
	}
}

  function go_gauche()
{
	if (pas==0){
	}
	else {
		new Effect.MoveBy('pano_centre', 0, 210, {duration:1, fps:25, from:0.0, to:1.0, beforeStart:out, afterFinish:retour});
		pas=pas-1;
	}
}

function out(){
	document.getElementById('pano_gauche').innerHTML = '<a href="javascript:void(0)" ></a>';
	document.getElementById('pano_droit').innerHTML = '<a href="javascript:void(0)" ></a>';
}

function retour(){
	document.getElementById('pano_gauche').innerHTML = '<a href="javascript:void(0)" onclick="go_gauche();" title="Défiler"></a>';
	document.getElementById('pano_droit').innerHTML = '<a href="javascript:void(0)" onclick="go_droite();" title="Défiler"></a>';
}

function delpost(champ) {
	
	
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
		  new Effect.BlindUp('p'+champ, {duration:.3});
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','delpost.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("champ="+escape(champ));

  
  }
  
  function liberer(champ) {
	
	
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			location.reload();
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','liberer.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("champ="+escape(champ));

  
  }
  
function fermer(champ) {
	
	
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			location.reload();
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','fermer.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("champ="+escape(champ));

  
  }
  
    function citer(champ) {
	
	
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			chaine = xhr.responseText;
			tinyMCE.execInstanceCommand('mce_editor_0','mceInsertContent', false, chaine);
			Element.scrollTo('poster_texte');	
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','citer.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("champ="+escape(champ));

  
  }
  
  
  function postit_on(champ) {
	
	
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			location.reload();
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','postit_on.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("champ="+escape(champ));

  
  }
  
    function fusionner(champ, champ2) {
	
	
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			location.reload();
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','fusion.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("champ="+escape(champ)+"&champ2="+escape(champ2));

  
  }
  
 function membres() {
	
	if (document.getElementById('destinataire').value.length > 0) {
    var liste = document.getElementById('destinataire').value;
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			chaine = xhr.responseText;
			document.getElementById('dest').innerHTML = chaine;
			document.getElementById('dest').style.visibility='visible';
 			document.getElementById('dest').style.display='block';
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','mp_membres.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("qrest="+escape(liste));
    }
  else {
	  document.getElementById('dest').innerHTML = "";
	document.getElementById('dest').style.visibility='hidden';
  document.getElementById('dest').style.display='none';}

  
  }
  
  function completion(mot, champ, champr) {
  document.getElementById(champ).value =  mot.replace(/__/g, ' ');
  document.getElementById(champr).innerHTML = '';
  document.getElementById(champr).style.visibility='hidden';
  document.getElementById(champr).style.display='none';
  }
  
  function spoiler(sp){
	  if (sp.style.color=='black'){
		  sp.style.color='white';
	  }
	  else {
		  sp.style.color='black';
	  }
  }
  
function autoc(champ, champr, nomtab) {
	
	if (document.getElementById(champ).value.length > 0) {
    var liste = document.getElementById(champ).value;
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			chaine = xhr.responseText;
			document.getElementById(champr).innerHTML = chaine;
			document.getElementById(champr).style.visibility='visible';
 			document.getElementById(champr).style.display='block';
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','tableaux.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("q="+escape(liste)+"&champ="+escape(champ)+"&nomtab="+escape(nomtab)+"&champr="+escape(champr));
    }
  else {
	  document.getElementById(champr).innerHTML = "";
	document.getElementById(champr).style.visibility='hidden';
  document.getElementById(champr).style.display='none';}

  
  }


function completion(mot, champ, champr) {
  document.getElementById(champ).value =  mot.replace(/__/g, ' ');
  document.getElementById(champr).innerHTML = '';
  document.getElementById(champr).style.visibility='hidden';
  document.getElementById(champr).style.display='none';
  }
  
  function add(num, champ, nom) {
	
	
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			chaine = xhr.responseText;
			document.getElementById(nom+(num-1)).innerHTML = chaine;
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','champs.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("champ="+escape(champ)+"&nom="+escape(nom)+"&num="+escape(num));

  
 }
  
 function ChangeUrl(formulaire){
	if (formulaire.categories.selectedIndex != 0){
	location.href = formulaire.categories.options[formulaire.categories.selectedIndex].value;
	}
 }
 
 function double(num, champ, nom, champ2, nom2) {
	
	
	getXhr();
	
 	 xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		 {
			chaine = xhr.responseText;
			document.getElementById(nom+(num-1)).innerHTML = chaine;
		}
     }
   
  
  // On envoie la requete au php
  xhr.open('POST','champs2.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  
  // On envoie au php
  xhr.send("champ="+escape(champ)+"&nom="+escape(nom)+"&num="+escape(num)+"&champ2="+escape(champ2)+"&nom2="+escape(nom2));

  
  }


