function createXMLHttpRequest( )
{
	var ua;
	if( window.XMLHttpRequest )
	{
		try
		{
			ua = new XMLHttpRequest( );
		}

		catch( e )
		{
			ua = false;
		}

	}
	else if( window.ActiveXObject )
	{
		try
		{
			ua = new ActiveXObject( "Microsoft.XMLHTTP" );
		}

		catch( e )
		{
			ua = false;
		}
	}
	return ua;
}

var req = createXMLHttpRequest( );

function sendRequest( page )
{
	req.open( 'get', page + '&rand=' + Math.random( ) );
	req.onreadystatechange = handleResponse;
	req.send( null );
}

function setSessionVariables( page )
{
	req.open( 'get', page + '&rand=' + Math.random( ) );
	req.send( null );
	return true;
}

function sendData( params )
{
	/* Store form data so we can pass it to the server. */
	req.open( 'post', window['phppage'] );
	req.onreadystatechange = handleResponse;

	/* Specify that the body of the request contains form data. You must
	** do this for the POST method. I think this has to come after the "open" call.
	*/
	req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );

	/* For a GET, the "send" arguments are null. For a POST, you’d add
	** a string containing the data you want to pass to the server, like below.
	** I note this here because I spent a good hour or so trying to
	** figure out why my script wasn’t working, only to realize I was trying
	** to pass these arguments in the "open" function…!
	** Note the use of the amphersand (&) between arguments.
	*/
	req.send( params );
}


function handleResponse( )
{
	if( req.readyState == 4 )
		RespondeOutput( req.responseText );
}
