/* Copyright 2011 Coast Guard Auxiliary Association, Inc. All Rights Reserved. */
function SubmitAuth() {
	// javascript:this.disabled=true;
	if (document.auth.eid.value == "" && document.auth.clearpass.value == "") {
		window.alert("ERROR - MISSING INPUT\n\nPlease enter your Auxiliary Employee ID and AuxDirectory password.");
		document.auth.login.disabled = false; // allow use of the login button
		return;
	} else if (document.auth.eid.value == "") {
		window.alert("ERROR - MISSING INPUT\n\nPlease enter your Auxiliary Employee ID.");
		document.auth.login.disabled = false; // allow use of the login button
		return;
	} else if (document.auth.clearpass.value == "") {
		window.alert("ERROR - MISSING INPUT\n\nPlease enter your AuxDirectory password.");
		document.auth.login.disabled = false; // allow use of the login button
		return;
	}

	if (md5_vm_test() == true) {
		//window.alert("document.auth.remember[0].checked=" + document.auth.remember[0].checked);
		if (document.auth.remember[0].checked) {
			// Do not store any cookies. Delete in case previously used.
			deleteCookie("Auxeid", "");
			deleteCookie("Auxpass", "");
		}
		if (document.auth.remember[1].checked) {
			// Do not store the password cookie. Delete in case previously used.
			deleteCookie("Auxpass", "");
		}
		if (document.auth.remember[1].checked || document.auth.remember[2].checked) {
			setCookie("Auxeid", document.auth.eid.value, "", 12);
		}
		if (document.auth.remember[2].checked) {
			setCookie("Auxpass", document.auth.clearpass.value, "", 12);
		}

		document.auth.pass.value = hex_md5(document.auth.clearpass.value.toUpperCase());
		document.auth.clearpass.value = "";
		document.auth.submit();
	} else {
		document.write("ERROR Unable to encrypt your password - login failed.");
	}
}
