
	document.onkeypress = SubmitForm;
	var bNS			= (window.Event) ? 1 : 0;
	var poster		= document.getElementById("poster");
	var logon =  FindControl(document.forms[2],"vsLogonName")
	var logon1 =  FindControl(document.forms[2],"vsLogonName1")
	var myString = "";

	//set logon if there is a logon text box and cookie
	if (logon != null)
	{
		if( GetCookie("_logon") != null ) {
			logon.value = GetCookie("_logon") 
		}
	}
	if (logon1 != null)
	{
		if( GetCookie("_logon") != null ) {
			logon1.value = GetCookie("_logon") 
		}
	}
	
	function SubmitForm(event) 
	{			//Start Changes By M.M 10/30/2008
		if (bNS) 
		{
			//NETSCAPE
			if(event.keyCode == 13) 
			{
				if(window.location.href.toLowerCase().indexOf("r3-online") != -1
					|| window.location.href.toLowerCase().indexOf("bunzl-online" )!= -1	
					|| window.location.href.toLowerCase().indexOf("morganscott-online" )!= -1)
				{
					SelectUserAccount();
				}
				else
				{
					GoLogon(); 
				}
			}
		} 
		else
		{
			//IE
			if(window.event.keyCode == 13)
			{
				if(window.location.href.toLowerCase().indexOf("r3-online") != -1
					|| window.location.href.toLowerCase().indexOf("bunzl-online" )!= -1
					|| window.location.href.toLowerCase().indexOf("morganscott-online" )!= -1)
				{
					SelectUserAccount();
				}
				else
				{
					GoLogon(); 
				}
			}
		}			//End Changes By M.M 10/30/2008
	}
	
function FindControl(node, name) 
{
	var temp;
	if(node.id != null)
		myString += node.id + " ";
	if (node.nodeType == 1 && node.id.indexOf(name) > -1) 
	{ 
		return node;
	}
	else if (node.childNodes != null)
	{
		for (var i=0; i < node.childNodes.length; i++) { 
			temp = FindControl(node.childNodes.item(i), name); 
			if (temp != null)
			{
				return temp;
			}
		} 
	}
	return null;
}

	
function GoLogon() {

		oApp = FindControl(document.forms[2],"lApplication");
		url = FindControl(document.forms[2],"failure_URL")
		sURL = url.value.toLowerCase();
		password = FindControl(document.forms[2],"vsPassword")
		// Make sure they have selected an application
		if(oApp != null)
		{
			if(oApp.value == "0") 
			{
			// Not a valid selection
			alert("Please select an application before trying to login");
			return;
			}
			
			// Make sure they have provided a valid username and password
			if(ValidString(password.value) && ValidString(logon.value)) {
			
				setCookie("_logon", logon.value)
				// disable the login button so it is not clicked multiple times
				if(document.getElementById('logonButton').tagName.toLowerCase() == 'a')
					document.getElementById('logonButton').style.display = 'none';
				else
					document.getElementById('logonButton').disabled = true;
				
				poster.failure_URL.value = url.value
				poster.vslogonname.value = logon.value
				poster.vspassword.value = password.value
				//Submit Form
				poster.submit();
				
			} else {
				alert("Please enter a valid username and password");
			}
		}
		else
		{
			//after a while we'll probably need a hidden value for the site name and site id
			LogonIntrepid();
		}
	}
	function LogonIntrepid()
	{
		var intrepid		= document.getElementById("intrepid");
		intrepid.action = document.getElementById("postAction").value;
	
		intrepid.loginName.value = logon.value;
		intrepid.password.value = password.value;
		
		intrepid.submit();
		
	}
	function SetFormAction(oSelect) 
	{
		if (oSelect == null)
		{
			if(document.getElementById('postAction'))
				poster.action = document.getElementById('postAction').value;
		}
		else
		{
			if (oSelect.value == 1)
			{
				poster.action = "/access/default.aspx";
			} 
			else if (oSelect.value == 2) 
			{
				poster.action = "/community/default.aspx";
			}
		}
		
		
	}
	function GoPwdHelp() {
		var sLogonName = PopUpWin("/assets/sendpassword.aspx", 350, 150);
	}
	//Set the form to post on load
	SetFormAction(FindControl(document.forms[2], "lApplication"));
