var xmlHttp = null;


function loadURLtoDoc(url, openmethod, parms, eid, onready)
{ 
	var ame = this;
	ame.onready = function() {onready();};
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		// alert ("Browser does not support HTTP Request")
		// No xmlHttp
		return false;
	 }
	if (openmethod=="GET") {
		url = url + "?" + parms;
		xmlHttp.open("GET",url,true);
		parms = null;
	} else {	
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", parms.length);
//		xmlHttp.setRequestHeader("Connection", "close");
	}	
	xmlHttp.onreadystatechange=function() { 
		//if (!(eid=="")) {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
				if (writeDocbyid(eid)) { 
 					ame.onready();	
				}	
			} else {
				// still waiting
			} 
	//	}
		
	}
	xmlHttp.send(parms);
	return true;
}


function writeDocbyid(eid) 
{ 
	if (xmlHttp.status==200) { 
		odiv = document.getElementById(eid);
	 	odiv.innerHTML = "";
	 	odiv.innerHTML = odiv.innerHTML + '<div style="display:none; height:1px">&nbsp;</div>' + xmlHttp.responseText;
		return true;
	} else {
		return false;
	}	
}


function loadURLJSON(url, openmethod, parms, jasoncallback, onready)
{ 
	var ame = this;
	ame.onready = function() {onready();};
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		// alert ("Browser does not support HTTP Request")
		// No xmlHttp
		return false;
	 }
	if (openmethod=="GET") {
		url = url + "?" + parms;
		xmlHttp.open("GET",url,true);
		parms = null;
	} else {	
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", parms.length);
//		xmlHttp.setRequestHeader("Connection", "close");
	}	
	xmlHttp.onreadystatechange=function() { 
		//if (!(eid=="")) {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
				jasoncallback(xmlHttp.responseText);
				ame.onready();	
			} else {
				// still waiting
			} 
	//	}
		
	}
	xmlHttp.send(parms);
	return true;
}


function GetXmlHttpObject()
{
	if (xmlHttp==null) {
		try {
			 // Firefox, Opera 8.0+, Safari
		 	xmlHttp=new XMLHttpRequest();
		} catch (e) {
			 //Internet Explorer
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
	 	}
 	}	
	return xmlHttp;
}



	