var oXmlHttp
var response = "/";
var theCallback;

function getPage(url,callback)
{
	theCallback = callback;
	
    oXmlHttp = null
    // code for Mozilla, etc.
    if (window.XMLHttpRequest)
    {
        oXmlHttp = new XMLHttpRequest()
    }
    // code for IE
    else if (window.ActiveXObject)
    {
        oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
    }

	// add some randomization
	url = url + '&' + Math.random();
	// alert(url);
	
	oXmlHttp.open("GET", url, true)
	oXmlHttp.onreadystatechange = stateChanged;
	oXmlHttp.send(null);
}

function stateChanged()
{
    // if xmlhttp shows "loaded"
    if (oXmlHttp.readyState==4)
    {
        // if "OK"
        if (oXmlHttp.status==200)
        {
            // ...some code here...
            response = oXmlHttp.responseText.trim();
        }
        else
        {
            response = "/";
        }
		theCallback(response);
    }
	
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function Elem(theid) {
	return document.getElementById(theid);
}

