/* 
 * Script réalisé par TEDDY FERRERE
 * REUNION FRANCE
 * Written by TEDDY FERRERE, http://www.roodali.com
 * Copyright 2007, Licence: Creative Commons "Attribution-ShareAlike 2.0 France" BY-SA (FR),
 * http://creativecommons.org/licenses/by-sa/2.0/fr/
 * - Attribution. You must give the original author credit
 * - Share Alike. If you alter, transform, or build upon this work,
 *   you may distribute the resulting work only under a license identical to this one
 * - The French law is authoritative
 * - Any of these conditions can be waived if you get permission from teddy FERRERE
 * - Please send to teddy FERRERE the modifications you make,
 *   in order to improve this file for the benefit of everybody
 */
/*______________________________________________*/
function queryselect(data, page, method, elem)
{
    if(window.ActiveXObject)
    {
        //Internet Explorer
        var FerTedObjc = new ActiveXObject("Microsoft.XMLHTTP") ;
    }//fin if
    else
    {
        //Mozilla
        var FerTedObjc = new XMLHttpRequest();
    }//fin else
    
    //définition de l'endroit d'affichage:
    var content = document.getElementById(elem);
    
    //si on envoie par la méthode GET:
    if(method == "GET")
    {
        if(data == 'null')
        {
            //Ouverture du fichier sélectionné:
            FerTedObjc.open("GET", page);
        }//fin if
        else
        {
            //Ouverture du fichier en methode GET
            FerTedObjc.open("GET", page+"?"+data);
        }//fin else
    }//fin if
    else if(method == "POST")
    {
        //Ouverture du fichier en methode POST
        FerTedObjc.open("POST", page);
    }//fin elseif
    FerTedObjc.onreadystatechange = function()
    {
		//tant que la réponse n'est pas arrivé afficher l'image d'attente
		if (FerTedObjc.readyState < 4){
			
			content.innerHTML = '<img src="../images/loading.gif">';
		}
		else {
		//sinon retourner la réponse	
		content.innerHTML = FerTedObjc.responseText;
		
		}
    }    
    if(method == "GET")
    {
        FerTedObjc.send(null);
    }//fin if
    else if(method == "POST")
    {
        FerTedObjc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        FerTedObjc.send(data);
		
    }//fin elseif
}//fin fonction queryselect
/*__________________________________________________________________________________________________*/