// JavaScript Document
function GET_XMLHTTPRequest()
{
    var request;
    
    // Lets try using ActiveX to instantiate the XMLHttpRequest object
    try{
        request = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(ex1){
        try{
            request = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(ex2){
            request = null;
        }
    }

    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest 
    if(!request && typeof XMLHttpRequest != "undefined"){
        //The browser does, so lets instantiate the object
        request = new XMLHttpRequest();
    }

    return request;
}

function show_result(elem,data,param)
{
    //Instantiate a new XMLHttpRequest object
    var myXMLHttpRequest = GET_XMLHTTPRequest();
    //var img1 = new Image();
	//img1.src = "http://www.eisforeffort.com/images/ajax-loader2.gif";

    //Make sure the XMLHttpRequest object was instantiated
    if (myXMLHttpRequest)
    {
        //Tell the XMLHttpRequest object what we want it to do.
        //In the first parameter we're telling it to use HTTP GET for the request
        //In the second parameter we're telling it what page to request
        //In the third parameter we're telling it to do the request asychronously
        myXMLHttpRequest.open("POST", data, true);
		myXMLHttpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        
        //Lets define the method that gets called when the request finishes
	    myXMLHttpRequest.onreadystatechange = function () {
	        //Any time the readyState of the XMLHttpRequest object changes this method is called.
	        //Loading is complete when the readyState equals 4, so that's the only value we care about right now.
    	if(myXMLHttpRequest.readyState == 1){
			
			document.getElementById(elem).innerHTML = "<img src='images/ajax-loader.gif' style='margin-top: 50px; margin-left: 90px;'>";
			//document.getElementById(elem).appendChild(img1);
		
		}else if(myXMLHttpRequest.readyState == 4 && myXMLHttpRequest.status == 200){
    		    //Sweet! The page loaded. Now lets set the contents of the request to the TextArea
        		document.getElementById(elem).innerHTML = myXMLHttpRequest.responseText;
		    }
	    };
	    
	    //Lets fire off the request
        myXMLHttpRequest.send(param);
    }
    else
    {
        //Oh no, the XMLHttpRequest object couldn't be instantiated.
        alert("A problem occurred instantiating the XMLHttpRequest object.");
    }
}