function submitLogin() {
	document.loginForm.password.value = hex_md5('dnej'+document.loginForm.password.value);
}
function submitRegister() {
	var error = "";
	error += checkUserName(document.loginForm.username.value);
	error += checkEmail(document.loginForm.email.value);
	if (document.loginForm.password.value != document.loginForm.confirmpw.value) {
		error += "Password confirmation did not match. \n\r";
	}
	if (document.loginForm.password.value == '') {
		error += "Password cannot be blank. \n\r";
	}
	if (document.loginForm.tosPrivacyNotice.checked == false) {
		error += 'You must agree to the Terms of Service and Privacy Policy. \n\r';
	}
	if (error != "") {
		alert(error);
		return false;
	} 
	document.loginForm.password.value = hex_md5('dnej'+document.loginForm.password.value);
	document.loginForm.confirmpw.value = hex_md5('dnej'+document.loginForm.confirmpw.value);
	return true;
}
function submitReset() {
	var error = "";
	error += checkUserName(document.loginForm.username.value);
	if (document.loginForm.password.value != document.loginForm.confirmpw.value) {
		error += "Password confirmation did not match. \n\r";
	}
	if (document.loginForm.password.value == '') {
		error += "Password cannot be blank. \n\r";
	}
	if (error != "") {
		alert(error);
		return false;
	} 
	document.loginForm.password.value = hex_md5('dnej'+document.loginForm.password.value);
	document.loginForm.confirmpw.value = hex_md5('dnej'+document.loginForm.confirmpw.value);
	return true;
}
function checkUserName(address) {
	if (address == '') {
		return 'Username cannot be left blank \n\r';
	}
	var ok = "1234567890qwertyuiopasdfghjklzxcvbnm_QWERTYUIOPASDFGHJKLZXCVBNM";
	//
	for(i=0; i < address.length ;i++){
		if(ok.indexOf(address.charAt(i))<0){ 
			return 'Username contains invalid characters, use only letters and numbers, spaces are not allowed. \n\r';
		}
	}
	return '';
}
function checkEmail(address) {
	var ok = "@1234567890qwertyuiop[]asdfghjklzxcvbnm.-_QWERTYUIOPASDFGHJKLZXCVBNM";
	//
	for(i=0; i < address.length ;i++){
		if(ok.indexOf(address.charAt(i))<0){ 
			return 'Email contains invalid characters \n\r';
		}
	}
	var email_array=address.split("@");
	if (email_array.length != 2) {
		return 'Email should contain 1 @ symbol \n\r';
	}
	var siteCheck = email_array[1].split(".");
	if (siteCheck.length > 1) {
		if (siteCheck[(siteCheck.length-1)].length > 4) {
			return 'Email address invalid \n\r';
		}
	} else {
		return 'Incomplete email address \n\r';
	}
	return '';
}