<!-- $Revision: 1 $ $Workfile: td_dynamic_cnt.js $ -->

/*
Methods to make server side requests from client-side JavaScript 

Note: A call to sendAjaxRequest() needs implementation of parseResults(str) method.
*/

    function sendAjaxRequest(url, submitMethod, tagName, idName, param) {     
        var divs = document.getElementsByTagName(tagName);
        var qryStr = "";

        for (var i=0; i < divs.length; i++) {
            if(divs[i].id != idName) {
                continue;
            }
            
            if(qryStr == "") {
            	qryStr = param + '=' + divs[i].getAttribute(param);
            } else {
            	qryStr = qryStr + "&" + param + '=' + divs[i].getAttribute(param) ;
            }
        }
        
        //alert("QUERY:"+qryStr);

        try {
            http.open(submitMethod, url + qryStr, true);
            http.onreadystatechange = handleHttpResponse;
            http.send(null);
        } catch(e) {}
    }
    
        function getHTTPObject() {
	
	    var xmlhttp;
	    if(window.XMLHttpRequest) {
	        try {
	            xmlhttp = new XMLHttpRequest();
	        } catch (e) {}
	    } else if (window.ActiveXObject) {
	        try {
	            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {}
	    }
	
	    return xmlhttp;
	}
	
	function handleHttpResponse() {
	
	    if (http.readyState == 4) {
	        results = http.responseText;
	        parseResponse(results);
	        return null;
	    }
	}
	
	function getXmlDoc() {
		var xmldoc;
		if(window.ActiveXObject) {
			//IEXPLORE
			xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	
		} else if(document.implementation && document.implementation.createDocument) {
			//MOZILLA
			xmldoc = document.implementation.createDocument("", "", null);
	
			//add the loadXML() method to the Document class
			Document.prototype.loadXML = function(strXML) {
	
				//create a DOMParser
				var objDOMParser = new DOMParser();
	
				//create new document from string
				var objDoc = objDOMParser.parseFromString(strXML, "text/xml");
	
				//make sure to remove all nodes from the document
				while (this.hasChildNodes())
					this.removeChild(this.lastChild);
	
				//add the nodes from the new document
				for (var i=0; i < objDoc.childNodes.length; i++) {
	
					//import the node
					var objImportedNode = this.importNode(objDoc.childNodes[i], true);
	
					//append the child to the current document
					this.appendChild(objImportedNode);
	
				} //End: for
			} //End: function
	
			//^^function to add xml attribute to the document
			function _Node_getXML() {
	
				//create a new XMLSerializer
				var objXMLSerializer = new XMLSerializer;
	
				//get the XML string
				var strXML = objXMLSerializer.serializeToString(this);
	
				//return the XML string
				return strXML;
			}
			Node.prototype.__defineGetter__("xml", _Node_getXML);
		}
	    return xmldoc;
	}
	
var http = getHTTPObject(); // We create the HTTP Object	