// JavaScript Document

function getAjaxObject() {
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	
	return xmlhttp;
}

function processResponse(objResponse, responseProcedure, status) {
	try {
		//var strFixedText = strText.replace(/"/g, '\\"');
		//strFixedText = strFixedText.replace(/\r\n/g, "");
		//alert(strFixedText);
		eval(responseProcedure + '(objResponse,status)');
		//setTimeout(responseProcedure + '("' + strFixedText + '")', 1);
	}
	catch(ex) {
		alert('An unknown error occurred.');
	}
}

function getURL(URL, responseProcedure, blnReturnXML) {
	var xmlhttp = getAjaxObject();
	
	if (!xmlhttp) {
		processResponse('<div class="alert">An unknown error occurred.</div>', responseProcedure);
		return false;	
	}
	
	var cachekiller = Math.random() * 214748;
	
	if (URL.indexOf('?') > 0)
		var paramJoiner = '&';
	else
		var paramJoiner = '?';
	
	xmlhttp.open("GET", URL + paramJoiner + cachekiller,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			if (blnReturnXML)
				processResponse(xmlhttp.responseXML, responseProcedure, xmlhttp.status);
			else
				processResponse(xmlhttp.responseText, responseProcedure, xmlhttp.status);
		}
	}
	xmlhttp.send(null)
}

function postURL(URL, FormVars, responseProcedure, blnReturnXML) {
	var xmlhttp = getAjaxObject();
	
	if (!xmlhttp) {
		processResponse('<div class="alert">An unknown error occurred.</div>', responseProcedure);
		return false;	
	}
	
	var cachekiller = Math.random() * 2147483647;
	
	if (URL.indexOf('?') > 0)
		var paramJoiner = '&';
	else
		var paramJoiner = '?';
	
	xmlhttp.open("POST", URL + paramJoiner + cachekiller,true);

	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", FormVars.length);
	xmlhttp.setRequestHeader("Connection", "close");

	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			if (blnReturnXML)
				processResponse(xmlhttp.responseXML, responseProcedure, xmlhttp.status);
			else
				processResponse(xmlhttp.responseText, responseProcedure, xmlhttp.status);
		}
	}
	xmlhttp.send(FormVars)
}

