// Last revised January 16, 2001, PRH

// *********************************************************************************
//                        		 BROWSER DETECTION SCRIPT 
//                          Called when you include this page
// *********************************************************************************


var gBrowser = new Object();	// store information about browser compatibility
								// don't use this name for other variables!


// --------------------------------------------------------------------------------------
//
// 		SniffBrowser
//
//			Check browser compatibility (just for version 3 and version 4 and up)
// 			On entry: nothing to pass in
//			On exit: 
//				gBrowser.isNavigator will be true if the browser is a Netscape product
//				gBrowser.isIE will be true if the browser is a Microsoft product
//				gBrowser.compatible will be 3 or 4, depending on the browser version
//				  This variable is probably what you'll most need to check.
//
// --------------------------------------------------------------------------------------

function SniffBrowser()	{
	gBrowser.version = parseInt(navigator.appVersion);
	gBrowser.isNavigator = false;
	gBrowser.isIE = false;
	if (navigator.appName.indexOf("Netscape") != -1)	{
		gBrowser.isNavigator = true;
	}
	else if (navigator.appName.indexOf("Microsoft") != -1)	{
		gBrowser.isIE = true;
	}
	gBrowser.compatible = 0;
	if ((gBrowser.isNavigator) || (gBrowser.isIE))	{
		if (gBrowser.version >= 4)	{
			gBrowser.compatible = 4;
		}
		else if (gBrowser.version >= 3)	{
			gBrowser.compatible = 3;
		}
	}
}


// Other scripts require browser information, so call the script now

SniffBrowser();



// *********************************************************************************
//                        		 KEYPRESS DETECTION SCRIPTS 
// *********************************************************************************

//--------------------------------------------------------------------------------
//
//	TestKey
//		Action: If the return key was pressed in a form field, submit the form
//			Typically, assign this function to a password field using the
//			SetKeyPressHandler script below.
//		On entry: If we're in Navigator 4, an event object is passed in evt
//			In IE 4 we have to retrieve the event from window.event
//			Similar twists are used to find the fied's form object
//		On exit: if the return/enter key was hit in the field we're handling, 
//			submit the form that contains it.
//
//--------------------------------------------------------------------------------


	function TestKey(evt)	{
		var currentForm;
		
		if (gBrowser.isIE == true)	{
			evt = window.event;
			currentForm = window.event.srcElement.form;
		}
		if (gBrowser.isNavigator == true)	{
			currentForm = evt.target.form;
		}
		if (evt.which == 13)	{
			currentForm.submit();
		}
	}
	
	
	
//--------------------------------------------------------------------------------
//
//	SetKeyPressHandler
//		Action: If we're using a level 4 browser, assign a text field
//			an onKeyPress handler
//		On entry: typically, call from body tag's ONLOAD attribute, 
//			passing in references to the field and the function to execute
//		On exit: onkeypress handler func is assigned to field fieldref
//
//--------------------------------------------------------------------------------

	function SetKeyPressHandler(fieldref, func, useCloseEvent)	{
		if (gBrowser.compatible == 4)	{
			fieldref.onkeypress = func;
		}
	}
	


