// Define site global properties and functions
// All pages must have following line
// <SCRIPT LANGUAGE="javascript" SRC="/js/global.js"></SCRIPT>



// Function that track and set toggle group button states. 
function FWFindImage(doc, name, j) {
    var theImage = false;
    if (doc.images) {
        theImage = doc.images[name];
    }
    if (theImage) {
        return theImage;
    }
    if (doc.layers) {
        for (j = 0; j < doc.layers.length; j++) {
            theImage = FWFindImage(doc.layers[j].document, name, 0);
            if (theImage) {
                return (theImage);
            }
        }
    }
    return (false);
}
// Function that swaps images.
function rollover(imgName, newSrc) {
    var theImage = FWFindImage(document, imgName, 0);
    if (theImage) {
        theImage.src = newSrc;
    }
}


//Finds the object specified on the page and returns it through getElementById
function FindObj(n) {
  var p,i,x, d;  
  d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) 
  	x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) 
  	x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
  	x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) 
  	x=d.getElementById(n); 
  	
  return x;
}
// Functions for object handling on forms
function uncheckOthers(oCheck, position){
 for (var i=0; i < oCheck.length; i++) 
   if (i == position){
   		if(oCheck[i].checked)
     		oCheck[i].checked = true;
     	else
     		oCheck[i].checked = false;
   }
   else
     oCheck[i].checked = false;
}
function maxExceeded(oCheck, position, nMax){
  var nCtr = 0;
  // First check to see if checkbox is being checked or unchecked
  if (!oCheck[position].checked)
    return;
  for (var i=0; i < oCheck.length; i++) 
    if (oCheck[i].checked) 
      nCtr += 1;
  if (nCtr > nMax) {
    oCheck[position].checked = false;
    alert ('Maximum selections exceeded.');
  }  
}

function isEmpty(s){
  return ((s == null) || (s.length == 0))
}
function isWhitespace(s){  
  var i;
  // Is s empty?
  if (isEmpty(s)) return true;

  // Search through string's characters one by one
  // until we find a non-whitespace character.
  // When we do, return false; if we don't, return true.
  for (i = 0; i < s.length; i++)
  {   
    // Check that current character isn't whitespace.
    var c = s.charAt(i);
	
    if (whitespace.indexOf(c) == -1) return false;
  }
	
  // All characters are whitespace.
  return true;
}
function charsOccurIn (s, universe){  
  var i;
  // Search through string's characters one by one.
  // Verify that character is in universe.

  for (i = 0; i < s.length; i++)
  {   
    // Check that current character is in universe
    var c = s.charAt(i);
    if (universe.indexOf(c) == -1) 
        return false;
  }
  return true;
}
function ValidID(id) {
  var legalchr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  return charsOccurIn(id,legalchr);
}
function showErrorMessage(strMessage){
	alert('Error:\n\n' + strMessage + '\n' + 'Please fix the above error(s) and try again!');
}
function showConfirmMessage(strMessage){
	if(window.confirm('Confirmation:\n\n' + strMessage)) return true;
	else return false;
}
function emailCheck(strEmailToCheck, blnCheckTLD, blnDetailError) {
	/*
	the function eitehr returns the error number, in this case 0 is no error
	or returns a detailed error string, in this case empty string is no error. 
	to get error string you need to pass true as blnDetailError 
	
	whether or not to verify that the address ends in a two-letter country or well-known
	TLD pass, pass blnCheckTLD true means check otherwise pase false means do not check
	
	number	=		error string
	**********************************************************************************************
	0		= 		empty string										-- this means ok
	1		=		Email address not specified!						-- empty string passed for the email address
	2		= 		Email address seems incorrect (check @ and .'s)
	3		= 		Email address username contains invalid characters.
	4		=		Email address domain name contains invalid characters.
	5		= 		Email address username doesn't seem to be valid.
	6		=		Email address destination IP address is invalid!	-- if we have IP for the domain part
	7		= 		Email address domain name does not seem to be valid.
	8		=		Email address must end in a well-known domain or two letter country.
	9		= 		Email address is missing a hostname!
	*/
	
	if(blnCheckTLD=='undefined' || blnCheckTLD==null || blnCheckTLD=='') blnCheckTLD=false;
	if(blnDetailError=='undefined' || blnDetailError==null || blnDetailError=='') blnDetailError=false;
	if(strEmailToCheck=='undefined' || strEmailToCheck==null) strEmailToCheck='';
		
	//if email to check is blank, return error immediately
	if(strEmailToCheck == ''){
		if(blnDetailError) return 'Email address not specified';
		else return 1;
	}

	/* The following is the list of known TLDs that an e-mail address must end with. */
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */
	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; ~ ` ! # $ % \ ^ & * = } { ' | ? / : \ " . [ ] */
	var specialChars="\\(\\)><@,;~`!#$%\^&*=}{'|?/:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/
	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */
	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */
	var matchArray=strEmailToCheck.match(emailPat);

	if (matchArray==null) {
		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
		if(blnDetailError) return "Email address seems incorrect (check @ and .'s)";
		else return 2;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			if(blnDetailError) return "Email address username contains invalid characters.";
			else return 3;
	   	}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			if(blnDetailError) return "Email address domain name contains invalid characters.";
			else return 4;
	   	}
	}
	
	// See if "user" is valid 
	if (user.match(userPat)==null) {
		if(blnDetailError) return "Email address username doesn't seem to be valid.";
		else return 5;
	}
	
	/* if the e-mail address is at an IP address (not host name) 
	make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) { //We have ourselves an IP address for email address
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				if(blnDetailError) return "Email address destination IP address is invalid!";
				else return 6;
	   		}
		}
		//this is valid IP address
		if(blnDetailError) return "";
		else return 0;
	}
	
	// See if "domain" is valid
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			if(blnDetailError) return "Email address domain name does not seem to be valid.";
			else return 7;
	   	}
	}
	
	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */
	if (blnCheckTLD && domArr[domArr.length-1].length!=2 && 
			domArr[domArr.length-1].search(knownDomsPat)==-1) {
		if(blnDetailError) return "The email address must end in a well-known domain or two letter country.";
		else return 8;
	}
	
	// Make sure there's a host name preceding the domain.
	if (len<2) {
		if(blnDetailError) return "Email address is missing a hostname!";
		else return 9;
	}
	
	// If we've gotten this far, everything's valid!
	if(blnDetailError) return '';
	else return 0;
}


function alltrim(s){  
  // Returns string with leading and trailing blanks removed.
  // Is s empty?
  if (isEmpty(s)) 
    return "";

  var i, n;
  
  // First find position of first nonblank character in string
  for (i = 0; s.charAt(i) == ' ' && i <= s.length;i++);
  
  // Search from end of string, find position of last nonblank character in string
  for (n = s.length; s.charAt(n-1) == ' ' && n >= 0;n--);
    
 return s.substring(i,n);
}
//formats the numeric value
function formatNumeric(number,precision) {
  var blnNeg;
  var strReturn = new String("");
  blnNeg = false;
  var num = new String(number);
  if (num == '')
	 return '';
   
  // First check for decimal point.
   
  if(num.indexOf(".") == -1) {
	   	
	 var strLeft = new String(num.substring(0, num.length));
	 var strRight = "00000000000000000000000".substring(0,precision);
	 
  }
  else {
	
    // Decimal point exists, separate right and left
	 pos = num.indexOf(".");
	 var strLeft = num.substring(0, pos);
	 if (strLeft == "")
	   strLeft = "0";
	 var strRight = num.substring(pos+1);
		
    // Correct precision to the desired level.
    // Adding zeros, or truncating where necessary
    strRight += '0000000000000000000000';
    strRight = strRight.substring(0,precision);
       	
  }  
  	
  // Add commas to the left side.
  var ctr = 0;
  var strTmp = "";
  for (var i=strLeft.length-1;i>=0;i--) {
    ctr += 1;
    if (ctr == 4) {
      strTmp += "," + strLeft.charAt(i);
      ctr = 1;
    }
    else 
      strTmp += strLeft.charAt(i);
       
  }     
  
  strLeft = "";
  for (var i=strTmp.length-1;i>=0;i--) {
    strLeft += strTmp.charAt(i)       
  }
 
  //Taking care of - at first place and , following it 
        
  if(strLeft.indexOf("-,") != -1 || strLeft.indexOf("-") != -1) {
  	blnNeg = true;
  	strLeft = strLeft.replace("-,","("); 
  	strLeft = strLeft.replace("-","(");
  }
	
 
  if (precision == 0)
    strReturn =  strLeft;
  else
    strReturn = strLeft+'.'+strRight
    
  if(blnNeg == true)
  		strReturn += ")"; 
  return strReturn;
}

function IsLeapYear(nYear){
	var nResult = 0;
	// If year is dividable by 4, then yes
	if (!(nYear % 4)){
		// Set Yes
		nResult = 1;
		// Unless, if year is dividable by 100, then No
		if (!(nYear % 100)){
			// Set No
			nResult = 0;
			// Unless, if year is dividable by 400, then Yes
			if (!(nYear % 400))
				// Set Yes
				nResult = 1;
		}
	}
	// Return result
	return (nResult == 1);
}
function checkDate(s){
	s = new String(s);
	//first checking that date comprises of 9 or 10 characters
	if (s.length < 8 || s.length > 10)
		return false;
	//now checking that 2 /'s are in the date
	s = s.split("/");
	//meaning that 2/ are present
	if (s.length == 3){
		//checking for numeric
		//alert(s[0] + " " + s[1] + " " +s[2])
		//alert(s[2] + "%4 = " + s[2]%4)
		if(charsOccurIn(s[0],"0123456789") == false)
			return false;
		else if(charsOccurIn(s[1],"0123456789") == false)
			return false;
		else if(charsOccurIn(s[2],"0123456789") == false)
			return false;
		//checking for the length of month day and year
		else if(s[0].length < 1 || s[0].length > 2 || s[1].length < 1 || s[1].length > 2 || s[2].length != 4)
			return false;
		//checking if only 0 is entered and year is greater than 1900
		else if(s[0] == 0 || s[1] == 0 || s[2] == 0 || s[2] < 1900)
			return false; 
		//month should not be greater than 12 and day 31
		else if(s[0] > 12 || s[1] > 31)
			return false;
		//month is 2 and day is greater than 29 
		else if(s[0] == 2 && s[1] >= 29){
			if (s[1] > 29)
				return false; 
			else if(!IsLeapYear(s[2]))
				return false;
			else
				return true;
		}
		else if((s[0] == 1 && s[1] >31) || +
				(s[0] == 3 && s[1] >31) || +
				(s[0] == 4 && s[1] >30) || +
				(s[0] == 5 && s[1] >31) || +
				(s[0] == 6 && s[1] >30) || +
				(s[0] == 7 && s[1] >31) || +
				(s[0] == 8 && s[1] >31) || +
				(s[0] == 9 && s[1] >30) || +
				(s[0] == 10 && s[1] >31) || +
				(s[0] == 11 && s[1] >30) || +
				(s[0] == 12 && s[1] >31)){
			return false; 
			}
		else
			return true;
	}
	else
		return  false;
}

function CheckToDateGreaterThanFromDate(strFromDate,strToDate){
	if(!checkDate(strFromDate) || !checkDate(strToDate))
		return false;
	else{
		var dFrom = new Date(strFromDate);
		var dTo = new Date(strToDate);
		
		if(dTo > dFrom)
			return true;
		else
			return false;
	}
}
function TodaysDate(){
	var strDate = new Date;
	var cMonth = strDate.getMonth() + 1;
	var cDay = strDate.getDate();
	var cYear = strDate.getFullYear();
	
	return cMonth+"/"+cDay+"/"+cYear;
}
function checkSelectedDateNotLessThanCurrentDate(strSelectedDate){
	var strDate = new Date();
	var dtCurrentDate =  new Date(TodaysDate());
	var dtDateCheck = new Date(strSelectedDate);
	if(dtDateCheck < dtCurrentDate)
		return true;
	else
		return false;
}

function Check5DigitZipCode(strZip){
	if(strZip.length != 5)
		return false;
	else if(!charsOccurIn(strZip,"0123456789"))
		return false;
	else
		return true; 
}
function CheckPhone(strPhone){
	strPhone = new String(strPhone);
	var blnReturn = false;
	var cFirst = new String("");
	var cMiddle = new String("");
	var cLast = new String("");
	var cFirstLine = new String("");
	var cSecondLine = new String("");
	
	if(strPhone != '' && strPhone.length == 12){
		cFirst = strPhone.substring(0,3);
		strPhone = strPhone.substring(3,strPhone.length);
		cFirstLine = strPhone.substring(0,1);
		strPhone = strPhone.substring(1,strPhone.length);
		cMiddle = strPhone.substring(0,3);
		strPhone = strPhone.substring(3,strPhone.length);
		cSecondLine = strPhone.substring(0,1);
		strPhone = strPhone.substring(1,strPhone.length);
		cLast = strPhone.substring(0,4);
		
		if(charsOccurIn(cFirst,"0123456789") && charsOccurIn(cFirstLine,"-") && 
				charsOccurIn(cMiddle,"0123456789") && charsOccurIn(cSecondLine,"-") && 
				charsOccurIn(cLast,"0123456789"))
			blnReturn = true;
	}
	return blnReturn 
}

function ShowWaitingMessage(ObjectToShow){	
	showhideBlockOnClick(ObjectToShow);
	//show counter up
	CounterUp(document.getElementById("spanCountUpWaiting"), "SPAN");
}
//show hide blocks
function showhideBlockWhileLoading(ObjectName,nShow){
	var objCat = document.getElementById(ObjectName);
	// n = 0 = not show
	// n = 1 = show
	if(objCat){
		if(nShow == 1) objCat.style.display="";
		else objCat.style.display="none";
	}
}
function showhideBlockOnClick(ObjectName) { 
	var objCat = document.getElementById(ObjectName);
	if(objCat){
		if (objCat.style.display=="none") objCat.style.display="";
		else objCat.style.display="none"; 
	}
}


//******************************************************************************

// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
// Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
// Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
//                      also added support for IE5.5 Opera4&5 HotJava3 AOLTV
// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, 
//                      correct Opera 5 detection
//                      add support for winME and win2k
//                      synch with browser-type-oo.js
// Revised 26 Mar 01 to correct Opera detection
// Revised 02 Oct 01 to add IE6 detection

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//     is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
// (2) browser version number:
//     is_major (integer indicating major version number: 2, 3, 4 ...)
//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
//     is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
//     is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
// (4) JavaScript version number:
//     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
//     is_os2
//     is_mac, is_mac68k, is_macppc
//     is_unix
//     is_sun, is_sun4, is_sun5, is_suni86
//     is_irix, is_irix5, is_irix6
//     is_hpux, is_hpux9, is_hpux10
//     is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//     is_linux, is_sco, is_unixware, is_mpras, is_reliant
//     is_dec, is_sinix, is_freebsd, is_bsd
//     is_vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when new versions of browsers are released, so
// in conditional code forks, use is_ie5up ("IE 5.0 or greater") 
// is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
// to check version in code which you want to work on future
// versions.

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1); 

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0;
    else if (is_nav3) is_js = 1.1;
    else if (is_opera5up) is_js = 1.3;
    else if (is_opera) is_js = 1.1;
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
    else if (is_hotjava3up) is_js = 1.4;
    else if (is_nav6 || is_gecko) is_js = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (is_nav6up) is_js = 1.5;
    // NOTE: ie5up on mac is 1.4
    else if (is_ie5up) is_js = 1.3

    // HACK: no idea for other browsers; always check for JS version with > or >=
    else is_js = 0.0;

    // *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) || 
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
               (agt.indexOf("windows 16-bit")!=-1) );  

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 || 
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) || 
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||   
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    // hack ie5 js version for mac
    if (is_mac && is_ie5up) is_js = 1.4;
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || 
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || 
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);    
    var is_aix2  = (agt.indexOf("aix 2") !=-1);    
    var is_aix3  = (agt.indexOf("aix 3") !=-1);    
    var is_aix4  = (agt.indexOf("aix 4") !=-1);    
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1); 
    var is_mpras    = (agt.indexOf("ncr")!=-1); 
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || 
                 is_sco ||is_unixware || is_mpras || is_reliant || 
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
