	/**
	 * Purpose: Called when you need to make AJAX call for getting tool content
     * This method creates XMLHttpRequest object to communicate with the
     * servlet
     */
    function getTool(url, divID)
    {
		var httpRequest;
		//alert("getTool(): EPIC_adSection=" + EPIC_adSection+'----');
		if (window.ActiveXObject)
        {
            httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if (window.XMLHttpRequest)
        {
            httpRequest = new XMLHttpRequest();
        }
        
        re = '\\?';	
        myArray = url.match(re);
        
        if(EPIC_adSection!=''){
			if(myArray!=null && myArray.length>0)        	
				url=url+'&adsec='+EPIC_adSection;
        	else
        		url=url+'?adsec='+EPIC_adSection;
        }
        
        //HIGH LOAD POLL REMOVE
        if(url.indexOf("/poll/user.do") > 0)
        {
                //COMMENT IN THE FOLLOWING LINE TO DISABLE LIVE POLLS
                //return false;
        }
        //END: HIGH LOAD POLL REMOVE
        
        httpRequest.open("GET", url, true);
        httpRequest.onreadystatechange = function() {processRequest(divID, httpRequest); } ;
        httpRequest.send(null);
	}

	/**
     * This is the call back method
     * If the call is completed when the readyState is 4
     * and if the HTTP is successfull when the status is 200
     * update the toolSection DIV
     */
	function processRequest(divID, httpRequest)
	{
    	if (httpRequest.readyState == 4)
        {
        	//alert(httpRequest.status);
            if(httpRequest.status == 200)
            {
                //get the text sent by the url
                var toolText = httpRequest.responseText;
                //alert(toolText);

                //Update the HTML
                updateHTML(toolText, divID);
                
                //allow for callback hook for executing code after getTool completes
                if (typeof getToolHook == 'function') {
                    getToolHook();
                } 
            }
            else
            {
                //alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText);
            }
        }
	}

	/**
     * This function parses the XML and updates the
     * HTML DOM by creating a new text node is not present
     * or replacing the existing text node.
     */
    function updateHTML(toolText, divID)
    {
        // Get the reference of the DIV in the HTML DOM by passing the ID
        var toolSection = document.getElementById(divID);
        //alert("divID=" + divID); // + ", toolText=" + toolText);
		toolSection.innerHTML = toolText;
    }
