function BrowserDetect() {
	var ua = navigator.userAgent.toLowerCase(); 
	this.ua = ua;

	// browser name
	this.isGecko = (-1 != ua.indexOf('gecko'));
	this.isMozilla = ((true == this.isGecko) && (ua.indexOf('gecko/') + 14 == ua.length));
	this.isNS = ((true == this.isGecko) ? (ua.indexOf('netscape') != -1) : ((-1 != ua.indexOf('mozilla')) && (-1 == ua.indexOf('opera'))));
	this.isIE = ((-1 != ua.indexOf('msie')) && (-1 == ua.indexOf('opera')));
	this.isOpera = (-1 != ua.indexOf('opera'));
	
	// browser version
	this.versionMinor = parseFloat(navigator.appVersion); 
	
	// correct version number for NS6+
	if ((true == this.isNS) && (true == this.isGecko)) {
		this.versionMinor = parseFloat(ua.substring(ua.lastIndexOf('/') + 1));
	}
	
	// correct version number for IE4+
	else if ((true == this.isIE) && (4 <= this.versionMinor)) {
		this.versionMinor = parseFloat(ua.substring(ua.indexOf('msie ') + 5));
	}
	
	// correct version number for Opera
	else if (true == this.isOpera) {
		if (-1 != ua.indexOf('opera/')) {
			this.versionMinor = parseFloat(ua.substring(ua.indexOf('opera/') + 6));
		} else {
			this.versionMinor = parseFloat(ua.substring(ua.indexOf('opera ') + 6));
		}
	}
	
	this.versionMajor = parseInt(this.versionMinor);
	this.geckoVersion = ((this.isGecko) ? ua.substring((ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1);
	
	// platform
	this.isWin = (-1 != ua.indexOf('win'));
	this.isWin32 = ((true == this.isWin) && ((-1 != ua.indexOf('95')) || (-1 != ua.indexOf('98')) || (-1 != ua.indexOf('nt')) || (-1 != ua.indexOf('win32')) || (-1 != ua.indexOf('32bit'))));
	this.isMac = (-1 != ua.indexOf('mac'));
	this.isUnix = ((-1 != ua.indexOf('unix')) || (-1 != ua.indexOf('linux')) || (-1 != ua.indexOf('sunos')) || (-1 != ua.indexOf('bsd')) || (-1 != ua.indexOf('x11')));
	
	// specific browser shortcuts
	this.isNS4x = (true == this.isNS && 4 == this.versionMajor);
	this.isNS40x = (true == this.isNS4x && 4.5 < this.versionMinor);
	this.isNS47x = (true == this.isNS4x && 4.7 <= this.versionMinor);
	this.isNS4up = (true == this.isNS && 4 <= this.versionMinor);
	this.isNS6x = (true == this.isNS && 6 == this.versionMajor);
	this.isNS6up = (true == this.isNS && 6 <= this.versionMajor);
	
	this.isIE4x = (true == this.isIE && 4 == this.versionMajor);
	this.isIE4up = (true == this.isIE && 4 <= this.versionMajor);
	this.isIE5x = (true == this.isIE && 5 == this.versionMajor);
	this.isIE55 = (true == this.isIE && 5.5 == this.versionMinor);
	this.isIE5up = (true == this.isIE && 5 <= this.versionMajor);
	this.isIE6x = (true == this.isIE && 6 == this.versionMajor);
	this.isIE6up = (true == this.isIE && 6 <= this.versionMajor);
}

var browser = new BrowserDetect();