//version 2.0.2.1
function BrowserChecker() {
var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;

var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else if (b=="Opera") this.b = "op"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.op = (this.b=="op" && this.v>=7)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	this.ie55 = (navigator.userAgent.indexOf('MSIE 5.5')>0)
	if (this.ie55) {
		this.v = 5.5;
		this.ie5 = false;
	}
	this.mac = (navigator.userAgent.indexOf('Mac')>0);
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
	
	
// In Internet Explorer, the true version is after "MSIE" in userAgent
if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
 this.browserName  = "Microsoft Internet Explorer";
 this.fullVersion  = parseFloat(nAgt.substring(verOffset+5));
 this.majorVersion = parseInt(''+this.fullVersion);
}

// In Opera, the true version is after "Opera" 
else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
 this.browserName  = "Opera";
 this.fullVersion  = parseFloat(nAgt.substring(verOffset+6));
 this.majorVersion = parseInt(''+this.fullVersion);
}

// In Firefox, the true version is after "Firefox" 
else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
 this.browserName  = "Firefox";
 this.fullVersion  = nAgt.substring(verOffset+8,nAgt.length);
 this.majorVersion = parseInt(''+this.fullVersion);
}

// In Chrome, the true version is after "Chrome/" and before "Safari" 
else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
 this.browserName  = "Chrome";
 this.fullVersion  = nAgt.substring(nAgt.indexOf("Chrome")+7,nAgt.indexOf("Safari"));
 this.majorVersion = parseInt(''+this.fullVersion);
}

// In Safari, the true version is after "Version/" 
else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
 this.browserName  = "Safari";
 this.fullVersion  = parseFloat(nAgt.substring(nAgt.indexOf("Version")+8,verOffset));
 this.majorVersion = parseInt(''+this.fullVersion);
}

// In Mozilla, the true version is after "Mozilla/" ??? 
else if ((verOffset=nAgt.indexOf("Mozilla"))!=-1) {
 this.browserName  = "Mozilla";
 this.fullVersion  = parseFloat(nAgt.substring(verOffset+8));
 this.majorVersion = parseInt(''+this.fullVersion);
}

// In most other browsers, "name/version" is at the end of userAgent 
else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) 
{
 this.browserName  = nAgt.substring(nameOffset,verOffset);
 this.fullVersion  = parseFloat(nAgt.substring(verOffset+1));
 if (!isNaN(this.fullVersion)) this.majorVersion = parseInt(''+this.fullVersion);
 else {this.fullVersion  = 0; this.majorVersion = 0;}
} else {

	// Finally, if no name and/or no version detected from userAgent...
	if (this.browserName.toLowerCase() == this.browserName.toUpperCase()
	 || this.fullVersion==0 || this.majorVersion == 0 )
	{
	 this.browserName  = navigator.appName;
	 this.fullVersion  = parseFloat(nVer);
	 this.majorVersion = parseInt(nVer);
	}
}
if ((verOffset=nAgt.indexOf("Windows NT"))!=-1) {
	this.os="Windows";
	ver=parseFloat(nAgt.substring(verOffset + 11));
	if (ver==4.0) {
		this.winver="Windows NT 4.0";
	}
	if (ver==5.0) {
		this.winver="Windows 2000";
	}
	if (ver==5.1) {
		this.winver="Windows XP";
	}
	if (ver==5.2) {
		this.winver="Windows Server 2003";
	}
	if (ver==6.0) {
		this.winver="Windows Vista";
	}
} else if ((verOffset=nAgt.indexOf("Mac"))!=-1) {
	this.os="Mac";
} else if ((verOffset=nAgt.indexOf("Linux"))!=-1) {
	this.os="Linux";
}

}

// automatically create the "browserCheck" object
browser = new BrowserChecker();

