/*****************************************************************************************
enformiaBrowserSpy.js
functionality for detecting browser

how to use:
===========
include this script in the page:
		<!-- browser spy script. instanciate a window level object enBC-->
		&lt;script language="JavaScript" type="text/javascript"
			src="../Static/WF/enformiaBrowserSpy.js"&gt;&lt;/script&gt;

an object named enBS will be created and it's properties may be used
	to query broser capabilities: if(enBS.ie4up){...}

enBS properties (all * items are marked)
===============
name			description
----			-----------
name			browser name
verMajor 		broser major version
verMinor 		broser minor version
supportsCookies	browser supports cookies

browsers:
ns				netscape
ns2
ns3
ns4
ns4up
ns6
ns6up
gecko
ie				internet explorer
ie3
ie4
ie4up
ie5
ie55
ie5up
ie6
ie6up
*opera
*webtv
*tvnav
*hotjava
*hotjava3
*hotjava3up

js				javascript version

operating systems:
os				platform name
win16
win31
winme
win2k
win95
win98
winnt
win32
win
mac
mac68k
macppc

*
sun
sun4
sun5
suni86
irix
irix5
irix6
hpux
hpux9
hpux10
aix
aix1
aix2
aix3
aix4
linux
sco
unixware
mpras
dec
sinix
freebsd
bsd
unix
vms
*

*****************************************************************************************/

//browser capabilities constructor function
function enBSConstructor() {
	var agent = navigator.userAgent.toLowerCase(); 
	// Browser version
	this.verMajor = parseInt(navigator.appVersion); 
	this.verMinor = parseFloat(navigator.appVersion); 
	
	// Browser name
	this.name=navigator.appName;
	
	//browser supports cookies
	this.supportsCookies=checkCookiesSupport();
	function checkCookiesSupport()
	{
		var c=document.cookie;
		//any cookies?
		if(c.length>0)return true;
		//try to write a cookie
		document.cookie="enTestCookie=test";
		//any cookies?
		return(c.length>0);
	}
	
	//specific browsers
	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.verMajor == 2)); 
	this.ns3=(this.ns && (this.verMajor == 3)); 
	this.ns4=(this.ns && this.verMajor == 4); 
	this.ns4up=(this.ns && this.verMajor >= 4); 
	this.ns6=(this.ns && this.verMajor == 5); 
	this.ns6up=(this.ns && this.verMajor >= 5);
	this.gecko=(agent.indexOf("gecko") != -1);
	
	this.ie=(agent.indexOf("msie") != -1); 
	this.ie3=(this.ie && (this.verMajor < 4)); 
	this.ie4=(this.ie && this.verMajor == 4 && agent.indexOf("msie 4")!=-1); 
	this.ie4up=(this.ie && this.verMajor >= 4); 
	this.ie5=(this.ie && this.verMajor == 4 && agent.indexOf("msie 5.0")!=-1);
	this.ie55=(agent.indexOf("msie 5.5")!=-1);
	this.ie6=(agent.indexOf("msie 6")!=-1);
	this.ie6up=this.ie6;
	this.ie5up=(agent.indexOf("msie 5")!=-1 || agent.indexOf("msie 6")!=-1); 
	
	this.opera=(agent.indexOf("opera") != -1);
	
	/*	
	this.webtv=(agent.indexOf("webtv") != -1); 
	this.tvnav=((agent.indexOf("navio") != -1) || (agent.indexOf("navio_aoltv") != -1)); 
	
	this.hotjava=(agent.indexOf("hotjava") != -1); 
	this.hotjava3=(this.hotjava && this.verMajor==3); 
	this.hotjava3up=(this.hotjava && this.verMajor>=3); 
	*/
	
	// Javascript version
	this.js = 0.0;
	if (this.ns2 || this.ie3) this.js = 1.0;
	else if (this.ns3 || this.opera || (document.images && this.ie && !this.ie4up)) this.js = 1.1;
	else if ((this.ns4 && this.verMinor <= 4.05) || this.ie4) this.js = 1.2;
	else if ((this.ns4 && this.verMinor > 4.05) || this.ie5up) this.js = 1.3;
	else if (this.hotjava3up) this.js = 1.4;
	else if (this.ns6up || this.gecko) this.js = 1.5;

	// Platform type
	this.os=navigator.platform;
	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.winme=((agent.indexOf("win 9x 4.90")!=-1));
    this.win2k=((agent.indexOf("windows nt 5.0")!=-1));
    this.win95=((agent.indexOf("win95")!=-1) || (agent.indexOf("windows 95")!=-1));
	this.win98=((agent.indexOf("win98")!=-1) || (agent.indexOf("windows 98")!=-1));
    this.winnt=((agent.indexOf("winnt")!=-1) || (agent.indexOf("windows nt")!=-1));
	this.win32=(this.win95 || this.win98 || this.winnt ||
				(this.verMajor >= 4 && navigator.platform == "win32") || 
				agent.indexOf("win32")!=-1 || agent.indexOf("32bit")!=-1);
	this.win=(this.win32 || this.win2k || this.win16 || this.win31);
	
	this.mac=(agent.indexOf("mac")!=-1);
	if (this.mac && this.ie5up) this.js = 1.4;
	this.mac68k = (this.mac && ((agent.indexOf("68k")!=-1) || 
            	(agent.indexOf("68000")!=-1)));
    this.macppc = (this.mac && ((agent.indexOf("ppc")!=-1) || 
              	(agent.indexOf("powerpc")!=-1)));
	
	/*
	this.os2=((agent.indexOf("os/2")!=-1) || 
            	(navigator.appVersion.indexOf("OS/2")!=-1) ||   
           		(agent.indexOf("ibm-webexplorer")!=-1));

    this.sun=(agent.indexOf("sunos")!=-1);
    this.sun4=(agent.indexOf("sunos 4")!=-1);
    this.sun5=(agent.indexOf("sunos 5")!=-1);
    this.suni86=(this.sun && (agent.indexOf("i86")!=-1));
    this.irix=(agent.indexOf("irix") !=-1);    // SGI
    this.irix5=(agent.indexOf("irix 5") !=-1);
    this.irix6=((agent.indexOf("irix 6") !=-1) || (agent.indexOf("irix6") !=-1));
    this.hpux=(agent.indexOf("hp-ux")!=-1);
    this.hpux9=(this.hpux && (agent.indexOf("09.")!=-1));
    this.hpux10=(this.hpux && (agent.indexOf("10.")!=-1));
    this.aix=(agent.indexOf("aix") !=-1);      // IBM
    this.aix1=(agent.indexOf("aix 1") !=-1);    
    this.aix2=(agent.indexOf("aix 2") !=-1);    
    this.aix3=(agent.indexOf("aix 3") !=-1);    
    this.aix4=(agent.indexOf("aix 4") !=-1);    
    this.linux=(agent.indexOf("inux")!=-1);
    this.sco=(agent.indexOf("sco")!=-1) || (agent.indexOf("unix_sv")!=-1);
    this.unixware=(agent.indexOf("unix_system_v")!=-1); 
    this.mpras=(agent.indexOf("ncr")!=-1); 
    this.reliant=(agent.indexOf("reliantunix")!=-1);
    this.dec=((agent.indexOf("dec")!=-1) || (agent.indexOf("osf1")!=-1) || 
           (agent.indexOf("dec_alpha")!=-1) || (agent.indexOf("alphaserver")!=-1) || 
           (agent.indexOf("ultrix")!=-1) || (agent.indexOf("alphastation")!=-1)); 
    this.sinix=(agent.indexOf("sinix")!=-1);
    this.freebsd=(agent.indexOf("freebsd")!=-1);
    this.bsd=(agent.indexOf("bsd")!=-1);
    this.unix= ((agent.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux || 
                 this.sco || this.unixware || this.mpras || this.reliant || 
                 this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd);

    this.vms=((agent.indexOf("vax")!=-1) || (agent.indexOf("openvms")!=-1));
	*/
}
//istanciate object
if(!window.enBS)window.enBS=new enBSConstructor();