var xmlHttp;
var rootpath;

rootpath = "/includes/ajax/";

//**************************************************************************
function GetXmlHttpObject(handler)
{
	var xmlhttp=null;
	if (window.XMLHttpRequest) // Most major browsers, screws up in IE though
	{
		if (navigator.userAgent.indexOf("MSIE") >= 0) // IE specific
		{
			objXmlHttp=new ActiveXObject("MSXML2.XMLHTTP.6.0");
			objXmlHttp.onreadystatechange=handler;
			return objXmlHttp;
		}
		else
		{
			xmlhttp=new XMLHttpRequest();
			xmlhttp.onload=handler;
			xmlhttp.onerror=handler;
			return xmlhttp;
		}
	}
	else // Older IE
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.onreadystatechange=handler;
        return xmlhttp;
	}
}

//**************************************************************************
function stateChangedUpdateInnerHTML(strElementID)
{

  //+++ Show a "Retrieving Content" message +++
  //alert(document.getElementById(strElementID).innerHTML);
  if(document.getElementById(strElementID).innerHTML != '<center><img src="/images/icon_processing_small.gif" border="0">&nbsp;Loading...</center>')
    {
    document.getElementById(strElementID).innerHTML = '<center><img src="/images/icon_processing_small.gif" border="0">&nbsp;Loading...</center>';
    }

  if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    if(xmlHttp.responseText != "")
      {
      document.getElementById(strElementID).innerHTML = xmlHttp.responseText;
      }
    }
}

//**************************************************************************
function stateChangedUpdateSelectList(strElementID)
{

  //+++ Show a "Retrieving Data" message +++
  if(document.getElementById(strElementID).options[0].value != "RETRIEVING")
    {
    //+++ Clear all the options in the drop down list +++
    document.getElementById(strElementID).length = 0;
    document.getElementById(strElementID).options[0] = new Option("Retrieving data...","RETRIEVING");
    document.getElementById(strElementID).options[0].style.color="#FF0000";
    }


  if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    //+++ Clear all the options in the drop down list +++
    document.getElementById(strElementID).length = 0;
    if(xmlHttp.responseText != "")
      {
      //+++ Eval the JSON into an array +++
      var arryTemp = eval(xmlHttp.responseText);
      //+++ Loop through the array and add the options +++
      for(var i=0;i<arryTemp.length;i++)
        {
        document.getElementById(strElementID).options[i] = new Option(arryTemp[i].label,arryTemp[i].value);
        }
      }
    }
}
