var req;

function loadXMLDoc(url,fonction) {
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		var lafonction = fonction;
		var b = new Array();
		if(arguments.length > 2) {
			for(var i = 2; i < arguments.length; i++) {
				b.push(arguments[i]);
			}
		}
		req.onreadystatechange = function() { lafonction.apply(null, b); };
		req.open("GET", url, true);
		req.send(null);
	}
}
function loadXMLDocSync(url,fonction) {
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.open("GET", url, false);
		req.send(null);
		var b = new Array();
		if(arguments.length > 2) {
			for(var i = 2; i < arguments.length; i++) {
				b.push(arguments[i]);
			}
		}
		fonction.apply(null, b);
	}
}


function veriferreur(fonct) {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            var retour=req.responseXML;
            if(retour.getElementsByTagName('erreur').length>0) {
            	alert(retour.getElementsByTagName('erreur')[0].firstChild.data);
            } else {
				var b = new Array();
				if(arguments.length > 1) {
					for(var i = 1; i < arguments.length; i++) {
						b.push(arguments[i]);
					}
				}
				fonct.apply(null, b);
            }
        }
    }
}

function retoursimple() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            return true;
        }
    }
}
function renvoicommun(id) {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            var retour=req.responseXML;
            if(retour.getElementsByTagName('erreur').length>0) {
            	alert(retour.getElementsByTagName('erreur')[0].firstChild.data);
            } else {
            	document.getElementById(id).innerHTML=retour.getElementsByTagName('commun')[0].firstChild.data;
            }
        }
    }
}

function popupWindow(url) {
window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=640, height=640,screenX=30,screenY=30,top=30,left=30')
}

function popupWindowTaille(url,larg,haut) {
window.open(url,'popupWindowtaille','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+larg+', height='+haut+',screenX=30,screenY=30,top=30,left=30')
}
