
/* AJAX GENERIC */
var req = false;
function loadXMLDocGeneric_classe(url, mimetype, cible1, cible2)
{   
	if (window.req!=false)
	{
		if (window.req.abort) window.req.abort();
		window.req=null;
		window.req=false;
	}

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		window.req = new XMLHttpRequest();
		if (window.req.overrideMimeType) {
			window.req.overrideMimeType(mimetype);
		}
	} else if (window.ActiveXObject) { // IE
		try {
			window.req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				window.req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!window.req) {
		alert('Abandon :( Impossible de créer une instance XMLHTTP');
		return false;
	}
	 
	window.req.onreadystatechange = function() {
	  document.getElementById('loding_affiche').src="images/loading.gif"; 
	   document.getElementById('loading_cal').src="images/loading.gif"; 
	  processReqChangeGeneric_classe(cible1, cible2); 
	};
	window.req.open('GET', url, true);
	
	window.req.send(null);
}

function processReqChangeGeneric_classe(cible1, cible2) {
	if (window.req.readyState == 4)
	{   
	    var tableau = new Array();
		var tableau2 = new Array();
		tableau = req.responseText.split('::'); 
		if (window.req.status == 200)
		{   
			if (tableau[0]=='1'){
			  tableau2 = tableau[1].split('|||'); 
			  if(tableau2.length == 2) document.getElementById(cible1).innerHTML = tableau2[1];
			  else document.getElementById(cible1).innerHTML = tableau[1];
			  document.getElementById('loding_affiche').src="images/vide.gif";
			  document.getElementById('loading_cal').src="images/vide.gif";
			  if(cible2) document.getElementById(cible2).innerHTML = tableau[2];
			  if(tableau2.length == 2) alert(tableau2[0]); 
			}
			else {
			  document.getElementById('loding_affiche').src="images/vide.gif";
			  document.getElementById('loading_cal').src="images/vide.gif";
			  alert(tableau[1]); 
			}  
		}
		
		window.req.abort();
		window.req=null;
		window.req=false;
	}
	//else document.getElementById(cible1).innerHTML = 'Erreur lors de l\'Exécution de la Requette';
}


  function Ajax_Lien(url, id1, id2) {
    //document.getElementById(id1).innerHTML = url;
    loadXMLDocGeneric_classe(url, 'text/html', id1, id2);
  }


  function Envoi_Form_Get(form, page, id1, id2, type) {
		var formulaire = eval('document.' + form);
		var val;
		
		if(type) {		 
		  for (i=0; i < formulaire.elements.length; i++)
			{ 
			  le_type = formulaire.elements[i].type;
			  le_type = le_type.toLowerCase();
			  if(le_type != 'button' && le_type != 'BUTTON') {
			    if(aux) aux += '&';
				val = formulaire.elements[i].value;
				if(le_type == 'checkbox' || le_type == 'radio') val = (formulaire.elements[i].checked)?'1':'0';
				val = val.replace('&', '|||');
			    aux += formulaire.elements[i].name + '=' + val;
			  }	
			}
	    }
		page = page + '?' + aux;
		//alert(page);
		Ajax_Lien(page, id1, id2); 	
  }

/* */