﻿// ---------- General AJAX API ------------
var xmlHttp;
/**
 * This function initializes the xmlHttp global variable.  Applies a singleton
 * design pattern approach to this object.
 */
function initxmlHttp() {
	try {
		xmlHttp = new ActiveXObject("Mxsml2.XMLHTTP");
	}
	catch(e) {
		try {
			xmlHttp = new XMLHttpRequest();
		}
		catch(e) {
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {
				alert("Browser does not support AJAX!");
				return false;
			}
		}
	}
}

/**
 *	Performs an ajax call passing the input parameter as the POST request.
 */
function ajaxpost(url, parameters, cbFunction) {
	// initialize a new xmlHttp object
	initxmlHttp();
	
	// define Ajax callback function
	xmlHttp.onreadystatechange = cbFunction;
		
	// open POST connection
	xmlHttp.open("POST", url, true);
	
	// define POST headers
	parameters = parameters + "&rndm=" + Math.random * 99999999;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	
	// send Ajax call
	xmlHttp.send(parameters);
}
/**
 *	Performs an ajax call passing the input parameter as a GET request.
 */
function ajaxget(url, parameters, cbFunction) {
	// initialize a new xmlHttp object
	initxmlHttp();
	
	// define Ajax callback function
	xmlHttp.onreadystatechange = cbFunction;
		
	// open GET connection
	parameters = parameters + "&rndm=" + Math.random * 99999999;
	xmlHttp.open("GET", url + "?" + parameters, true);
	xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	
	// send Ajax call
	xmlHttp.send(parameters);
}



//  ----------------  END General AJAX functions -------------------


/**
 	Convinence call back function to write the output from /osr/scripts/display.asp
	into the division specified
	
	Param id - id of the division to wirte the ouput of the script to
*/
function display_opportunities() {
	var div = document.getElementById("opportunities");
	if (xmlHttp.readyState == 4 && xmlHttp.responseText.length > 0) {
		div.innerHTML = xmlHttp.responseText;
	}
}






























