function createREQ() {
	try {
		req = new XMLHttpRequest(); /*e.g Firefox */
	} catch(err1) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			/* Some versions IE */
	  	} catch (err2) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
				/* Some versions IE */
				} catch (err3) {
		  			req = false;
				} 
	  	} 
	}
	return req;
}


function requestGET(url, query, req) {
	myRand=parseInt(Math.random()*99999999);
	req.open("GET",url+'?'+query+'&rand='+myRand,true);
	req.send(null);
}

function requestPOST(url, query, req) {
	req.open("POST", url,true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	req.send(query);
}

function doCallback(callback,item) {
	eval(callback + '(item)');
	//description = "<p></p>"; // Take note to make this dynamic //--Uncomment when fixed for production
	initLightbox();
}
var divisionID = '';
function doAjax(url,query,callback,reqtype,getxml,divisionID) { //used to call small texts same as doAjax(params)
	//create the XMLHTTPRequest object instance
	var myreq = createREQ();
	myreq.onreadystatechange = function() {
		if(myreq.readyState == 4) {
			if(myreq.status == 200) {
				var item = myreq.responseText;
				if(getxml==1) {
					item = myreq.responseXML;
				}
				doCallback(callback, item);
			}
		} else { // lets tell the user that something's happening
			document.getElementById(divisionID).innerHTML = '<p>&nbsp;</p><p>&nbsp;</p>&nbsp;&nbsp;<br /><div align ="center"><img src="ajax/loading.gif"></div>'; // we want animation to appear on the main division in the left screen
		}
	}
	
	if(reqtype=='post') {
		requestPOST(url,query,myreq);
	} else {
		requestGET(url,query,myreq);
	}
}
	// Left Divisions
	//
    // showtime
	// flash
	// leftHeadingAjaxableID
	
	// Right Divisions
	//
	// showSetRightTextID
	// showsetRightHeadingID
	
// For Wise Erase Feature as well as for overlapping CSS divisions
function doWiseAjax(url,query,callback,reqtype,getxml, userFeedBack, erase) { //used to call small texts same as doAjax(params)
	//userFeedBack is the returnd CSS division ID from the calling doCallBack()
	//create the XMLHTTPRequest object instance
	var myreq = createREQ();
	myreq.onreadystatechange = function() {
		if(myreq.readyState == 4) {
			if(myreq.status == 200) {
				var item = myreq.responseText;
				if(getxml==1) {
					item = myreq.responseXML;
				}
				doCallback(callback, item);
			}
		} else { // lets tell the user that something's happening
			if (userFeedBack == 'showtime') {
				document.getElementById(userFeedBack).innerHTML = '<p>&nbsp;</p><p>&nbsp;</p>&nbsp;&nbsp;<br /><div align ="center"><img src="ajax/loading.gif"></div>'; // we want animation to appear on the main division in the left screen
			} else {
				document.getElementById(userFeedBack).innerHTML = '<img src="ajax/loading.gif" hspace="10">';
			}
		}
	}
	
	if(reqtype=='post') {
		requestPOST(url,query,myreq);
	} else {
		requestGET(url,query,myreq);
	}
}