/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

              
function callServer(offset,items_per_page,total_records,admin_mode) {

  
  document.getElementById('gbookdiv').innerHTML="<p align=center valign=top><B>Loading ...</B><BR><img border='0' src='images/loading3.gif'/></p>";  
 // effect.toggle('gbookdiv', 'slide', { delay: 0.1 });
 
  parameters='offset='+offset+'&items_per_page='+items_per_page+'&total_records='+total_records+'&admin_mode='+admin_mode;
  var url = 'phplibrary/gbook/gbookProvider.php?'+parameters;
  // var url='gogo.php';
  //document.getElementById('status-id').innerHTML=url;
  
  //$loading_code="<img border='0' src='images/loading3.gif'/>";
  //document.getElementById('status-id').innerHTML = $loading_code;
  
  
   /*
  if(xmlHttp==null)
    document.write("no http");    
  else 
  	document.write("yes http");
  */
  
  // Open a connection to the server
  xmlHttp.open("GET", url, true);
  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = updatePage;
  // Send the request
  xmlHttp.send(null);
  //getElementById("go").firstChild.nodeValue="$";
  
  /*
  var questionText=document.getElementById(selfid).firstChild.nodeValue;
  var tag=getNewTDTextNode(questionText);    	    	    
  while (document.getElementById('reply-question-tr').hasChildNodes())    	
  {
  			document.getElementById('reply-question-tr').removeChild(document.getElementById('reply-question-tr').firstChild);
  }
  document.getElementById('reply-question-tr').appendChild(tag);  
  */
  //document.getElementById('gbookdiv').innerHTML= document.getElementById('gbookdiv').innerHTML + '....';
}

function testr()
{
	document.write("you in");
}

function getNewTDTextNode(text)
{
	var tTag= document.createElement("td");
    var tTxt= document.createTextNode(text);
    tTag.appendChild(tTxt);
    return tTag;
}

function updatePage() 
{
	if (xmlHttp.readyState == 4) 
	{
		//document.getElementById('status-id').innerHTML="done";
		//document.getElementById('status-id').innerHTML ='';

    	//var tTag= document.createElement("td");
    	//var tTxt= document.createTextNode("now i get it");
    	//tTag.appendChild(tTxt);
    	
		//var cell = document.createElement("td");
        //var cellText = document.createTextNode("cell is row ");    	
        //cell.appendChild(cellText);
    	//document.getElementById('reply-tr').firstChild.nodeValue=response;
    	
    	var response =xmlHttp.responseText;    	
    	document.getElementById('gbookdiv').innerHTML='';
    	document.getElementById('gbookdiv').innerHTML=response;
    	/*
    	var response = xmlHttp.responseText;    	
    	var tag=getNewTDTextNode(response);    	    	    
    	while (document.getElementById('reply-tr').hasChildNodes())    	
    	{
    				document.getElementById('reply-tr').removeChild(document.getElementById('reply-tr').firstChild);
		}
		document.getElementById('reply-tr').appendChild(tag);
    	document.getElementById('status-td').firstChild.nodeValue=" ";
    	*/
    	//document.getElementById('reply-td').appendChild(cell);    	    	
    }
	else 
	{
		//document.getElementById('gbookdiv').innerHTML= document.getElementById('gbookdiv').innerHTML + '....';
	     //document.getElementById('status-id').innerHTML="not yet";
	    //document.getElementById('status-td').firstChild.nodeValue=document.getElementById('status-td').firstChild.nodeValue+'.';	
    }
	
}

function tests(say)
{
	document.getElementById('status-td').firstChild.nodeValue=say;
}
