// JavaScript Document
// Validate the Person form before submitting it
function validate(thisform)
{
	var posting	= true;
	with (thisform)
	{
		if(actionStep.value == 'Delete')
		{
			var ok=confirm('Please confirm you wish to delete this account');
			return ok;
		}
		if(username.value == "")
		{
			username.value = email.value;
		}
		if(!validate_required(username, "A user name is required")) { posting = false; }
		if (document.getElementById)
		{
			var pwdreqd	= document.getElementById("pwd");
			if (pwdreqd.getAttribute("value") != "no check")
			{
				if (!validate_required(password, "Please enter a password"))  { posting = false; }
				if (!validate_required(password_again, "Please enter the password again")) { posting = false; }
				if (!validate_match(password, password_again, "This password does not match the first one")) 	{ posting = false; }
				if (!validate_required(passwordHint, "Please enter a password hint")) { posting = false; }
				if (!validate_required(passwordSecurityAnswer, "Please enter an answer to one of the security questions")) { posting = false; }
			}
		}
		if(MyAdmin.value == '0' || MyAdmin.value == '')
		{
			if (!validate_required(discipline, "Please specify your discipline. You may select one from the drop-down list.")) { posting = false; }
		}
		if (!validate_required(nameLast,"Please enter your name")) 	{ posting = false; }
		if (!validate_email(email,"The e-mail address needs a name, a @-sign and a URL")) 	{ posting = false; }
		if (!validate_match(email,email_again,"E-mail addresses do not match")) 	{ posting = false; }
		if (!validate_phone(phoneWork)) { posting = false; }
		if (!validate_phone(phoneHome)) { posting = false; }
		if (!validate_phone(phoneCell)) { posting = false; }
		if (!validate_phone(phoneFax)) { posting = false; }
		var step	= document.getElementById('actionStep');
		step.setAttribute("value", "publish");
		return posting;
	}
}
function removeDiscError()
{
	disc =	document.getElementById('discipline');
	if(disc.className)
	{
		disc.className = disc.className.substring(0, disc.className.lastIndexOf(' '));
	}
	if(disc.hasError)
	{
		try { disc.parentNode.removeChild(disc.hasError); }
		catch(err) { }
	}
	disc.hasError = null;
	disc.onchange = null;
}

