

//fonction de création de l'objet xhr (ajax)
function createXhrObject(){
    if (window.XMLHttpRequest)
        return new XMLHttpRequest();
 
    if (window.ActiveXObject){
        var names = [
            "Msxml2.XMLHTTP.6.0",
            "Msxml2.XMLHTTP.3.0",
            "Msxml2.XMLHTTP",
            "Microsoft.XMLHTTP"
        ];
        for(var i in names){
            try{
            	return new ActiveXObject(names[i]);
            }
            catch(e){}
        }
    }
    window.alert("Votre navigateur ne prend pas en charge l'objet XMLHTTPRequest.");
    return null; // non supporté
}


function handleSearchArdRequestStateChange(xhrConfirm,ici,idUser) {

	//DEBUG
	if(xhrConfirm) {
		
		if(xhrConfirm.readyState == 4) {		
			
			//continue seulement si le statut HTTP est OK
			if(xhrConfirm.status == 200) {
			
				//handleSearchAdsServerResponse(xhrConfirm);
				modif_confirm(ici,idUser);//On lance le js
				
				//DEBUG
				// alert('handleAddPopulaireRequestStateChange\nStatut HTTP = 200');
			}
		}

	}
	else {
		alert('handleSearchAdsRequestStateChange\nObjet xhr manquant !');
	}
	
}

function handleSearchArdRequestStateChange2(xhrConfirm,ici,idAvis) {

	//DEBUG
	if(xhrConfirm) {
		
		if(xhrConfirm.readyState == 4) {		
			
			//continue seulement si le statut HTTP est OK
			if(xhrConfirm.status == 200) {
			
				//handleSearchAdsServerResponse(xhrConfirm);
				supr_avis(idAvis);//On lance le js
				
				//DEBUG
				// alert('handleAddPopulaireRequestStateChange\nStatut HTTP = 200');
			}
		}

	}
	else {
		alert('handleSearchAdsRequestStateChange\nObjet xhr manquant !');
	}
	
}

function handleSearchArdRequestStateChange3(xhrConfirm,ici,idAvis) {

	//DEBUG
	if(xhrConfirm) {
		
		if(xhrConfirm.readyState == 4) {		
			
			//continue seulement si le statut HTTP est OK
			if(xhrConfirm.status == 200) {
			
				//handleSearchAdsServerResponse(xhrConfirm);
				valid_avis(idAvis);//On lance le js
				
				//DEBUG
				// alert('handleAddPopulaireRequestStateChange\nStatut HTTP = 200');
			}
		}

	}
	else {
		alert('handleSearchAdsRequestStateChange\nObjet xhr manquant !');
	}
	
}

function handleSearchAdsServerResponse(xhrConfirm) {

	var html = '';
	var searchXMLResponse;
	var nb_aff_annonce = 5;
	
	if (xhrConfirm.responseXML != null)
	{
		/*
		var avis = xhrConfirm.responseXML.getElementsByTagName("avis")[0].getAttribute("value");
		alert(avis);
		*/
	}
}
