function BrowserSniffer(){
	this.userAgent		= navigator.userAgent.toLowerCase();
	this.appVersion 	= navigator.appVersion.toLowerCase();
	this.BrowserName 	= '';
	this.VersionMajor	= '';
	this.VersionMinor	= '';
	
	this.isMac		= false;
	this.isWindows	= false;
	this.isLinux	= false;
	
	this.isMsie		= false;
	this.isMsie7	= false;
	this.isMsie8	= false;
	this.isMozilla	= false;
	this.isFirefox	= false;
	this.isNetscape	= false;
	this.isSafari	= false;
	this.isGecko	= false;
	
	this.run();
	
	return this;
}

BrowserSniffer.prototype = {
	run : function() {
		
		this.VersionMinor 	= parseFloat(this.appVersion);
		this.VersionMajor 	= parseInt(this.VersionMinor);
		this.isMac		= (this.userAgent.indexOf("mac")!=-1);
		this.isWindows		= (this.userAgent.indexOf("windows")!=-1);
		this.isLinux		= (this.userAgent.indexOf("linux")!=-1);

		//MSie
		var iePos  = this.appVersion.indexOf('msie');
		if (iePos !=-1) {
			this.VersionMinor 	= parseFloat(this.appVersion.substring(iePos+5,this.appVersion.indexOf(';',iePos)));
			this.VersionMajor 	= parseInt(this.VersionMinor);
			this.BrowserName 	= 'msie';
			if (this.VersionMajor == 7 || this.VersionMajor == 8) {
				this.isMsie7 = true;
			}
			this.isMsie		= true;
			return;
		}
		
		//Safari
		this.isSafari = ((this.userAgent.indexOf('safari')!=-1)&&(this.userAgent.indexOf('mac')!=-1))?true:false;
		if (this.isSafari) {
			this.BrowserName 	= 'Safari';
			return;
		}
	
		//Netscape
		if ((navigator.vendor)&& (navigator.vendor=="Netscape")) {
			this.BrowserName 	= 'Netscape';
			this.isNetscape		= true;
			this.VersionMajor 	= parseInt(navigator.vendorSub);
			this.VersionMinor 	= parseFloat(navigator.vendorSub);
			return;
		}		

		//Firefox
 		this.isGecko = ((!this.isSafari)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
		this.isFirefox = ((this.userAgent.indexOf('mozilla/5')!=-1) && (this.userAgent.indexOf('spoofer')==-1) &&
	                 (this.userAgent.indexOf('compatible')==-1) && (this.userAgent.indexOf('opera')==-1)  &&
			 (this.userAgent.indexOf('webtv')==-1) && (this.userAgent.indexOf('hotjava')==-1)     &&
			 (this.isGecko) && ((navigator.vendor=="Firefox")||(this.userAgent.indexOf('firefox')!=-1)));
		this.isMozilla   = ((this.userAgent.indexOf('mozilla/5')!=-1) && (this.userAgent.indexOf('spoofer')==-1) &&
			(this.userAgent.indexOf('compatible')==-1) && (this.userAgent.indexOf('opera')==-1)  &&
			(this.userAgent.indexOf('webtv')==-1) && (this.userAgent.indexOf('hotjava')==-1)     &&
			(this.isGecko) && (!this.isFirefox) &&
			((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));
			
		if ((this.isMozilla)||(this.isFirefox)) {  
			var sMozillaVersion = (navigator.vendorSub)?navigator.vendorSub:0;
			if(this.isFirefox&&!sMozillaVersion) {
				sMozillaVersion = this.userAgent.indexOf('firefox/');
				sMozillaVersion = this.userAgent.substring(sMozillaVersion+8);
				sMozillaVersion = parseFloat(sMozillaVersion);
			}
			if(!(sMozillaVersion)) {
				sMozillaVersion = this.userAgent.indexOf('rv:');
				sMozillaVersion = this.userAgent.substring(sMozillaVersion+3);
				is_paren   = sMozillaVersion.indexOf(')');
				sMozillaVersion = sMozillaVersion.substring(0,is_paren);
			}
			if (this.isFirefox) { this.BrowserName = 'Firefox'; }
			this.VersionMinor = sMozillaVersion;
			this.VersionMajor = parseInt(this.VersionMinor);
		}
	}, 
	
	isBrowserName : function(sBrowserName) { return (this.BrowserName == sBrowserName) }
	    
}	
