var xmlHttp;
var rootpath;

rootpath = "http://www.investsmart.com.au/includes/ajax/";
//rootpath = "http://beta01.investsmart.com.au/includes/ajax/";

//**************************************************************************
function GetXmlHttpObject(handler)
{
    var objXmlHttp=null;

    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...");
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP";
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP";
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName);
            objXmlHttp.onreadystatechange=handler;
            return objXmlHttp;
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled");
            return;
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest();
        objXmlHttp.onload=handler;
        objXmlHttp.onerror=handler;
        return objXmlHttp;
    }
}

//**************************************************************************
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);
        }
      }
    }
}