/* @author eharman
 * BrowserObj() provides browser statistics.
 * Public Methods
 *		isMozCompliant() : boolean	// subjective test for latest version of mozilla
 * Public Properties
 *		mozVersion : float	// mozilla version
 *		mozRevision : float	// mozilla revision
 *		family : string		// another subjective one: "ie" if IE, "ns" if "Netscape" (true for most moz browsers too), else null
 *		browserName : string	// actual name of browser, NOT appName as it returns "Netscape" for most moz browsers
 *		version : float		// actual version of browser, NOT appVersion as it returns "5.0" for most moz browsers
 *		fire : boolean		// is a Fire* browser
 *		fire07 : boolean	// is Fire* 0.7 (Firebird)
 *		fire09 : boolean	// is Fire* 0.9 (Firefox) 
 *		opera : boolean		// is Opera
 *		ns : boolean		// is at least Netscape 4
 *		ns4 : boolean		// is between Netscape 4 and 5
 *		ns5 : boolean		// is between Netscape 5 and 6
 *		ns6 : boolean		// is between Netscape 6 and 7
 *		ns7 : boolean		// is between Netscape 7 and 8
 *		ie : boolean		// is at least IE 5
 *		ie5 : boolean		// is between IE 5 and 5.5
 *		ie55 : boolean		// is between IE 5.5 and 6
 *		ie6 : boolean		// is between IE 6 and 7
 */

/* Will only load if not already loaded in browser */
if (!window.browserIsLoaded) {

	/* Register that the script is loaded */
	browserIsLoaded = true;

	/* BrowserObj: constructor */
	function BrowserObj() {
		// Globals
		var mozVersionRE = new RegExp("Mozilla\/([0-9\.]+)", "i");
		var mozRevisionRE = new RegExp("rv:([0-9\.]+)", "i");
		this.mozVersion = (navigator.userAgent) ? ((mozVersionRE.test(navigator.userAgent)) ? parseFloat(RegExp.$1) : null) : null;
		this.mozRevision = (navigator.userAgent) ? ((mozRevisionRE.test(navigator.userAgent)) ? parseFloat(RegExp.$1) : null) : null;
		this.family = (navigator.appName) ? ((navigator.appName == "Netscape") ? "ns" : ((navigator.appName == "Microsoft Internet Explorer") ? "ie" : navigator.appName)) : null;
		this.browserName = (navigator.vendor) ? navigator.vendor : ((this.family == "ie") ? "MSIE" : "Firefox");
		var browserVersionRE = new RegExp(this.browserName + "[\/ ]([0-9\.]+)", "i");
		this.version = (navigator.userAgent) ? ((browserVersionRE.test(navigator.userAgent)) ? parseFloat(RegExp.$1) : null) : null;

		// Mozilla browsers
		this.fire = (this.browserName.indexOf("Fire") == 0);
		this.fire07 = (this.fire && (this.version == 0.7));
		this.fire09 = (this.fire && (this.version >= 0.9));
		// Opera
		this.opera = (!navigator.appName && !navigator.appVersion && !navigator.userAgent);
		// Netscape
		this.ns = ((this.family == "ns") && (this.version >= 4));
		this.ns4 = (this.ns && (this.version >= 4) && (this.version < 5));
		this.ns5 = (this.ns && (this.version >= 5) && (this.version < 6));
		this.ns6 = (this.ns && (this.version >= 6) && (this.version < 7));
		this.ns7 = (this.ns && (this.version >= 7) && (this.version < 8));
		// IE
		this.ie = ((this.family == "ie") && (this.version >= 5));
		this.ie5 = (this.ie && (this.version >= 5) && (this.version < 5.5));
		this.ie55 = (this.ie && (this.version >= 5.5) && (this.version < 6));
		this.ie6 = (this.ie && (this.version >= 6) && (this.version < 7));
		
		return this;
	}
	
	/* isMozCompliant: highly subjective test for compliancy with the latest mozilla version */
	BrowserObj.prototype.isMozCompliant = function() {
		return (this.mozVersion && (this.mozVersion > 4));
	}
}

