// filename: browsercheck.js
// Creating the Browsercheck Object for Browser Identification
// Distributed under the terms of the GNU Library General Public License
// version 1.06-merz - 2002-01-02
// please document *any* changes exactly!
// author: martin dot kliehm at gpm dot de

window.onerror = null

function BrowserCheck() {
	var b = navigator.userAgent.toLowerCase()
	// get browser version
	this.major = parseInt(navigator.appVersion)
	this.minor = parseFloat(navigator.appVersion)
		
	// check for Netscape detect masked browsers workaround for NN6 returning navigator.appVersion = 5
	this.ns = (this.major >= 4 && ((b.indexOf("mozilla") != -1) && (b.indexOf("spoofer") == -1) && (b.indexOf("compatible") == -1) && (b.indexOf("opera") == -1) && (b.indexOf("webtv") == -1)))
	this.ns4 = (this.ns && (this.major == 4))
	this.ns40 = (this.ns4 && this.minor < 4.1) // added 1 Apr 2001 by mak
	this.ns4up = (this.ns && (this.major >= 4))
	this.ns5 = (this.ns && (this.major == 5))
	this.ns5up = (this.ns && (this.major >= 5))
	this.ns6 = (this.ns && ((this.major == 6) || (b.indexOf("netscape6") != -1) || (b.indexOf("gecko") != -1))) // added "gecko" 09 Jan 2001 by mak
	this.ns6up = (this.ns && ((this.major >= 6) || this.ns6))
	
	// check for Microsoft Internet Explorer detect masked browsers workaround for IE5 returning navigator.appVersion = 4
	this.ie = (this.major >= 4 && ((b.indexOf("msie") != -1) && (b.indexOf("spoofer") == -1) && (b.indexOf("opera") == -1) && (b.indexOf("webtv") == -1)))
	this.ie4 = (b.indexOf("msie 4") != -1)
	this.ie4up = (this.ie && (this.major >= 4))
	this.ie5 = (b.indexOf("msie 5") != -1)
	this.ie55 = (b.indexOf("msie 5.5") != -1) // added 1 Apr 2001 by mak
	this.ie5up = (this.ie && ((b.indexOf("msie 6") != -1) || this.ie5)) // added IE6 19 Sep 2001 by mak
	this.ie6 = (b.indexOf("msie 6") != -1) // changed 19 Sep 2001
	this.ie6up = (b.indexOf("msie 6") != -1) // changed 19 Sep 2001
	
	// detect Opera behind masking // changed 09 Jan 2001 and 25 Apr 2001 by mak
	this.opera = (b.indexOf("opera") != -1)
	this.opera3 = (b.indexOf("opera 3") != -1)
	this.opera3up = (this.opera3 || (b.indexOf("opera 4") != -1) || (this.opera && this.major == 4) || (b.indexOf("opera 5") != -1) || (this.opera && this.major == 5))
	this.opera4 = (b.indexOf("opera 4") != -1 || (this.opera && this.major == 4))
	this.opera4up = (this.opera4 || b.indexOf("opera 5") != -1 || b.indexOf("opera/5") != -1 || (this.opera && this.major >= 5))
	this.opera5 = (b.indexOf("opera 5") != -1 || b.indexOf("opera/5") != -1 || (this.opera && this.major == 5))
	this.opera5up = (this.opera5 || b.indexOf("opera 6") != -1 || b.indexOf("opera/6") != -1 || (this.opera && this.major == 6)) // added Opera 6 2002-01-02 by mak
	this.opera6 = (b.indexOf("opera 6") != -1 || b.indexOf("opera/6") != -1 || (this.opera && this.major == 6))
	this.opera6up = (this.opera6)
	// added 26 Jul 2000 by mak: set NS and IE detection to false if masked Opera
	if (this.opera) {
		this.ns = this.ns4 = this.ns4up = this.ns5 = this.ns5up = this.ns6 = this.ns6up = this.ie = this.ie4 = this.ie4up = this.ie5 = this.ie5up = this.ie6 = this.ie6up = false
		}
	
	// is.min stands for minimum requirements, i.e. browsers 5+
	this.min = (this.ns5up || this.ie5up || this.opera6up)
	
	// platform detection without the use of document.platform
	this.win = this.pc = (b.indexOf("win") != -1 || b.indexOf("16bit") != -1)
	this.mac = (b.indexOf("mac") != -1)
	
	// object detection
	this.all = (document.all) ? true : false
	this.layers = (document.layers) ? true : false
	this.dom = (document.getElementById) ? true : false
	
	this.java = (navigator.javaEnabled())
	this.print = (window.print) ? true : false
	
	this.images = (document.images) ? true : false
	this.frames = (window.frames) ? true : false
	this.screen = (window.screen) ? true : false
	
	// JavaScript version detection (workaround for NS3 returning 1.2 instead of 1.1)
	if (this.ns3 || this.opera3) this.js = 1.1 // added this.ns3 09 Jan 2001 by mak
	else if ((this.ns4 && this.minor <= 4.05) || this.ie4) this.js = 1.2
	else if ((this.ns4 && this.minor > 4.05) || this.ie5up || this.opera4 || this.opera5) this.js = 1.3 // added opera5 09 Jan 2001 by mak
	else if (this.ns5 && !this.ns6up) this.js = 1.4
	else if (this.ns6up) this.js = 1.5
	}

// automatically create the "is" object
is = new BrowserCheck()
