
function myAjax()
{
	var xmlObj=null;
	var url="";
	var uiObjectID="";
	var uiLoadingObjectID="";
	var uiObjectProperty=""
	var EVAL=0;
	var INNERHTML=1;
	
	this.requestData=requestData;
	this.requestText=requestText;

	function xmlHttp_Get(xmlHttp, url)
	{
		xmlHttp.open('GET', url, true);
		xmlHttp.send(null);
	}

	function GetXmlHttpObject(handler)
	{
		var xmlHttp;
		if (window.ActiveXObject) 
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			xmlHttp.onreadystatechange = handler;
		}
		else if (window.XMLHttpRequest) 
		{
			xmlHttp = new XMLHttpRequest();
			xmlHttp.onreadystatechange = handler;
		}
		return xmlHttp;
	}
	 
	function loadInfo()
	{
		xmlObj=GetXmlHttpObject(showInfo);
		xmlHttp_Get(xmlObj,url);
	}
	 
	function showInfo()
	{
		if (xmlObj.readyState == 4 || xmlObj.readyState == 'complete')
		{
			var content = xmlObj.responseText;		
			if (content.indexOf("REDIRECT_LOGIN") == 0)
			{		
				//alert("Session Expired. Redirecting to Login Page!");
				window.location = "/SmsMela.UI/Login.aspx";		
			}
			else
			{													
				switch(uiObjectProperty)
				{
					case INNERHTML:																	   
						var oTable = document.getElementById(uiObjectID);																		
						oTable.innerHTML="";
						oTable.innerHTML=content;																		
						var loadingIndicator = document.getElementById(uiLoadingObjectID);
						loadingIndicator.style.display = "none";
						break;
						
					case EVAL:
						eval(uiObjectID);
						var loadingIndicator = document.getElementById(uiLoadingObjectID);
						loadingIndicator.style.display = "none";
						break;
						
					default:
						eval(content);
				}
			}
		}
	}

	//Facilities Functions
	function requestData(url1,uiObjectID1,uiLoadingObjectID1)
	{
		var loadingIndicator = document.getElementById(uiLoadingObjectID1);
		loadingIndicator.style.display = "block";
	    
		url=encodeURI(url1);
		uiObjectID=uiObjectID1;
		uiLoadingObjectID=uiLoadingObjectID1;
		uiObjectProperty=INNERHTML;
		loadInfo();
	}
	
	function requestText(url1,uiObjectID1,uiLoadingObjectID1)
	{
		var loadingIndicator = document.getElementById(uiLoadingObjectID1);
		loadingIndicator.style.display = "block";
	    
		url=encodeURI(url1);
		uiObjectID=uiObjectID1;
		uiLoadingObjectID=uiLoadingObjectID1;
		uiObjectProperty=EVAL;
		loadInfo();
	}
}