﻿var xmlHttp
var elementid;

// Usage onchange="showCustomer('div Id', 'Serverside page', this.value)"
// div id, The id of the element the data is returned to
// Serverside page, The name of the asp page run on the server excluding the extension .asp
// this.value, the value to be passed to the server page

function callAJAX(divid, page, str)
{ 
elementid = divid;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url=page;
url=url+"?"+str;
//url=url+"&query="+qry;
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById(elementid).innerHTML=xmlHttp.responseText;
}
/*else
{
document.getElementById(elementid).innerHTML='<img src=\'pleasewait.gif\'>';
}*/
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function displayelement(action, id)
{
	if (action == 'show')
	{
		document.getElementById("explanation"+id).style.display = "block";
		document.getElementById("link"+id).href= "javascript:displayelement('hide', "+id+")";
		document.getElementById("link"+id).innerHTML = "Close";
	}
	
	if (action == 'hide')
	{
		document.getElementById("explanation"+id).style.display = "none";
		document.getElementById("link"+id).href= "javascript:displayelement('show', "+id+")";
		document.getElementById("link"+id).innerHTML = "Add Comment";
	}
}


