
// Define the global variables;

var xmlHttp=null;
var currDivId=null;
/*
#-------------------------------------------------------------------------------
#Function : create_xml_httpObject
#Desc : Create the http object instance and return to callng fun.
#Arguments : None
#Return : http object
#Example : create_xml_httpObject();
#-------------------------------------------------------------------------------
*/

function create_xml_httpObject()
{
// clear the xmlHTTP before initiailising new one
xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("No AJAX support in your browser!");

return false;
}
}
}
return xmlHttp;
}
/*
#-------------------------------------------------------------------------------
#Function : rd_srv_data
#Desc : this is the base call for all the div areas. this will get the
# response and update the corresponding div area.
#Arguments : divId, url
#Return : non
#Example : rd_srv_data('headerArea','cgi/index.pl');
#-------------------------------------------------------------------------------
*/
function rd_srv_data(divId,url)
{
if (url.length == 0) {
clearDiv(divId);
return ;
}
xmlHttp=create_xml_httpObject();
currDivId=divId;
xmlHttp.onreadystatechange=stateChanged;
// add bustcache to avoid caching problem in IE.
// every time this will create a random url
//var queryStrExist=url.indexOf("c")
//if (queryStrExist>=0) {
//var newUrl = url + '&bustcache=' + new Date().getTime();
//xmlHttp.open("GET",newUrl,true);
//} else {
var newUrl = url + '?bustcache=' + new Date().getTime();
xmlHttp.open("GET",newUrl,true);
//}

xmlHttp.send(null);
}




/*
#-------------------------------------------------------------------------------
#Function : stateChanged
#Desc : Get the response and put it in the inner html of global id.
#Arguments : None
#Return : None
#Example : stataChanged();
#-------------------------------------------------------------------------------
*/
function stateChanged()
{

if (xmlHttp.readyState==4)
{
//split thecontent with the seperator ~MRE~
var response = xmlHttp.responseText;
document.getElementById(currDivId).innerHTML=response;
}
}


/*
#-------------------------------------------------------------------------------
#Function : clearDiv
#Desc : Hide the given div by setting innerhtml to blank value.
#Arguments : divId
#Return : None
#Example : clearDiv();
#-------------------------------------------------------------------------------
*/
function clear_div(divId){
//alert(divId);
document.getElementById(divId).innerHTML="";
}


