/*********************************************************************
* Browser.js - A browser screening class (used with dClass.js)       *
* Copyright © 2000-2002, 5square Software (info@5squaresoftware.com) *
* Version $Id$                                                       *
*********************************************************************/

/*
 * SET THESE VARIABLES
 * upgrade_action values mean:
 * 1 = print out default upgrade page (I supplied)
 * 2 = specify upgrade page (you supply)
 * 3 = suppress errors (may cause loss of functionality)
 * 4 = fork (you supply the browser and page pairs)
 * 5 = don't do anything - see the errors 
*/
var upgrade_action = 2;
var upgrade_page = "upgrade.html";


/*********************************************************************
**********DON'T EDIT BELOW THIS POINT UNLESS YOU FEEL LIKE IT*********
*********************************************************************/


//functions to handle bad browsers
function errorFunc() { return true; }

function upgrade(){
	if(upgrade_action == 1){
		document.open();
		document.writeln('<html><head><title>Upgrade Your Browser</title></head>');
		document.writeln('<body bgcolor="#000000"><p>&nbsp;</p><p align=center>');
		document.writeln('<font size="3" color="#FFFFFF" face="Arial,Verdana">In order to view this site, please upgrade your browser.');
		document.writeln('<br>Click here to go to <a href="http://home.netscape.com" target="_blank">Netscape</a>');
		document.writeln('<br>Click here to go to <a href="http://www.microsoft.com" target="_blank">Microsoft</a>');
		document.writeln('</font></p></body></html>');
		document.close()
		//suppress further errors
		window.onerror = errorFunc;
	}
	else if (upgrade_action == 2) window.location = upgrade_page;
	else if (upgrade_action == 3) {
		//suppress further errors
		window.onerror = errorFunc; 
	}
	else if (upgrade_action == 4) {
		//FORKING NOT DONE
		//suppress further errors
		window.onerror = errorFunc; 
	}
	else if (upgrade_action == 5){
		//do nothing
	}
	else {
		//suppress further errors
		window.onerror = errorFunc;
	}
}

function dontUpgrade() { return true; }

//construct browser objects
function Browser (){
	this.browser = navigator.appName; 
	this.version = parseFloat(navigator.appVersion);//returns the 'compatible' version
	this.width = window.innerWidth;
	this.height = window.innerHeight;
	
	//platforms
	this.isMac = (navigator.userAgent.indexOf('PPC') >= 0 || navigator.userAgent.indexOf('Mac') >= 0) ? true : false ;
	this.isWin = (navigator.userAgent.indexOf("Win")>=0 || navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0 ) ? true : false ;
	
	//browser definitions
	this.isIE4_01 = (navigator.appVersion.indexOf('MSIE 4.01') != -1) ? true : false ;
	this.isIE4_5 = (navigator.appVersion.indexOf('MSIE 4.5') != -1) ? true : false ;
	this.isIE5 = (navigator.appVersion.indexOf('MSIE 5.0') != -1) ? true : false ;

	this.isNN3_01 = (this.version == 3.01 && this.browser == 'Netscape') ? true : false ;
	this.isNN4_61 = (this.version == 4.61 && this.browser == 'Netscape') ? true : false ;
	this.isNN4_73 = (this.version == 4.73 && this.browser == 'Netscape') ? true : false ;
	if(navigator.vendor && navigator.product){
		this.isNN6 = (navigator.vendor == 'Netscape6' || navigator.product == 'Gecko') ? true : false ;//any Gecko browser
	}
	this.isDOMBrowser = (document.getElementById) ? true : false ;
	
	this.isMacIE5 = (this.isIE5 && this.isMac) ? true : false ; 
	this.isMacNN6 = (this.isMac && this.isNN6) ? true : false;
	this.isWinNN6 = (this.isWin && this.isNN6) ? true : false;
	this.isWinIE4Plus = (this.isWin && this.isIE4Plus) ? true : false;

	//groups of browsers for screening -- add your own if you want
	this.isNN4Plus = ((this.version >= 4) && (this.browser == "Netscape")) ? true : false ;
	this.isIE4Plus = ((this.version >= 4) && (this.browser == "Microsoft Internet Explorer")) ? true : false ;
	this.isNN6Plus = ((this.version >= 5) && (this.browser == "Netscape")) ? true : false ;
	//this.DhtmlBrowser = (this.isNN4Plus || this.isIE4Plus);
	this.DhtmlBrowser = (this.isNN6Plus || this.isIE4Plus || this.isDOMBrowser);



	//handle bad browsers
	this.badBrowser = !this.DhtmlBrowser;
	this.upgradeAction = (this.badBrowser) ? upgrade : dontUpgrade ;

}

var client = new Browser();
client.upgradeAction();


