function validateLogin(theForm) {
	var reason = "";
	//this function is in the ssoCommonValidation.js
	reason += ssoValidateLoginFields(theForm.username.value);
	if (reason != "") {
		var innerdiv = document.getElementById("errorMessage");
		if (innerdiv != null) {
			innerdiv.innerHTML = reason;
		}
		$('lblusername').className = "error";
		$('errorMessageContainer').style.display = 'inline';
		return false;
	} else {
		$('lblusername').className = "";
		$('errorMessageContainer').style.display = 'none';
		
		theForm.event.value = "validateUser";
		
		//document.getElementById('loginBox').style.display = 'none';
		//document.getElementById("loginProcessing").innerHTML = document.getElementById("loginProcessing").innerHTML;
		//document.getElementById("loginProcessing").className = "login_Customer";
		//document.getElementById('loginProcessing').style.display = 'block';
		
		Director.directRequest('Members');
	}
}

function registerNewUser(theForm) {
	theForm.event.value = "newUserRegistration";
	Director.directRequest('NewUser');
}

function forgotUserName(theForm) {
	theForm.event.value = "forgotUserName";
	Director.directRequest('ForgotUserName');
}

function handlePersistentUserName(strUserNameElementId, strRememberCheckboxElementId, strCookieName) {
	var cookieValue = getCookieValue(strCookieName);
	if (cookieValue.length > 0) {
		document.getElementById(strUserNameElementId).value = cookieValue;
		document.getElementById(strRememberCheckboxElementId).checked = true;
	}
}

function getCookieValue(cookieName) {
	var search = cookieName + "=";
	var returnValue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		// if cookie exists
		if (offset != -1) {
			offset += search.length;
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1) {
				end = document.cookie.length;
			}
			returnValue = unescape(document.cookie.substring(offset, end));
		}
	}
	return returnValue;
}

function cancelPage() {
	document.PrimaryloginForm.event.value = "ssoMessagePage";
	document.PrimaryloginForm.submit();
}
