var CurrentData = "";
if (location.href.indexOf("?")>0) { CurrentData = location.href.split("?")[1]; }


function LoadContent(Data) {
  XmlHttpReq(Data);
}


function PutIFrameContent() {
  if (document.getElementById("content") && parent.frames["remoteHttp"]) {
    if (parent.frames["remoteHttp"].document.body.innerHTML!="") {
      document.getElementById("content").innerHTML = parent.frames["remoteHttp"].document.body.innerHTML;
    }
  }
}


function XmlHttpReq(Data) {
  CurrentData = Data;
  var r = XmlHttpObj();
  if (r) {
    r.open("GET","/content_ajax.asp?"+Data,true);
    r.setRequestHeader("Content-type","text/html");
    r.setRequestHeader("Content-length",Data.length);
    r.setRequestHeader("Connection","close");
    r.onreadystatechange=function() {
      if(r.readyState==4) {
        var txt = r.responseText;
        if (r.status==200) {
          if (txt!="") {
            document.getElementById("content").innerHTML = txt;
            window.focus();
          } else {
            location.href = "/content.asp?"+Data;
          }
        } else {
          if (txt && txt.indexOf("<!--Problem-->")>0) {
            alert(txt.split("<!--Problem-->")[1]);
          } else {
            location.href = "/content.asp?"+Data;
          } 
        }
      }
    }
    r.send(null);
  } else {
    // IFrame method
    document.getElementById("remoteHttp").src = "/content_ajax.asp?"+Data;
  }
}


function XmlHttpObj() {
  // Retrieves an XMLHttpRequest/MS XMLHTTP object
  if (window.XMLHttpRequest) {
    // Branch for native XMLHttpRequest object
    try {
      return new XMLHttpRequest();
    } catch(e) {
      return null;
    }
  } else if (window.ActiveXObject) {
    return null;
    // Branch for IE/Windows ActiveX version
    /*
    try {
      return new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try { 
        return new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        return null;
      }
    }
    */
  }
}
