// Browser Support Code.
// Checks for type of browser and sets appropriate XMLHTTP.
function browserTest(){
   try{
   	// Opera 8.0+, Firefox, Safari
   	return (new XMLHttpRequest());
   } catch (e){
   	// Internet Explorer Browsers
   	try{                           
   		return (new ActiveXObject("Msxml2.XMLHTTP"));
   	} catch (e) {
   		try{
   			return (new ActiveXObject("Microsoft.XMLHTTP"));
   		} catch (e){
   			// None compatible browser
   			alert("Your browser is not compatible!");
   			return false;
   		}
   	}
   }
}
  
// Processes links and forms.
// processajax(destination page, get/post, string to send,viewtoupdate)  
function processajax(serverPage,getOrPost,str,viewlocation){
   // Set the window to be used to display results.
   var ajaxDisplay = document.getElementById(viewlocation);
   // Create and assign a appropriate XMLHTTP request by using browserTest function.   
   if (ajaxDisplay != null){
	   xmlhttp = browserTest();
	   // If sent link is a get method.
	   if (getOrPost == "get"){
		  // Open destination page using xmlhttp.
		  xmlhttp.open("GET",serverPage,true);
		  xmlhttp.onreadystatechange = function(){
			 if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
				// If ready display response in window set earlier.
				ajaxDisplay.innerHTML = xmlhttp.responseText;
			 }
		  }
		  // Sends the request.
		  xmlhttp.send(null);
	   } else {
		  // Open destination page using xmlhttp.
		  xmlhttp.open("POST", serverPage, true);
		  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		  xmlhttp.onreadystatechange = function(){
			 if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
				// If ready display response in window set earlier.
				ajaxDisplay.innerHTML = xmlhttp.responseText;
			 }
		  }
		  // Sends the request.
		  xmlhttp.send(str);
	   }
   }
}