
function createXMLHttpRequest(id)
{
  try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
  try { return new XMLHttpRequest(); } catch(e) {}
  $(id).innerHTML="<hr>Warning - Your browser either has javascript switched off or does not support AJAX !<br>This page will not display properly<hr>";
  return null;
}

function $(id) 
{
  if( document.getElementById ) 
    // this is the way the standards work
    return document.getElementById( id );  
  else if( document.all ) 
    // this is the way old msie versions work
    return document.all[id];  
  else if( document.layers ) 
    // this is the way nn4 works
    return document.layers[id]; 
}

function getPage(str, id, addQs)
{ 
  var xhr= createXMLHttpRequest(id);

  xhr.onreadystatechange = function () 
  {
    switch (xhr.readyState)
    { 
      //case 0: $("response").innerHTML = "Reading page..."; break;
      //case 1: $("response").innerHTML += "<br>Response 1"; break;
      //case 2: $("response").innerHTML += "<br>Response 2"; break;
      //case 3: $("response").innerHTML += "<br>Response 3"; break;
      case 4: 
      {
        // request finished
        //$("response").innerHTML += "Server has responded.";
        //$("container").innerHTML += xhr.responseText;
        if (xhr.status==200) 
        {
          //$("response").innerHTML = "Server has responded.";
          //alert("Server has responded.");
          $(id).innerHTML = xhr.responseText;
          return null;
        }
      }  
      //default: 
      //{
      //  $("response").innerHTML = "Server has responded,  but with an error.";
      //}
    }
  }
  var url="/server/getpage.asp";
  url=url+"?page="+str;
  url=url+"&sid="+Math.random();
  url=url+addQs;
  //xhr.onreadystatechange=stateChanged;
  xhr.open("GET",url,true);
  xhr.send(null);
  
}

function goPage(url)
{
   window.location.href = url;
}
