var ajaxBustCache=true
var ajaxXMLDOM=null
var ajaxReturnMode=null
var ajaxHTTPRequest=null
var ajaxTargetObj=null
var ajaxTargetFunc=null

function ajax(iUri, iTarg, iFunc)
{
  ajaxHTTPRequest=null

  //Set the global variables
  if(iTarg==null)
  {
    ajaxReturnMode="FUNC"
    ajaxXMLDOM=null
    ajaxTargetFunc=iFunc
  }
  else
  {
    ajaxReturnMode="OBJ"
    ajaxTargetObj=iTarg
  }

  //If Mozilla, Safari etc
  if(window.XMLHttpRequest)
    ajaxHTTPRequest=new XMLHttpRequest()
  else if(window.ActiveXObject)
  {
    try
    {
      ajaxHTTPRequest=new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch(e)
    {
      try
      {
        ajaxHTTPRequest=new ActiveXObject("Microsoft.XMLHTTP")
      }
      catch(e) { }
    }
  }
  else
    return false

  ajaxHTTPRequest.onreadystatechange=function() { ajaxLoadPage() }

  //If bust caching of external page
  if(ajaxBustCache)
    iUri+=(iUri.indexOf("?")!= -1)?"&"+new Date().getTime():"?"+new Date().getTime()

  ajaxHTTPRequest.open("GET", iUri, true)
  ajaxHTTPRequest.send(null)
}

function ajaxLoadPage()
{
  if(ajaxHTTPRequest.readyState==4&&(ajaxHTTPRequest.status==200||window.location.href.indexOf("http")== -1))
  { 
    if(ajaxReturnMode=="FUNC")
      ajaxLoadXml(ajaxHTTPRequest.responseText)
    else
      document.getElementById(ajaxTargetObj).innerHTML=ajaxHTTPRequest.responseText
  }
}

function ajaxLoadXml(iText)
{
  //Code for IE
  if(window.ActiveXObject)
  {
    ajaxXMLDOM=new ActiveXObject("Microsoft.XMLDOM")
    ajaxXMLDOM.async=false
    ajaxXMLDOM.loadXML(iText)
  }
  //Code for Mozilla, Firefox, Opera, etc.
  else
    ajaxXMLDOM=(new DOMParser()).parseFromString(iText, "text/xml")

  eval(ajaxTargetFunc)
}