/*
 * Copyright © 1995-2005 by 4system Polska Sp. z o.o.
 * All Rights Reserved.
 */

function Browser() {
	//***old
	var b=navigator.appName;
	if (b.indexOf('Netscape')!=-1) this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	
/*	if (!b) alert('Unidentified browser.\nThis browser is not supported,'); */

	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ns7=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6')>0);
	this.ie7 = (this.version.indexOf('MSIE 7') > 0);
	this.ie55UP = this.ie55 || this.ie6 || this.ie7;
	this.ie7UP = this.ie7;
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	var ua=navigator.userAgent.toLowerCase();
	
	this.winXPPlatform = false;
	if (ua.indexOf("win")>-1) {
		this.platform="win32";
		this.winXPPlatform = ( ua.indexOf( "NT 5.1" ) > -1 );
	} else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
	//***old
	
	//***new
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	
	// NETSCAPE SNIFFS 
	this.ns = ((agent.indexOf('mozilla')!=-1) && (agent.indexOf('spoofer')==-1)
		&& (agent.indexOf('compatible') == -1) && (agent.indexOf('opera')==-1)
		&& (agent.indexOf('webtv')==-1));
	this.ns2 = (this.ns && (this._major == 2));
	this.ns3 = (this.ns && (this.major == 3));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns40 = (this.ns && (this.major == 4) && (agent.indexOf('4.0 ')!=-1));
	this.ns401 = (this.ns && (this.major == 4) && (agent.indexOf('4.01')!=-1));
	this.ns02 = (this.ns && (this.major == 4) && (agent.indexOf('4.02')!=-1));
	this.ns03 = (this.ns && (this.major == 4) && (agent.indexOf('4.03')!=-1));
	this.ns04 = (this.ns && (this.major == 4) && (agent.indexOf('4.04')!=-1));
	this.ns05 = (this.ns && (this.major == 4) && (agent.indexOf('4.05')!=-1));
	this.ns06 = (this.ns && (this.major == 4) && (agent.indexOf('4.06')!=-1));
	this.ns07 = (this.ns && (this.major == 4) && (agent.indexOf('4.07')!=-1));
	this.ns08 = (this.ns && (this.major == 4) && (agent.indexOf('4.08')!=-1));
	this.ns450 = (this.ns && (this.major == 4) && (agent.indexOf('4.50')!=-1));
	this.ns451 = (this.ns && (this.major == 4) && (agent.indexOf('4.51')!=-1));
	this.ns46 = (this.ns && (this.major == 4) && (agent.indexOf('4.6')!=-1));
	this.ns461 = (this.ns && (this.major == 4) && (agent.indexOf('4.61')!=-1));
	this.ns47 = (this.ns && (this.major == 4) && (agent.indexOf('4.7')!=-1));
	this.ns472 = (this.ns && (this.major == 4) && (agent.indexOf('4.72')!=-1));
	this.ns473 = (this.ns && (this.major == 4) && (agent.indexOf('4.73')!=-1));
	this.ns474 = (this.ns && (this.major == 4) && (agent.indexOf('4.74')!=-1));
	this.ns475 = (this.ns && (this.major == 4) && (agent.indexOf('4.75')!=-1));
	this.ns476 = (this.ns && (this.major == 4) && (agent.indexOf('4.76')!=-1));
	this.ns48 = (this.ns && (this.major == 4) && (agent.indexOf('4.8')!=-1));
	this.ns6 = (this.ns && (this.major == 6));
	this.ns7 = (this.ns && (this.major == 7));
	this.ns7up = (this.ns && (this.major >= 6));
	this.ns7x = (this.ns && (this.major == 5));
	
	//MOZILLA-SPECIFIC CHECK 
	this.ns6pr1 = (this.ns && (this.major == 5)&&(agent.indexOf('6.0b1')!=-1)); 
	this.ns6pr2 = (this.ns && (this.major == 5)&&(agent.indexOf('6.0b2')!=-1)); 
	this.ns6pr3 = (this.ns && (this.major == 5)&&(agent.indexOf('6.0b3')!=-1)); 
	this.ns6gold = (this.ns && (this.major == 5) && (agent.indexOf('netscape')!=-1) && !this.ns6pr1 && !this.ns6pr2 && !this.ns6pr3);
	this.moz = (this.ns && (this.major >= 5) && (agent.indexOf('netscape')==-1));
	
	if (this.ns7x) this.moz = true;
	
	if	(this.ns6)	{
		if (agent.indexOf('; m')!=-1) {
			MSnumStart = agent.indexOf('; m') + 3;
			MSnumEnd = MSnumStart +2;
			MSnum = agent.substring(MSnumStart, MSnumEnd);
			mozmile = Number(MSnum);
		} else {
			mozmile = 'cannot obtain milestone number';
		}
	} else {
		mozmile = 'not a mozilla or netscape user agent';
	}
	
	this.mozBased = (agent.indexOf('gecko')!=-1); 
	if (this.mozBased) {
		GeckoBuildIDStart = agent.indexOf('gecko') + 6;
		GeckoBuildIDEnd = GeckoBuildIDStart + 8;
		GeckoBuildIDnum = agent.substring(GeckoBuildIDStart, GeckoBuildIDEnd);
		GeckoBuildID = Number(GeckoBuildIDnum);
	} else {
		GeckoBuildID = 'cannot obtain gecko build #';
	}
	
	//MSIE CHECK 
	this.ie = ((agent.indexOf("msie") != -1)&& (agent.indexOf('opera')==-1));
	this.winie = (this.win && this.ie);
	this.ie3 = (this.ie && (this.major < 4) && !this.ie6);
	this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 4")!=-1) );
	this.ie401 = (this.ie && (this.major == 4) && (agent.indexOf("msie 4.01")!=-1) );
	this.ie4up = (this.ie && (this.major >= 4));
	this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5")!=-1) );
	this.ie51 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.01")!=-1) );
	this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5")!=-1) ); 
	this.ie5up = (this.ie && !this.ie3 && !this.ie4);
	this.ie6 = (this.ie && (agent.indexOf("msie 6.0")!=-1) );
	this.ie7 = (this.ie && (agent.indexOf("msie 7.0")!=-1) );
	
	// AOL CHECKS 
	this.aol = (agent.indexOf("aol") != -1);
	this.aolandie3 = (this.aol && this.ie3); 
	this.aolandie4 = (this.aol && this.ie4); 
	this.aolandie5 = (this.aol && this.ie5);
	this.aol3 = (agent.indexOf("aol 3") != -1);
	this.aol4 = (agent.indexOf("aol 4") != -1);
	this.aol5 = (agent.indexOf("aol 5") != -1);
	this.aol6 = (agent.indexOf("aol 6") != -1);
	this.aol7 = (agent.indexOf("aol 7") != -1);
	this.aol8 = (agent.indexOf("aol 8") != -1);
	
	//MAC CHECK 
	this.mac = (agent.indexOf("mac")!=-1); 
	this.mac68k = (this.mac && ((agent.indexOf("68k")!=-1) || (agent.indexOf("68000")!=-1)));
	this.macppc = (this.mac && ((agent.indexOf("ppc")!=-1) || (agent.indexOf("powerpc")!=-1)));
	//MAC MSIE CHECK
	this.macie = (this.mac && this.ie); 
	this.macie4 = (this.mac && (agent.indexOf("msie 4")!=-1));
	this.macie401 = (this.mac && (agent.indexOf("msie 4.01")!=-1));
	this.macie45 = (this.mac && (agent.indexOf("msie 4.5")!=-1));
	this.macie5 = (this.mac && (agent.indexOf("msie 5.0")!=-1));
	this.macie6 = (this.mac && (agent.indexOf("msie 6.0")!=-1));
	// MAC SAFARI
	this.safari = (this.mac && (agent.indexOf("safari")!=-1));
	
	//OPERA CHECK 
	this.opera = (agent.indexOf("opera") != -1);
	this.opera3 = (this.opera && (agent.indexOf(") 3.0") != -1));
	this.opera321 = (this.opera && (agent.indexOf(") 3.21") != -1));
	this.opera351 = (this.opera && (agent.indexOf(") 3.51") != -1));
	this.opera360 = (agent.indexOf("opera 3.60") != -1);
	this.opera361 = (agent.indexOf("opera 3.61") != -1);
	this.opera362 = (agent.indexOf("opera 3.62") != -1);
	this.opera4 = (agent.indexOf("opera 4") != -1);
	this.opera5 = (agent.indexOf("opera 5") != -1);
	this.opera51 = (agent.indexOf("opera 5.1") != -1);
	this.opera52 = (agent.indexOf("opera 5.2") != -1);
	this.opera6 = (agent.indexOf("opera 6") != -1);
	this.opera7 = (agent.indexOf("opera 7") != -1);
	
	//WEB TV CHECK 
	this.webtv = (agent.indexOf("webtv") != -1);
	this.webtv12 = this.webtv && (agent.indexOf("1.2") != -1);
	this.webtv22 = this.webtv && (agent.indexOf("2.2") != -1);
	
	//WINDOWS CHECK 
	this.win = ((agent.indexOf("win")!=-1) || (agent.indexOf("16bit")!=-1));
	this.win95 = ((agent.indexOf("win95")!=-1) || (agent.indexOf("windows 95")!=-1));
	this.win16 = ((agent.indexOf("win16")!=-1) || (agent.indexOf("16bit")!=-1)
		|| (agent.indexOf("windows 3.1")!=-1) || (agent.indexOf("windows 16-bit")!=-1));
	this.win31 = ((agent.indexOf("windows 3.1")!=-1) || (agent.indexOf("win16")!=-1)
		|| (agent.indexOf("windows 16-bit")!=-1));
	this.win98 = ((agent.indexOf("win98")!=-1) || (agent.indexOf("windows 98")!=-1)); 
	this.winnt = ((agent.indexOf("winnt")!=-1) || (agent.indexOf("windows nt")!=-1));
	this.winnt4 = (agent.indexOf("windows nt 4.0")!=-1);
	this.winnt5 = (agent.indexOf("windows nt 5.0")!=-1); 
	this.winnt6 = (agent.indexOf("windows nt 6.0")!=-1);
	this.win2pro = (agent.indexOf("win2000pro")!=-1);
	this.win21 = (agent.indexOf("windows 2001")!=-1);
	this.wince = (agent.indexOf("windows ce")!=-1); 
	this.winxp = (agent.indexOf("windows xp")!=-1);
}

is = new Browser();

