var hpo_toolbox_Xhr			= null;

function hpo_toolbox_getXmlNodeValue(reponse, sName) {
	var node = reponse.getElementsByTagName(sName)[0];
	
	if ((node == null) || (node.childNodes.length == 0))
		return "";
	
	return node.firstChild.nodeValue;
}

function hpo_toolbox_getXhr(){
	var xhr = null;
	
	if(window.XMLHttpRequest)		// Firefox et autres
		xhr = new XMLHttpRequest();
	else if(window.ActiveXObject){	// Internet Explorer 
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else { // XMLHttpRequest non support? par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		xhr = false; 
	}
	
	return xhr;
}

function hpo_toolbox_onLoadXhr(xmlPath, obj, filter, onReadyStateChangeFct) {
	if (!onReadyStateChangeFct)
		onReadyStateChangeFct = 'hpo_toolbox_onChangeXhr';
		
	var param = "";
	var d = new Date();
	xmlPath += "&filter="+escape(filter);
	xmlPath += "&forceRefresh="+d.getTime();
	
	//alert(xmlPath+"--"+obj+"--"+filter+"--"+onReadyStateChangeFct);
	
	if (hpo_toolbox_Xhr == null) {
		hpo_toolbox_Xhr = hpo_toolbox_getXhr();
		
		if (hpo_toolbox_Xhr != null) {
			try {
				hpo_toolbox_Xhr.open("GET", xmlPath, true);
				hpo_toolbox_Xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				hpo_toolbox_Xhr.onreadystatechange = function() {
					eval(onReadyStateChangeFct+'(obj);');
				}
				
				hpo_toolbox_Xhr.send(param);
			}
			catch (e) {
				alert("erreur : " + e);
			}
		}
		else
			setTimeout("hpo_toolbox_onLoadXhr('" + xmlPath + "', '" + obj + "', '" + filter + "');",1000);
	}
}

function hpo_toolbox_onSubmitXhr(obj) {
	if(hpo_toolbox_Xhr && hpo_toolbox_Xhr.readyState == 4 && hpo_toolbox_Xhr.status == 200 && hpo_toolbox_Xhr.responseXML != null) {
		var xml = hpo_toolbox_Xhr.responseXML.documentElement;
		var node = xml.getElementsByTagName("numIndex");
		alert(hpo_toolbox_getXmlNodeValue(node[0],"text"));
		
		hpo_toolbox_Xhr = null;
	}
}

var bIsToDestroy;
var hpo_toolbox_theTime = 250;
function hpo_toolbox_showNotationTab(notationtab){
	var obj = document.getElementById(notationtab);
	obj.style.visibility = 'visible';
	clearTimeout(bIsToDestroy);
}
function hpo_toolbox_hideNotationTab(notationtab){
	bIsToDestroy = setTimeout("hpo_toolbox_destroyNotationTab('" + notationtab + "')",hpo_toolbox_theTime);
}
function hpo_toolbox_destroyNotationTab(notationtab){	
	clearTimeout(bIsToDestroy);
	var obj = document.getElementById(notationtab);
	obj.style.visibility = 'hidden';
}