var isNav = (navigator.appName.indexOf("Netscape") != -1);
var isIE = (navigator.appName.indexOf("Microsoft") != -1);
var EKey;

if(isNav) 
{	
	
	window.captureEvents(Event.KEYDOWN | Event.SUBMIT );
	window.onkeydown = NavEnter;
	window.onsubmit = NavSubmit;
}
if(isIE)
{
	
	document.onkeydown = IEEnter;	
}
/* this function redirects an enter key to 
the appropriate button. If the text box is name SearchValue it
clicks the button called SearchButton, otherwise no action occurs.
*/

/* this is the IE Version of the two functions above 
*/
function IEEnter()
{

	var e = window.event; 
	if(e.keyCode == 13)
	{
	if(e.srcElement.type.toUpperCase()=='SUBMIT' || e.srcElement.type.toUpperCase()=='TEXTAREA' ){
		return true;
	}
		if (e.srcElement.attributes["ButtonToClick"] != null)
		{
			var Bindex =  e.srcElement.attributes["ButtonToClick"].value;
			var BtoClick = document.all[Bindex];
			if(BtoClick != null)
			{		
			
				BtoClick.click();
				e.keyCode = 0;
				e.cancelBubble = true;
				return false;
			}
		}	
		else
		{
			e.keyCode = 0;
			e.cancelBubble = true;
			return false;
		}		
	}	
	return true;
}

/* these two functions work together to prohibit any actions
from hitting Enter 
*/
function NavEnter(e)
{
	if(e.keyCode == 13)
	{
		document.EKey = true;
		//alert("NAV:Enter came from: " + e.target.name);	
	}
	else
	{
		document.EKey = false;
	}	
}
function NavSubmit()
{
	if(document.EKey == true)
	{
		//alert("cancel submit");
		document.EKey = false;
		return false;
	}	
}

