// Ultimate client-side JavaScript client sniff.
// (C) Netscape Communications 1999.  Permission granted to reuse and distribute.
// http://developer.netscape.com/docs/examples/javascript/browser_type_oo.html
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when Nav5 and IE5 (or later) are released, so
// in conditional code forks, use is.nav4up ("Nav4 or greater")
// and is.ie4up ("IE4 or greater") instead of is.nav4 or is.ie4
// to check version in code which you want to work on future
// versions.
// jmr removed code for browsers/os's that we don't support
function Is ()
{   // 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.
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    // check first for firefox
	 this.firefox = (agt.indexOf('firefox')!=-1);

    // check first for safari
	 this.safari = (agt.indexOf('safari')!=-1);

    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('firefox')==-1)
					 && (agt.indexOf('safari')==-1));

    this.nav2 = (this.nav && (this.major == 2));
    this.nav3 = (this.nav && (this.major == 3));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    this.nav5 = (this.nav && (this.major == 5));
    this.nav5up = (this.nav && (this.major >= 5));

    this.nav6 = (this.nav && (this.major == 6));
    this.nav6up = (this.nav && (this.major >= 6));

    this.ie   = (agt.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major < 4));
    this.ie4  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.")==-1) && (agt.indexOf("msie 6.")==-1) );
    this.ie4up  = (this.ie  && (this.major >= 4));
    this.ie5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);

    this.ie55  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5")!=-1) );
    this.ie55up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie55);

// *** JAVASCRIPT VERSION CHECK ***
    if (this.nav2 || this.ie3) this.js = 1.0
    else if (this.nav3 || this.opera) this.js = 1.1
    else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2
    else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3
    else if (this.nav5) this.js = 1.4
    // 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 (this.nav && (this.major > 5)) this.js = 1.4
    else if (this.ie && (this.major > 5)) this.js = 1.3
    // HACK: no idea for other browsers; always check for JS version with > or >=
    else this.js = 0.0;

    // *** PLATFORM ***
    this.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.
    this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    this.win16 = ((agt.indexOf("win16")!=-1) ||
                  (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
                  (agt.indexOf("windows 16-bit")!=-1) );

    this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                  (agt.indexOf("windows 16-bit")!=-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".
    this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    this.win32 = ( this.win95 || this.winnt || this.win98 ||
                   ((this.major >= 4) && (navigator.platform == "Win32")) ||
                   (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1) );

    this.mac    = (agt.indexOf("mac")!=-1);
    this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) ||
                               (agt.indexOf("68000")!=-1)));
    this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) ||
                               (agt.indexOf("powerpc")!=-1)));
}

var is = new Is();
var isNetscape = is.nav;
var isIE = is.ie;
var isMac = is.mac;
var isSafari = is.safari;


function printPage() {
	var da = (document.all) ? 1 : 0;
	var pr = (window.print) ? 1 : 0;
	if (pr) // NS4, IE5
		window.print();
	else if (isMac)
		alert("Press Cmd+P to print this page");
	else // other browsers
	 alert("Sorry, your browser doesn't support this feature.");
	return false;
}

function printMainFrame() {
	var da = (document.all) ? 1 : 0;
	var pr = (window.print) ? 1 : 0;
	if (pr) // NS4, IE5
	{
		window.parent.mainFrame.focus();
		window.print();
	}
	else if (isMac)
		alert("Press Cmd+P to print this page");
	else // other browsers
	 alert("Sorry, your browser doesn't support this feature.");
}

function getIframeDoc(iframeObj) {
	var iframeDoc;
	if (iframeObj.contentDocument) {
		// For NS6
		iframeDoc = iframeObj.contentDocument;
	} else if (iframeObj.contentWindow) {
		// For IE5.5 and IE6
		iframeDoc = iframeObj.contentWindow.document;
	} else if (iframeObj.document) {
		// For IE5
		iframeDoc = iframeObj.document;
	} else {
		alert('none of the above');
	}

	return(iframeDoc);
}


function setIframeLocation(iframeObj, loc) {
	var iframeDoc = getIframeDoc(iframeObj);
	iframeDoc.location.href = loc;
}

function getIframeLocation(iframeObj) {
	var iframeDoc = getIframeDoc(iframeObj);
	return (iframeDoc.location.href)
}

/* CVS Change Log
$Log: detect.js,v $
Revision 1.2  2008/11/17 21:33:06  ztracCVS
- added a func to print the main frame so the page doesn't have to reload

*/