
function NewXMLHttpObj() {
	NewXmlHttp = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP") ;
	if ( ! NewXmlHttp )
		NewXmlHttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");

	return NewXmlHttp;
}
var XmlHttp = NewXMLHttpObj();

function CreaRequest() {
	if (XmlHttp) {
		if ( XmlHttp.readyState >= 1 ){
			return NewXMLHttpObj() ;
		}
		if ( XmlHttp.readyState == 0 ) {
			return XmlHttp;
		}

	} else {
		return  NewXMLHttpObj();
	}

}


function fetchPage( page , destin ) {
        var fXmlHttp =  CreaRequest();

  // if you did not specify a destination div
	if (destin )
		var destinObj = document.getElementById( destin );
	else
  // put result in the default id
		var destinObj = document.getElementById( "visore" );
  // fetch effectly 
        fXmlHttp.open("get", page, true);

        fXmlHttp.onreadystatechange = function () {
             if (fXmlHttp.readyState == 4) {
                    if (fXmlHttp.status == 200) {
				destinObj.innerHTML = fXmlHttp.responseText;
				return fXmlHttp.responseText;
			}
                    } 
                    
                
            };
            fXmlHttp.send(null);
}

