//************************************************************************
 function getXMLObject()  //XML OBJECT
{
   var xmlHttp = false;
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   }
   catch (e) {
     try {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
     }
     catch (e2) {
       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
     }
   }
   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   }
   return xmlHttp;  // Mandatory Statement returning the ajax object created
}
//************************************************************************
function _ajax() {
	this._post = function(id,url,parameters,waiting_object) {
		var xmlhttp = new getXMLObject(); //xmlhttp holds the ajax object
		var date = new Date();
		var timestamp = date.getTime();
		xmlhttp.abort();
		if(url.indexOf("?")==-1)url=url+"?";
		var RequestURL=url + "&time=" + timestamp;
		if(xmlhttp) { 
			xmlhttp.open("POST",RequestURL,true); //getname will be the servlet name
			xmlhttp.onreadystatechange=function() {
				 if (xmlhttp.readyState == 4) {
				 if(xmlhttp.status == 200) {
						 document.getElementById(id).innerHTML = xmlhttp.responseText;
				 }else {
					alert("Error during AJAX call. Please try again");
				 }
			}
			 if(xmlhttp.readyState == 1|| xmlhttp.readyState=="complete")
			 document.getElementById(id).innerHTML = waiting_object;
		  }
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.send(parameters); //Posting txtname to Servlet
		}
	}
	//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
	this._get=function(id,url,waiting_object){ 
		 var xmlhttp = new getXMLObject(); //xmlhttp holds the ajax object
		 var date = new Date();
		var timestamp = date.getTime();
		xmlhttp.abort();
		if(url.indexOf("?")==-1)url=url+"?";
		var RequestURL=url + "&time=" + timestamp;
		// Create a function that will receive data sent from the server 
		xmlhttp.onreadystatechange = function(){ 
			//This if satement will check if the status of the script 
			//If the readyState is not equal to 4 (The request is complete) 
			//It will display text that says loading... 
			if(xmlhttp.readyState < 4){ 
				//AJAX in the prenthacies, is what id element in the body will be changed. 
				document.getElementById(id).innerHTML = waiting_object; 
			} 
			//Once the readyState is equal to four, this means that the request was sent, 
			//and successfully processed. 
			if(xmlhttp.readyState == 4){ 
				//This is where the output of the file we called and it will be placed 
				//in the div where we named the ID = AJAX 
				document.getElementById(id).innerHTML = xmlhttp.responseText; 
			} 
		} 
		//This section processes the data 
		xmlhttp.open("GET", RequestURL, true); 
		xmlhttp.send(null);     
	} 

	//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
	this._return_value=function(id,url,waiting_object){
		var xmlhttp = new getXMLObject(); //xmlhttp holds the ajax object
		var date = new Date();
		var timestamp = date.getTime();
		if(url.indexOf("?")==-1)url=url+"?";
		var RequestURL=url + "&time=" + timestamp;
		xmlhttp.onreadystatechange=function() {
			if(document.getElementById(id)!=null)
			if(xmlhttp.readyState < 4){ 
				document.getElementById(id).innerHTML = waiting_object; 
			} 
					if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete"){
							return xmlhttp.responseText;
					}
			  }
			xmlhttp.open("GET",RequestURL,false);
		xmlhttp.send(null);
	return xmlhttp.responseText;
	}
	this.just_return_value=function(url,waiting_object){
		var xmlhttp = new getXMLObject(); //xmlhttp holds the ajax object
		var date = new Date();
		var timestamp = date.getTime();
		if(url.indexOf("?")==-1)url=url+"?";
		var RequestURL=url + "&time=" + timestamp;
		xmlhttp.onreadystatechange=function() {
			 if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete"){
					return xmlhttp.responseText;
				}
			 }
			xmlhttp.open("GET",RequestURL,false);
		xmlhttp.send(null);
	return xmlhttp.responseText;
	}
}


 
