/*
    ajax.js
    :  functions relevant to ajax calls
    :  Brett C. Zabos
    :  2007
*/

/***************************************
 * Function getXMLRefObject
 * Purpose	This routine will just proceed to get a reference (if it can)
 * 		to the XMHHTTPResponse Object
 *************************************/
 function getXMLRefObject()
 {
	var obXHR = null;

	if ( window.XMLHttpRequest )
	{
		obXHR = new window.XMLHttpRequest();
	}
	else
	{
		//  internet explorer
		if (window.ActiveXObject)
		{
			obXHR = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return obXHR;
}


/***************************************
 * Function 	getXMLHTTPRequestText
 * Purpose	retrieve text from spec'd url using get proto
 *************************************/
 function getXMLHttpRequestText( sURL, fCallBack )
 {
	obXHR = getXMLRefObject();
	
	if( obXHR )
	{
		obXHR.open( "GET", sURL );
		obXHR.onreadystatechange =
		function()
		{
			if( obXHR.readyState == 4 && obXHR.status == 200 )
			{
				if( fCallBack ) 
                { 
                    fCallBack( obXHR.responseText );
                }
				delete( obXHR );
			}
		}
        
		obXHR.send( null );
	}
 }
/***************************************
 * Function 	getXMLPOSTHTTPRequestText
 * Purpose	retrieve posrt text from spec'd url using get proto
 *************************************/
 /*
 function getXMLHttpRequestText( sURL, fCallBack, sArgs )
 {
	obXHR = getXMLRefObject();
	
	if( obXHR )
	{
		obXHR.open( "POST", sURL );
		obXHR.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
		obXHR.onreadystatechange =
    		function()
    		{
    			if( obXHR.readyState == 4 && obXHR.status == 200 )
    			{
    				fCallBack( obXHR.responseText );
    				delete( obXHR );
    			}
    		}
		
		obXHR.send( sArgs );
	}
 }
*/


