var xmlhttp;
var isLogin;
var currUrl;
function loadXMLDoc(url)
{
    currUrl = url;
    // code for Mozilla, etc
    if (window.XMLHttpRequest)
    {
        xmlhttp=new XMLHttpRequest();
        xmlhttp.onreadystatechange=xmlhttpChange;
        xmlhttp.open("GET",url+"?dummy="+new Date().getTime(),true);
        xmlhttp.send(null);
    }
    // code for IE
    else if (window.ActiveXObject)
    {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlhttp)
        {
            xmlhttp.onreadystatechange=xmlhttpChange;
            xmlhttp.open("GET",url+"?dummy="+new Date().getTime(),true);
            xmlhttp.send();
        }
    }
}
function xmlhttpChange()
{
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4)
    {
        // if "OK"
        if (xmlhttp.status==200)
        {
            // ...some code here...
            var xmlValue = xmlhttp.responseText 
            if(xmlValue.indexOf("isLogin") > -1) {
                setLogin();
                //setLayer();
                if (document.getElementById("btnlogout")!=null) document.getElementById("btnlogout").style.display="";
                if (document.getElementById("mydiv")!=null) document.getElementById('mydiv').style.display="";
                if (document.getElementById("btnlogin")!=null) document.getElementById("btnlogin").style.display="none";
            }
            if(typeof(document.getElementById('mydiv')) != "undefined"){
                if(xmlValue.indexOf("<form") > -1){
                    //Logout, not show login panel.
                    document.getElementById('mydiv').innerHTML = "&nbsp;";
                    //document.getElementById('mydiv').style.display="none";				
                    if (document.getElementById("btnlogout")!=null) document.getElementById("btnlogout").style.display="none";
                    if (document.getElementById("btnlogin")!=null) document.getElementById("btnlogin").style.display="";
                }else{
                    //Login already show name.
                    document.getElementById('mydiv').innerHTML = xmlValue;
                }
            }
        }
        else
        {
            alert("Error Status " + xmlhttp.status + ":Problem retrieving XML data" + xmlhttp.status + " " + currUrl)
        }
    }
}
function geturl(url){	
	document.getElementById('mydiv').innerHTML = "please wait..."
	loadXMLDoc(url)
}