function objXHR()
{ // scan the function clicked and act on it using the Ajax interthingy
	var url; // URL to send HTTP requests to
	var timer; // timer for timing things
	var XHR; // XMLHttpRequest object
	var xmlDoc; // object for requesting XML documents from the server
	var xmlIEFlag; // linked to xmlDoc, this discerns between IE and the better browser XML implementations
	var _responseXML; // holds XML formed responses from the server
	var _responseText; // holds any textual response from the server
	var request; // associative array to hold requests to be sent
	var additional; // additional settings in an associative array
	
	// vars added in addition to base vars
	var session_id; // current customer session ID
	
	this.request = new Array();
	this.additional = new Array();
	this.createXHR();
}

objXHR.prototype.xmlDoc = function() {
	this.xmlDoc = false;
	if (document.implementation && document.implementation.createDocument)
	{ // decent browser
		this.xmlDoc = document.implementation.createDocument("", "", null);
		this.xmlIEFlag = false;
	} else if (window.ActiveXObject) { // crappy IE
		this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		this.xmlIEFlag = true;
	} else { // hmm... no XML request support
		this.xmlDoc = false;
	}
	xmlDoc.async = false;
}

objXHR.prototype.createXHR = function () { // this code has been modified from the Apple developers website
	this.XHR = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) { // decent, normal, law abiding browsers
    	try { // make sure the object can be created
			this.XHR = new XMLHttpRequest();
        } catch(e) { // it can't
			this.XHR = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) { // this does stuff too
       	try {
        	this.XHR = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		this.XHR = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		this.XHR = false;
        	}
		}
    }
}

objXHR.prototype.getData = function(strMode, resFunc) { // send a request to the server in either GET or POST
	// resfunc is the string name of the function that will handle the response when it arrives
	// determine the transport method (can only send POST for some reason)
	// resFunc is the name of the prototype function to be called on data arrival
	
	strMode = (strMode.toLowerCase() == 'post' ? 'post' : 'get');
	var _this = this; // scope resolution
	this.createXHR();

	if (this.XHR) {
		this.XHR.onreadystatechange = function () {
			if (_this.XHR.readyState == 4) {
			// only if "OK"
				if (_this.XHR.status == 200) {
					_this._responseXML = _this.XHR.responseXML;
					_this._responseText = _this.XHR.responseText;
					_this.responseHandler(resFunc);
				} else {
					alert('Status returned - ' + _this.XHR.statusText);
				}
			}
		}
		this.XHR.open(strMode.toLowerCase(), this.url, true);
		if (strMode.toLowerCase() == 'post')	this.XHR.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		this.XHR.send(this.compileRequest());
	} else {
		var mess = "I couldn't contact the server!\n\nIf you use IE please allow ActiveX objects to run";
		alert (mess);
	}
}

objXHR.prototype.compileRequest = function () {
	// parse the request array into a URL encoded string
	var ret = ''; // return request string
	
	for (var e in this.request) {
		ret += e + '=' + this.request[e].replace(/&/, '%26') + '&';
	}
	
	return (ret.substr(0, ret.length - 1));
}

objXHR.prototype.responseHandler = function (theFunction) { // redirect responses from the server to the right function
	// to add a function simply declare a prototype function and the pass the exact name
	// as the second parameter
	// ### NOTE ### function strings must be passed with parantheses
	
	this.request = new Array();
	eval('this.'+theFunction);
}

/// prototype functions below here are not necessary for the function of objHXR

objXHR.prototype.getEntry = function (theLink) {
	if (theLink !== false) {
		document.getElementById('galleryLoading').style.display = 'block';
		this.request['stat'] = 'getgalleryentryajax';
		this.request['id'] = theLink.id.replace(/[^0-9]*/, '');
		this.getData('post', 'getEntry(false)');
	} else {
		document.getElementById('galleryLoading').style.display = 'none';
		document.getElementById('mainContentRight').innerHTML = this._responseText;
	}
	return false;
}

objXHR.prototype.imgSwap = function (theImg) {
	var pImg = document.getElementById('galleryPrimaryImage');
	var temp = pImg.src;
	pImg.src = theImg.src;
	theImg.src = temp;
}

var getGal = new objXHR;