// Ajax Functions
function getElement(ID)
{
	return (document.getElementById(ID)) ? document.getElementById(ID) : document.all[ID];
}

function assegnaXMLHttpRequest() 
{
	// lista delle variabili locali
	var
	 // variabile di ritorno, nulla di default
	 XHR = null,
	 
	 // informazioni sul nome del browser
	 browserUtente = navigator.userAgent.toUpperCase();
	
	
	 // browser standard con supporto nativo
	 // non importa il tipo di browser
	 if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
	  XHR = new XMLHttpRequest();
	
	 // browser Internet Explorer
	 // è necessario filtrare la versione 4
	 else if(
	  window.ActiveXObject &&
	  browserUtente.indexOf("MSIE 4") < 0
	 ) {
	 
	  // la versione 6 di IE ha un nome differente
	  // per il tipo di oggetto ActiveX
	  if(browserUtente.indexOf("MSIE 5") < 0)
	   XHR = new ActiveXObject("Msxml2.XMLHTTP");
	
	  // le versioni 5 e 5.5 invece sfruttano lo stesso nome
	  else
	   XHR = new ActiveXObject("Microsoft.XMLHTTP");
	 }
	 
	 return XHR;
} 

function execJS(t)
{
    var p1 = 0, p2 = 0, p3 = 0, p4 = 0;
    p1 = t.indexOf("<" + "script", 0);
    if(p1 == -1) return t;
    
    p2 = t.indexOf(">", p1 + 7) + 1;
    p3 = t.indexOf("<" + "/script>", p2);
    p4 = p3 + 9;
    
    var c = t.substring(p2, p3);
    var s = document.createElement("script");
    s.type = "text/javascript";
    s.text = c;
    document.getElementsByTagName("head")[0].appendChild(s);
    
    t = t.substring(0, p1) + t.substr(p4);
    return execJS(t);

}

function AddSlashes(s)
{
	s=s.replace(/\'/g, "\\'");
	return s;
}
