var ajaxRequest;
function addEvent(obj, evType, fn, useCapture){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else {
		alert("Handler could not be attached");
	}
}
function getEvent(e){
	if(!e){
		e = window.event;
	}
	return e;
}
function getElement(e){
	e = getEvent(e);
	if( e.target ){
		obj = e.target;
	}
	else{
		obj = e.srcElement;
	}
	return obj;
}
function getText(obj){
	if ('string' == typeof obj.textContent) return obj.textContent;
	if ('string' == typeof obj.innerText) return obj.innerText;
	return obj.innerHTML.replace(/<[^>]*>/g,'');
}
function setText(obj,text){
	if ('string' == typeof obj.textContent){
		obj.textContent = text;
	}
	else if ('string' == typeof obj.innerText){
		obj.innerText = text;
	}
}
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements);
}
function doAJAXRequest(requestURL, requestMethod, requestASync, requestData, requestHandler){
	if( requestURL == null || requestURL == "" ){
		return [false, "ERROR 7384-01: No URL specified.\nPlease contact the webmaster."];
	}
	else if(requestMethod != null && requestMethod.toUpperCase() != "POST" && requestMethod.toUpperCase() != "GET"){
		return [false, "ERROR 7384-02: Invalid method.\nPlease contact the webmaster."];
	}
	else if(requestASync == null || requestASync == "" ){
		return [false, "ERROR 7384-03: Syncronous not specified.\nPlease contact the webmaster."];
	}
	else if( requestMethod.toUpperCase() == "POST" && requestData == null ){
		return [false, "ERROR 7384-04: No post data specified.\nPlease contact the webmaster."];
	}
	
	if (window.XMLHttpRequest){ 
		ajaxRequest = new XMLHttpRequest();
	} 
	else{
		if (window.ActiveXObject){
			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else{
			return [false,"ERROR 7384-05: Unable to create XMLHTTP object."];
		}
	}
	
	requestMethod = requestMethod.toUpperCase();
	
	ajaxRequest.onreadystatechange = requestHandler;
	
	ajaxRequest.open(requestMethod, requestURL, requestASync);
	if( requestMethod == "POST" ){
		ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}
	ajaxRequest.send(requestData);
	return [true];
}
/*
function doAJAX(iURL, iMETHOD, iASYNC, iDATA){
	if( iURL != null && iMETHOD != null && iASYNC != NULL ){
		this.sURL = iURL;
		this.sMETHOD = iMETHOD.toUpperCase();
		this.sASYNC = iASYNC;
		if( iMETHOD.toUpperCase() == "POST" && iDATA == null ){
			this.sDATA = "";
		}
		else{
			this.sDATA = iDATA;
		}
	}
}
*/