var httpRequest;

/**
* This method is called when the author is selected
* It creates XMLHttpRequest object to communicate with the
* servlet
*/
function getPage( querystring, cntr )
{
	//document.URL = 'index.php?id='+id;

    var url = querystring;

    if ( window.ActiveXObject )
    {
        httpRequest = new ActiveXObject( 'Microsoft.XMLHTTP' );
    } else if ( window.XMLHttpRequest )
    {
        httpRequest = new XMLHttpRequest();
    }

    httpRequest.open( 'GET', url, true );
    httpRequest.onreadystatechange = function() {processRequest( cntr ); } ;
    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 profileSection DIV
*/
function processRequest( cntr )
{
    if ( httpRequest.readyState == 4 )
    {
        if( httpRequest.status == 200 )
        {
            //get the XML send by the servlet
            var contentXML = httpRequest.responseXML.getElementsByTagName( 'content' )[0];

            //Update the HTML
            updateHTML( contentXML, cntr );
        } 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( contentXML, cntr )
{
    //The node valuse will give actual data
    var contentText = contentXML.childNodes[0].nodeValue;
//alert( contentText );
    //Create the Text Node with the data received
   // var content = document.createNode(contentText);

    //Get the reference of the DIV in the HTML DOM by passing the ID
    var contentCntr = document.getElementById( cntr );
    contentCntr.innerHTML = contentText;
}