//<script>
	var myVarDebug=false;

	/**
	 *		Invia una pagina in modalità POST via XMLHTTP
	 *
	 **/
	function sendPostPage(targetPage, args){
		var xmlReq=new ActiveXObject("Microsoft.XMLHTTP");
		xmlReq.open("POST", targetPage, false);
		xmlReq.setRequestHeader("content-type","application/x-www-form-urlencoded");
		xmlReq.send(""+args);
		if (myVarDebug){
			var w=window.open("","_blank");
			w.document.writeln(xmlReq.responseText);

		}
		return xmlReq.responseText;
	}

	/**
	 *		Invia una pagina XML in modalità POST via XMLHTTP
	 *
	 **/
	function sendXmlPage(targetPage, args){
		var xmlReq=new ActiveXObject("Microsoft.XMLHTTP");
		xmlReq.open("POST", targetPage, false);
		xmlReq.setRequestHeader("content-type","text/xml");
		xmlReq.send(""+args);
		//alert(xmlReq.responseText);
		if (xmlReq.responseXML.xml==""){
			if (myVarDebug){
				var myTempDebug=window.open("","_blank");
				alert("Si è verificato un errore nella richiesta a:\n"+targetPage+"?"+args);
				document.writeln(xmlReq.responseText);
				return false;
			} else
				return false;
		}else
			return xmlReq.responseXML;
	}
	
	function requestGetPage(targetPage, args){
		var xmlReq=new ActiveXObject("Microsoft.XMLHTTP");
		xmlReq.open("GET", targetPage+"?"+args, false);
		xmlReq.send("");
		if (myVarDebug){
			var w=window.open("","_blank");
			w.document.writeln(xmlReq.responseText);

		}
		
		return xmlReq.responseText;
	}
	/**
	 *		Invia una pagina in modalità GET via XMLHTTP
	 *
	 **/
	function sendGetPage(targetPage, args){
		var xmlReq=new ActiveXObject("Microsoft.XMLHTTP");
		xmlReq.open("POST", targetPage+"?"+args, false);
		xmlReq.send("");
		if (xmlReq.responseXML.xml==""){
			//var myTempDebug=window.open("","_blank");
			alert("Si è verificato un errore nella richiesta a:\n"+targetPage+"?"+args);
			document.writeln(xmlReq.responseText);
			return;
		}else
			return xmlReq.responseXML;
	}

	/**
	 *		Ritorna il valore di un parametro passato via GET
	 *
	 **/
	function getReqParam(str, name){
		//Recupera il valore di un parametro passato nella richiesta
		var temp=str;
		
		//Splitto i parametri
		var ss=temp.split("&");
		var p,l;
		for (p=0; p<ss.length; p++){
			l=ss[p].indexOf("=");
			if (l<0 || ss[p].length==l) {
				//Nome del parametro nullo
			}else{
				var pname=unescape(ss[p].substring(0,l));
				if (pname.toUpperCase()==name.toUpperCase()){
					//Estraggo il valore
					if (ss[p].length==(l+1)) {
						//valore nullo
						return "";
					}else
						return unescape(ss[p].substr(l+1));
				}				
			}
		}
		return "";
	}

	/** 
	 *	     TRASFORMAZIONE XSLT PER GENERARE XML FINALE
	 *  ------------------------------------------------------
	 *
	 *  Viene applicato un documento XSL per creare un
	 *	documento XML dei soli elementi selezionati.
	 *  Ritorna una stringa con l'XML risultatnte.
	 **/
	function generaXmlResult(xmlSrc, filenameXsl){

		// Load style sheet.
		var stylesheet = new ActiveXObject("Msxml.DOMDocument");
		stylesheet.async = false
		stylesheet.load(filenameXsl);
		return xmlSrc.transformNode(stylesheet);	
	}

	function estraiParams(str){
		var expr
		expr=/#wb_+[a-z_A-Z]+#/g;
		var lista=str.match(expr);
		if (lista==null) return null;
		var t;
		for (t=0; t<lista.length; t++){
			lista[t]=lista[t].substring(4,lista[t].length-1);
		}

		return lista;
	}
	
	function centerWindow(tbl1){
		var x,y;
		x=tbl1.clientWidth;
		y=tbl1.clientHeight;

		x=x+tbl1.offsetLeft*2 ;
		y=y+tbl1.offsetTop*2 ;
		
		window.resizeTo(x,y);
		
		xx=document.body.offsetWidth;  
		yy=document.body.offsetHeight;
		
		window.resizeBy(x-xx,y-yy);
		window.moveTo(50,50);
}

function sendRequest(url, callback, postData) {
    var req = createXMLHTTPObject();
    if (!req) return;
    var method = (postData) ? "POST" : "GET";
    req.open(method, url, true);
    req.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
    if (postData)
        req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    req.onreadystatechange = function() {
        if (req.readyState != 4) return;
        if (req.status != 200 && req.status != 304) {
            //			alert('HTTP error ' + req.status);
            return;
        }
        callback(req);
    }
    if (req.readyState == 4) return;
    req.send(postData);
}

var XMLHttpFactories = [
	function() { return new XMLHttpRequest() },
	function() { return new ActiveXObject("Msxml2.XMLHTTP") },
	function() { return new ActiveXObject("Msxml3.XMLHTTP") },
	function() { return new ActiveXObject("Microsoft.XMLHTTP") }
];

function createXMLHTTPObject() {
    var xmlhttp = false;
    for (var i = 0; i < XMLHttpFactories.length; i++) {
        try {
            xmlhttp = XMLHttpFactories[i]();
        }
        catch (e) {
            continue;
        }
        break;
    }
    return xmlhttp;
}

	
//</script>