// $Id: web_pwd.js,v 1.9 2010/08/13 20:47:45 root Exp $
// 
// Created: 01.03.02
// Revised: 10.02.03
//
// Author: Jim Turner <jimt@netins.net>
//
// validate the web password changer form
//
///////////////////////////////////////////////////////
function chngpwCheckForm( tf )
{
    if( tf.username.value == "" )
    {
	alert( 'You must enter your complete email address as your username' );
	tf.username.focus();
	tf.username.select();

	return false;
    }

    var validEmail = tf.username.value.search( /^[^\@]+\@[^\.]+\.\w+$/ );
    if( validEmail != 0 )
    {
	alert( 'It doesn\'t appear as if you entered in your complete email' + 
	       'address for your username...\nplease enter your entire email' +
	       'address for your username' );

	tf.username.focus();
	tf.username.select();

	return false;
    }

    if( tf.password.value == "" )
    {
	alert( 'You must provide your password for authentication' );

	tf.password.focus();

	return false;
    }

    if( (tf.newpasswd.value.length < 6) || (tf.newpasswd.value.length > 16) )
    {
	alert( 'New passwords must be between 6 and 16 characters in length' );

	tf.verpasswd.value = "";
	tf.newpasswd.focus();
	tf.newpasswd.select();

	return false;
    }

    if( (tf.newpasswd.value != "") && (tf.verpasswd.value == "") )
    {
	alert( 'You must verify your new password by typing it a second time' );

	tf.verpasswd.focus();

	return false;
    }

    if( tf.newpasswd.value (/\b \b/i) != null) {
    {
        alert( 'You cannot have a space in your password' );

        tf.newpasswd.value = "";
        tf.verpasswd.value = "";

        tf.newpasswd.focus();

        return false;
    }

    if( tf.newpasswd.value != tf.verpasswd.value )
    {
	alert( 'You new passwords do not match.  Please type them in again' );

	tf.newpasswd.value = "";
	tf.verpasswd.value = "";

	tf.newpasswd.focus();

	return false;
    }	

    if( tf.password.value == tf.newpasswd.value )
    {
	alert( 'You are attempting to change your password to your existing password.\n' +
	       'Please pick a different new password' );

	tf.newpasswd.value = "";
	tf.verpasswd.value = "";

	tf.newpasswd.focus();

	return false;
    }	
	
    var comps = tf.username.value.split( "@" );
    if( tf.newpasswd.value == comps[0] )
    {
	alert( 'New password cannot be the same as your username' );

	tf.newpasswd.value = "";
	tf.verpasswd.value = "";

	tf.newpasswd.focus();
	
	return false;
    }

    return true;
}

function bodyFocus()
{
    document.theForm.username.focus();
}






