//AJAX LIBRARY BY RAMKRISHNA

var AjaxErrorTrace=false;

function AjaxObj()
{
	var CallBack,HTTPRequest,ErrorTrace;
	HTTPRequest=false;
	if (window.XMLHttpRequest)//  Mozilla, etc.
		HTTPRequest = new XMLHttpRequest();
	else if (window.ActiveXObject)// IE
	{ 
		try 
		{
            HTTPRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } 
		catch (e) 
		{
            try
			{
               HTTPRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } 
			catch (e) 
			{
				if(AjaxErrorTrace)
					ShowError(e);
			}
        }
	}
	this.LoadData=function(URL,fCallBack)
	{	
		ShowPleaseWait();
		CallBack=fCallBack;
		HTTPRequest.open("GET",URL,true);
		HTTPRequest.onreadystatechange=this.LoadComplete;
		HTTPRequest.send(null);
	}

	this.PostData=function(URL,fCallBack,Data)
	{
		ShowPleaseWait();
		CallBack=fCallBack;
		HTTPRequest.open("POST",URL,true);
		HTTPRequest.onreadystatechange=this.LoadComplete;
		HTTPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      	HTTPRequest.setRequestHeader("Content-length", Data.length);
      	HTTPRequest.setRequestHeader("Connection", "close");
		HTTPRequest.send(Data);
	}
	
	this.LoadComplete=function()
	{	
		if (HTTPRequest.readyState==4)// load complete
		{	
			HidePleaseWait();
			if (HTTPRequest.status==200)
			{	
				if(CallBack!=null)
					CallBack(HTTPRequest.responseText);
			}
			else
			{
				if(AjaxErrorTrace)
					ShowError(HTTPRequest.responseText);

				return null; // Error Occured
			}
		}
	}
	
	if (!HTTPRequest)
	{	
		if(AjaxErrorTrace)
			ShowError("Can't create XMLHTTPRequest object.");
		else
			alert("Ajax is not supported in this browser.");
			
		return false;
	}
	else
		return this;
}

document.write('<div id="AjaxPleaseWait" style="position: absolute; z-index: 1000; visibility: hidden; font-family:Tahoma, Arial, Helvetica, sans-serif; font-size:11px; color:#660066; font-weight:bold; border:1px solid #000000; padding:10px; width:130px; background-color:#EFF3F5;" >&nbsp;&nbsp; Please wait...</div>');
document.write('<div id="AjaxError" style="position: absolute; z-index: 1000; height:515px; width:500px; visibility: hidden; font-family:Tahoma, Arial, Helvetica, sans-serif; font-size:11px; color:#660066; font-weight:bold; border:1px solid #000000; background-color:#77ddee;" >'+
			   '<div style="background:#00FF99; height:15px; text-align:right; padding:5px;" ><a href="javascript:HideError();">Close</a> </div>'+
  				'<div id="AjaxErrorMessage" style="height:500px; background:#FFFFFF; overflow:scroll;"></div></div>');

var PleaseWait = document.getElementById("AjaxPleaseWait");
var ErrorDiv   = document.getElementById("AjaxError");

function HidePleaseWait(){
	
	if (PleaseWait)
		PleaseWait.style.visibility="hidden";
}

function ShowPleaseWait(){
	if (PleaseWait)
	{	
		var DocHeight = document.body.clientHeight;
		var DocWidth = document.body.clientWidth;
		PleaseWait.style.visibility="visible";
		PleaseWait.style.left=document.body.scrollLeft+((DocWidth/2)-(PleaseWait.offsetWidth/2));
		PleaseWait.style.top=document.body.scrollTop+((DocHeight/2)-(PleaseWait.offsetHeight/2));
	}
}
function ShowError(ErrorText){
	if (ErrorDiv)
	{	
		var DocHeight = document.body.clientHeight;
		var DocWidth = document.body.clientWidth;
		document.getElementById("AjaxErrorMessage").innerHTML=ErrorText;
		ErrorDiv.style.visibility="visible";
		ErrorDiv.style.left=document.body.scrollLeft+((DocWidth/2)-(ErrorDiv.offsetWidth/2));
		ErrorDiv.style.top=document.body.scrollTop+((DocHeight/2)-(ErrorDiv.offsetHeight/2));
	}
}
function HideError(){
	if (ErrorDiv)
		ErrorDiv.style.visibility="hidden";
}