<!--
// Javascript necessary for GV Login

//show the login portion of the left nav if this file is include
//note: this file MUST be included AFTER letnav.html

	function DoLoadGVForm(form) {
		document.getElementById('UserName').value = GetCookie("LastUsername");
		if((document.getElementById('UserName').value == "") || (document.getElementById('UserName').value == "User Name") ) {
			document.getElementById('UserName').value = "User Name"
			document.getElementById('UserPwd').value = ""
			document.getElementById('UserName').select();
		} else {
            $(".signin").click();
		}
	}
	
	// Retrieve the value of the cookie with the specified name.
	function GetCookie(sName)
	{
		// cookies are separated by semicolons
		var aCookie = document.cookie.split("; ");
		for (var i=0; i < aCookie.length; i++)
		{
			// a name/value pair (a crumb) is separated by an equal sign
			var aCrumb = aCookie[i].split("=");
			if (sName == aCrumb[0]) 
			return unescape(aCrumb[1]);
		}

		// a cookie with the requested name does not exist
		return "";
	}
	
	function SetCookie (name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
		// set expiry date to 1 year from now.
		var largeExpDate = new Date ();
		largeExpDate.setTime(largeExpDate.getTime() + (365 * 24 * 3600 * 1000));
        document.cookie = name + "=" + escape (value) +
                ((largeExpDate == null) ? "" : ("; expires=" + largeExpDate.toGMTString())) +
                ((path == null) ? "" : ("; path=" + path)) +
                ((domain == null) ? "" : ("; domain=" + domain)) +
                ((secure == true) ? "; secure" : "");
	}
	
	function DoKeyPress() {
		if(event.keyCode == 13) {
			DoLogin();
		}
	}
	var launched;
	
	function DoLogin() {
		//save the profile and username
		SetCookie('LastProfile', document.getElementById('Profile').value);
		SetCookie('LastUsername', document.getElementById('UserName').value);
		LaunchLogin();									
		//document.getElementById('UserPwd').value = ''; //had to be commented out- for some reason the password field is cleared before the form submission.  Even when this line is moved to below the call to submit() in LaunchLogin(), it is still a problem
	}
	
	function LaunchLogin(){
		try {
			// Close any open window
			if(launched) {
				if(launched.GVClose) {
					launched.GVClose();
				}										
			}
		} catch (e) { /* Do Nothing */ }
		
		launched = window.open("templates/LoggingIn.htm", "GVLogin","resizable=yes,scrollbars=yes,menubar=yes,toolbar=no,status=yes,location=no")
		document.getElementById("signin").submit();
	}
	var OKToNavigate = true;
	
	function NavigateToPage(page) {
		if (OKToNavigate) {
		OpenWin = this.open(page, "GrandView", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");	
		}
	}
-->

