// xmlhttp.js

// create an xmlhttp object

function getxmlhttp(){
	//boolean variable to check for a valid MS activex instance
	var xmlhttp = false;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		catch (E) {
			xmlhttp = false;
			}
		}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
		}
	return xmlhttp;
	}

// function to process an XMLHttpRequest

function processajax (serverPage, obj, getOrPost, str){
	// get object

	xmlhttp = getxmlhttp();
	if (getOrPost == "get")
		{
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() 
			{
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById(obj).innerHTML = xmlhttp.responseText;
				}
			}	
		xmlhttp.send(null);
		}
	else
		{
		//alert(serverPage+' ' +obj+ ' '+ str);
		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)
				{
				document.getElementById(obj).innerHTML = xmlhttp.responseText;
				}
			}
		xmlhttp.send(str);
		}
	}

	//Function to process an XMLHttpRequest. for scheduling speakers
	function processajax_sched (serverPage, obj, getOrPost, str){
		//Get an XMLHttpRequest object for use.
		xmlhttp = getxmlhttp ();
		if (getOrPost == "get"){
			xmlhttp.open("GET", serverPage);
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
		} else {
			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) {
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(str);
		}
	}