var XmlHttpObj;
function CreateXmlHttpObj(){
    try {
        XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
        try {
            XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc) {
            XmlHttpObj = null;
        }
    }
    if(!XmlHttpObj && typeof XMLHttpRequest != "undefined")
        XmlHttpObj = new XMLHttpRequest();
}

function sendAjaxRequest(url, callback){
    CreateXmlHttpObj();
    if( XmlHttpObj) {
        XmlHttpObj.onreadystatechange = callback;
        XmlHttpObj.open("GET", url,  true);
        XmlHttpObj.send(null);
    }
}

function GetInnerText (node){
    return (node.textContent || node.innerText || node.text) ;
}

function rtnSubCat(node_id){
 if (XmlHttpObj.readyState == 4)
  if (XmlHttpObj.status != 200) alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
    else {
        var data = XmlHttpObj.responseXML.documentElement;
	    var records = data.getElementsByTagName('record');
		var subCats = document.getElementById(node_id);
 	    for (var count = subCats.options.length-1; count >-1; count--)
            subCats.options[count] = null;
        var idValue = 0;
        var textValue = '';
        var optionItem = null;
        for(var count = 0; count < records.length; count++) {
		     idValue = records[count].getAttribute("id");
			 textValue = GetInnerText(records[count]);
		     optionItem = new Option(textValue, idValue, false, false);
		     subCats.options[subCats.length] = optionItem;
	    }
    }
}

