/**
 * Client detection.
 */
var Client = new function () {
	
	var platform = navigator.platform.toLowerCase ();
	var useragent = navigator.userAgent.toLowerCase ();
	
	/**
	 * Has Flash? Version 8 passes as yes. Flash is tested for below...
	 * @type {boolean}
	 */
	this.hasFlash = false;
	
	/**
	 * Is Windows platform?
	 * @type {boolean}
	 */
	this.isWindows = platform.indexOf ( "win" ) > -1;
	
	/**
	 * Is Opera browser?
	 * @type {boolean}
	 */
	this.isOpera = window.opera != null;
	
	/**
	 * Is Explorer?
	 * @type {boolean}
	 */
	this.isExplorer = !this.isOpera && document.all != null;
	
	/**
	 * Is Explorer version 7 or lower?
	 * @type {boolean}
	 */
	this.isExplorerOld = this.isExplorer && window.XDomainRequest == null;
	
	/**
	 * Is Explorer version 6 horror?
	 * @type {boolean}
	 */
	this.isExplorer6 = this.isExplorer && window.XMLHttpRequest == null;
	
	/**
	 * Is Chrome or Safari?
	 * @type {boolean}
	 */
	this.isWebKit = !this.isExplorer && useragent.indexOf ( "webkit" ) > -1;
	
	/**
	 * Is old Chrome or Safari? At the time of coding, only 
	 * Safari 4 beta 2 qualifies as a not-old WebKit browser.
	 */
	this.isOldWebKit = this.isWebKit && isOldWebKit ();
	
	/**
	 * Is Firefox?
	 * @type {boolean}
	 */
	this.isGecko = !this.isOpera && !this.isExplorer && !this.isWebKit && document.createTreeWalker != null;
	
	/*
	 * Test flash.
	 */
	if ( navigator.mimeTypes != null && navigator.mimeTypes.length > 0 ) {
		this.hasFlash = navigator.mimeTypes [ "application/x-shockwave-flash" ] != null;
	} else {
		try {
			new ActiveXObject ( "ShockwaveFlash.ShockwaveFlash.8" );
			this.hasFlash = true;
		} catch ( exception ) {}
	}
	
	/**
	 * We seriously need to detect old WebKit versions to patch 
	 * a CSS rendering bug in the top navigation menu.
	 * @return {boolean}
	 */
	function isOldWebKit () {
		
		var string = useragent.split ( "applewebkit/" )[ 1 ].split ( " " )[ 0 ];
		var version = parseFloat ( string );
		return ( version < 528 );
	}
}

