/******* BROWSER RECOGNITION *******/
/* Purpose: Grab all the information about the user
 * Usage: [variable] = new oBrowser();
 * Arguments: none
 * Returns: Object
 */
function oBrowser() {
	this.win = (navigator.platform=="Win32");
	this.mac = (navigator.platform=="MacPPC");
	this.ver = navigator.appVersion;
	this.ua = navigator.userAgent;
	this.dom = document.getElementById;
	this.safari = (window.addEventListener && navigator.vendor == "Apple Computer, Inc.");
	this.ie5 = (this.ver.indexOf("MSIE 5")!=-1 && this.dom);
	this.ie6 = (this.ver.indexOf("MSIE 6")!=-1 && this.dom);
	this.ie4 = (document.all && !this.dom);
	this.ie = (this.ie5 || this.ie4 || this.ie6);
	this.ns7 = (this.ua.indexOf('Netscape/7')!=-1);
	this.ns6 = (this.dom && parseInt(this.ver)>=5);
	this.ns4 = (document.layers && !this.dom);
	this.ns = (this.ns4 || this.ns6 || this.ns7);
	this.op = (window.opera);
	this.bw = (this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.ns7);
	this.bx = (this.ie5 || this.ns6 || this.ie6 || this.ns7);
	this.iWidth = 0;
	this.iHeight = 0;
	this.pLoaded = false;
	return this;
}
var browser = new oBrowser();
/******* END BROWSER RECOGNITION *******/



/******* AJAX OBJECT *******/
/* Purpose: creates and sends JS And XML object (AJAX/XMLHTTP) request
 * Usage: [variable] = AJAX([String], [Function]);
 * Arguments: url string, function to call with rendered HTML
 * Returns: window-level XMLHTTP object
 */
function AJAX(url, fn) {
	var rand = "ajax_"+Math.round(Math.random()*5000);
	while(typeof window[rand] != "undefined") {
		rand = "ajax_"+Math.round(Math.random()*5000);
	}

	if(browser.ie) {
		try {
			window[rand] = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				window[rand] = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(E) {
				window[rand] = false;
			}
		}
	} else if(typeof XMLHttpRequest != "undefined") {
		window[rand] = new XMLHttpRequest();
	}

	if(window[rand]) {
		window[rand].open("GET", url, true);
		window[rand].onreadystatechange = function() {
			if(window[rand].readyState == 4 && window[rand].status == 200) {
				fn(window[rand].responseText);
			} else if(window[rand].readyState == 4 && window[rand].status == 404) {
				fn("AJAX Error "+window[rand].status+": Page not found");
			} else if(window[rand].readyState == 4 && parseInt(window[rand].status) == 5) {
				fn("AJAX error "+window[rand].status+": Internal server error");
			}
		}
		window[rand].send(null);

		return window[rand];
	} else {
		return null;
	}
}
/******* END AJAX OBJECT *******/
