// JavaScript Document
function AJAXRequest(php_source, field, value, type, div) {

	try {
	  request = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
		request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				 request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
				   request = false;
			}  
		}
   }
   
	//Used for multiple URL variables and values
	var myString = new String(field);
	var field_name = myString.split(':');
	var url = "";
	
   if(value == ''){ //use this section for form values
		
		for (i=0; i < field_name.length; i++) {

			var the_value = document.getElementById(field_name[i]).value
			parameter = field_name[i] + '=' + the_value;
			//alert("Perfect Penguin Test " + the_value);
		
			//Create the url including the query string
			if(url == ""){
				url += php_source + "?" + field_name[i] + "=" + escape(the_value);
			}
			else{
				url += "&" + field_name[i] + "=" + escape(the_value);
			}
		}	
   }
   else{ //This this section for posting a static value
		var myString2 = new String(value);
		var field_value = myString2.split(':');
		
		for (i=0; i < field_name.length; i++) {
			var the_value = field_value[i]
			parameter = field_name[i] + '=' + the_value;			

			//Create the url including the query string
			if(url == ""){
				url += php_source + "?" + field_name[i] + "=" + escape(the_value);
			}
			else{
				url += "&" + field_name[i] + "=" + escape(the_value);
			}
		}
   }
   
	//Set the global varible divName which assigns the div/span name to use
	divName = div;
	// send the request to display_results
	request.onreadystatechange = display_results;
	
	// Check whether it is a post or get method
	if(type == 'POST'){
		request.open('POST', url, true);
		request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		request.send(parameters);
	}
	if(type == 'GET'){
		request.open('GET', url, true);
		request.send(null);
	}	
}
//-->
function display_results() {
	//alert("entering responce()");
		  if (request.readyState == 4) {
			  //alert("ready state = 4");
			 if (request.status == 200) {
				 //alert("request state = 200");
				var response = request.responseText;
				document.getElementById(divName).innerHTML = response;   
			 } else {
				//alert('There was a problem with the request.');
				//removed as there was a problem with MSS site and the error logging
			 }
		  }
		  else{
			//alert("connection busy");
			setTimeout('display_results()',300);
		  }
}