
function getHTML(url, options)
{
	var xmlHttp = GetXmlHttpObject();
	
	if (!xmlHttp) {
		alert ("Browser does not support HTTP Request");
		return;
	} 
	
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange = function() { stateChanged(xmlHttp, options); };
	
	//xmlHttp.setRequestHeader("Content-Length",xmlHttp.Size);
	xmlHttp.setRequestHeader("Content-Type","text/html; charset=utf-8");
	xmlHttp.setRequestHeader('charset','utf-8');
		
	//alert(xmlHttp.getAllResponseHeaders());
	xmlHttp.send(null);		
	//alert(xmlHttp.getResponseHeader('Content-Type'));
	
}

function stateChanged(xmlHttp, options) 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		
		if (xmlHttp.status == 200) 
		{
			if (typeof options.callbackFunc == 'function') {
				options.callbackFunc(options, xmlHttp);
			} else {
				
				//default ajax function
				createElement(options, xmlHttp.responseText);
			}
		}
		else 
		{
		// error in here for failed http call
		}
		
		/*
		//xmlHttp.setRequestHeader('charset','UTF-8');
		//alert(xmlHttp.getAllResponseHeaders());
		
		var htmlTxt = xmlHttp.responseText;
		var htmlChange = document.getElementById(sWriteTo)
		//htmlChange.innerHTML = htmlTxt;  
		
		var wt = document.getElementById(sWriteTo);
	    
	    removeChildNodes(sWriteTo);
		
		var nd = document.createElement(sEle);
			
		nd.innerHTML=htmlTxt;		
		wt.appendChild(nd);	
		
		if (sWriteTo == 'office_list' || sWriteTo == 'office_list_pr' )
		{
			var pr = "";
			
			if (sWriteTo == 'office_list_pr')
			{
				var pr = "_pr" 
			}
			
			if (htmlTxt =="")
			{
				document.getElementById('office_list' + pr).style.visibility = "hidden";
			} else {
				document.getElementById('office_list' + pr).style.visibility = "visible";
			}
		}
		*/
	} 
} 


function createElement(options, htmlTxt)
{
	
	var wt = document.getElementById(options.element);
    
    removeChildNodes(options.element);
	
	var nd = document.createElement(options.nelement);
		
	nd.innerHTML=htmlTxt;		
	wt.appendChild(nd);	
	
}





function GetXmlHttpObject()
{ 
	var objXMLHttp = null;
	if (window.XMLHttpRequest) {
		objXMLHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	return objXMLHttp;
} 


function removeChildNodes(id)
{
	var cell = document.getElementById(id);
	if (cell && cell.hasChildNodes())
	{
		while ( cell.childNodes.length >= 1 )
		{
			cell.removeChild( cell.firstChild );       
		} 
	}
}




 