function validateSignIn(e)
{
	if ( !e ) var e = window.event;
	if (e.target) var targ = e.target;
	else if (e.srcElement) var targ = e.srcElement;
	if (targ.nodeType == 3) var targ = targ.parentNode;		// defeat Safari bug

	var oForm = targ.form;

	// Lock the form to prevent double-click saves
	if ( gForm_lock ) return;
	else gForm_lock = true;

	var errors	= new ErrorList();

	clearInputErrors(oForm);

	var email		= getInputValue(oForm["email"]);
	var password	= getInputValue(oForm["password"]);

	if ( email == "" || email == "Email" ) setError(oForm["email"], errors, "Please enter your email address\n");
	else if ( !checkEmail(email) ) setError(oForm["email"], errors, "Invalid email address\n");
	if ( !checkAlphaNum(password) )
	{
		setError(oForm["password_text"], errors, "Your password can only be characters and numbers\n");
		setError(oForm["password"], errors);
	}
	else if ( password.length < 6 )
	{
		setError(oForm["password_text"], errors, "Your password must be at least 6 characters/digits long\n");
		setError(oForm["password"], errors);
	}

	if ( errors.getNumErrors() )
	{
		errors.showErrors();
		gForm_lock = false;
	}
	else oForm.submit();
}


// Called when the password box in the top status bar is clicked or focused on.  Changes the box to a password box.
function checkPasswordInput(oInput)
{
	var oForm = oInput.form;
	var prefix = getInputValue(oForm["prefix"]);
	document.getElementById(prefix+"_password_text").style.display = "none";
	document.getElementById(prefix+"_password").style.display = "inline";
	document.getElementById(prefix+"_password").focus();
}

function validateNewAccount()
{
    // Lock the form to prevent double-click saves
	if ( gForm_lock ) return;
	else gForm_lock = true;

	var errors	= new ErrorList();
	var oForm	= document.getElementById("new_account");

	clearInputErrors(oForm);

	var first_name		= getInputValue(oForm["first_name"]);
	var last_name		= getInputValue(oForm["last_name"]);

	var company			= getInputValue(oForm["company"]);
	var email			= getInputValue(oForm["email"]);
	var email_2			= getInputValue(oForm["email_2"]);
	var user_type_id	= getInputValue(oForm["user_type_id"]);

	var password		= getInputValue(oForm["password"]);

	if ( first_name.length == 0 ) setError(oForm["first_name"], errors, "Your first name cannot be blank\n");
	else if ( !checkTheseChars(first_name, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '.-") ) setError(oForm["first_name"], errors, "Your first name must be alpha-numeric and space ' . -\n");

	if ( last_name.length == 0 ) setError(oForm["last_name"], errors, "Your last name cannot be blank\n");
	else if ( !checkTheseChars(last_name, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '.-") ) setError(oForm["last_name"], errors, "Your last name must be alpha-numeric and space ' . -\n");

	if ( company.length == 0 ) setError(oForm["company"], errors, "Your company name cannot be blank\n");

	if ( !checkEmail(email) ) setError(oForm["email"], errors, "Invalid email address\n");
	else if ( email != email_2 )
	{
		setError(oForm["email"], errors, "Your email addresses do not match\n");
		setError(oForm["email_2"], errors);
	}


	if ( !user_type_id || user_type_id == "0" ) setError(oForm["user_type_id"], errors, "Please select your description\n");

	if ( !checkAlphaNum(password) ) setError(oForm["password"], errors, "Your password can only be characters and numbers\n");
	else if ( password.length < 6 ) setError(oForm["password"], errors, "Your password must be at least 6 characters/digits long\n");


	if ( errors.getNumErrors() )
	{
		errors.showErrors();
		gForm_lock = false;
        return false;
	}
	else
    {
        oForm.submit();
    }
}

function validateNewAccount1()
{
	if ( gForm_lock ) return;
	else gForm_lock = true;

	var errors	= new ErrorList();
	var oForm	= document.getElementById("new_account");

	clearInputErrors(oForm);

	var first_name		= getInputValue(oForm["first_name"]);
	var last_name		= getInputValue(oForm["last_name"]);

	var company			= getInputValue(oForm["company"]);
	var email			= getInputValue(oForm["email"]);
	var email_2			= getInputValue(oForm["email_2"]);
	var user_type_id	= getInputValue(oForm["user_type_id"]);

	var password		= getInputValue(oForm["password"]);

	if ( first_name.length == 0 ) setError(oForm["first_name"], errors, "Your first name cannot be blank\n");
	else if ( !checkTheseChars(first_name, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '.-") ) setError(oForm["first_name"], errors, "Your first name must be alpha-numeric and space ' . -\n");

	if ( last_name.length == 0 ) setError(oForm["last_name"], errors, "Your last name cannot be blank\n");
	else if ( !checkTheseChars(last_name, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '.-") ) setError(oForm["last_name"], errors, "Your last name must be alpha-numeric and space ' . -\n");

	if ( company.length == 0 ) setError(oForm["company"], errors, "Your company name cannot be blank\n");

	if ( !checkEmail(email) ) setError(oForm["email"], errors, "Invalid email address\n");
	else if ( email != email_2 )
	{
		setError(oForm["email"], errors, "Your email addresses do not match\n");
		setError(oForm["email_2"], errors);
	}


	if ( !user_type_id || user_type_id == "0" ) setError(oForm["user_type_id"], errors, "Please select your description\n");

	if ( !checkAlphaNum(password) ) setError(oForm["password"], errors, "Your password can only be characters and numbers\n");
	else if ( password.length < 6 ) setError(oForm["password"], errors, "Your password must be at least 6 characters/digits long\n");


	if ( errors.getNumErrors() )
	{
		errors.showErrors();
		gForm_lock = false;
        return false;
	}
	else
    {
        document.getElementById("complete_my_profile").value ="1";
        oForm.submit();
    }
}
