function GetXmlHttpObject(handler)
{
   var objXMLHttp=null
   if (window.XMLHttpRequest)
   {
       objXMLHttp=new XMLHttpRequest()
   }
   else if (window.ActiveXObject)
   {
       objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
   }
   return objXMLHttp
}

function stateChanged()
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
           
           // Here is where we can parse the return text and modify the required selects
           var xmlstring = xmlHttp.responseText;
           var xmlDoc;
           var browserType;
           
           try //Internet Explorer
           {
                xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async="false";
                xmlDoc.loadXML(xmlstring);
                browserType = "IE";
           }
           catch(e)
           {
                parser=new DOMParser();
                xmlDoc=parser.parseFromString(xmlstring ,"text/xml");
                browserType = "FF";
          }
           
           var xmlobject = xmlDoc;
                     
           var rootNode = xmlobject.getElementsByTagName("smf")[0];
           
           // Get the array of child fields that need select data
           var childs = rootNode.getElementsByTagName('child');
           
           var child_id;
           var child_options;
           
           
           // Loop through the children and apply the select data
           
           // DOM version
           //var opt = document.createElement("option");
           //opt.innerHTML = "text of the option";
           //opt.value = "0";
           //document.getElementByID("mysel").appendChild(opt);
           
           for (var i = 0; i < childs.length; i++) {
                // Get the ID                
                child_id = childs[i].getElementsByTagName('id')[0].childNodes[0].nodeValue;
                          
                // Set the field options
                child_options = childs[i].getElementsByTagName('options')[0].childNodes[0].nodeValue;
                
                var fieldObj = document.getElementById("field_id_lov_" + child_id)
                
                
                //If the user has FireFox or some other browser:
                //document.getElementById(’SELECTLIST’).innerHTML = options;

                //If the user has Internet Explorer:
                //document.getElementById(’SELECTLIST’).outerHTML = “”+options+”"
                
                if(browserType == "FF") {
                    fieldObj.innerHTML= child_options;
                }
                else if(browserType == "IE") {
                    //fieldObj.innerHTML= ""+child_options+"";
                    //alert(document.getElementById("field_id_lov_" + child_id).outerHTML);
                    var theOuterHTML = document.getElementById("field_id_lov_" + child_id).outerHTML;
                    var theIndex = theOuterHTML.indexOf("<OPTION");
                    //alert(theIndex);
                    var selectHTML = theOuterHTML.substr(0, theIndex);
                    //alert(selectHTML);
                    document.getElementById("field_id_lov_" + child_id).outerHTML = selectHTML+child_options+"</select>";
                }
                
                
           } 
                 
           
   }
   else {
           //alert(xmlHttp.status);
   }
}

// Will populate data based on input
function htmlData(url)
{
   if (url.length==0)
   {
       document.getElementById("fieldjjjj_id_lov_3").innerHTML="";
       return;
   }
   xmlHttp=GetXmlHttpObject()
   if (xmlHttp==null)
   {
       alert ("Browser does not support HTTP Request");
       return;
   }

 
   
   //url=url+"?"+qStr;
   url=url+"&sid="+Math.random();
   xmlHttp.onreadystatechange=stateChanged;
   xmlHttp.open("GET",url,true) ;
   xmlHttp.send(null);
}

// This function used to dynamically size the database display table, since it will overflow sometimes
function gdbChangeWidth()
{
    var elem = document.getElementById("gdbDataDiv");
        
    var x = 0;
    if (self.innerHeight)
    {
            x = self.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
            x = document.documentElement.clientWidth;
    }
    else if (document.body)
    {
            x = document.body.clientWidth;
    }
    
    x = x * 0.835;
    
    elem.style.width =  x + "px";
        
}