/* $Id: AddUserFunctions.js,v 1.3 2003/11/10 15:21:40 prabhukm Exp $ */

// Function to initialize the fields based on checkbox' state
function init()
{
    if(eval(document.AddUserForm.userName))
    {
        document.AddUserForm.userName.focus();
    }
}

//Function to enable/disable newgroup field based on the corresponding checkbox
function newGroupCheck()
{
        if(document.AddUserForm.ifnewgroup.checked)
        {
                document.AddUserForm.newGroup.disabled = false;
                document.AddUserForm.newGroup.focus();
                document.AddUserForm.newGroup.className = "formStyle";
        }
        else
        {
                document.AddUserForm.newGroup.value = "";
                document.AddUserForm.newGroup.disabled = true;
                document.AddUserForm.newGroup.className = "formStyleDisabled";
        }
}

//Function to enable/disable PasswordExpirytime field based on the corresponding checkbox
function PasswordExpCheck()
{
        if(document.AddUserForm.ispasswordexpiry.checked)
        {
                document.AddUserForm.passwordExpiryTime.disabled = false;
                document.AddUserForm.passwordExpiryTime.focus();
                document.AddUserForm.passwordExpiryTime.className = "formStyle";
        }
        else
        {
                document.AddUserForm.passwordExpiryTime.value = "";
                document.AddUserForm.passwordExpiryTime.disabled = true;
                document.AddUserForm.passwordExpiryTime.className = "formStyleDisabled";
        }
}

//Function to enable/disable AccountExpiryTime field based on the corresponding checkbox
function AccountExpCheck()
{
        if(document.AddUserForm.isaccountexpiry.checked)
        {
                document.AddUserForm.accountExpiryTime.disabled = false;
                document.AddUserForm.accountExpiryTime.focus();
                document.AddUserForm.accountExpiryTime.className = "formStyle";
        }
        else
        {
                document.AddUserForm.accountExpiryTime.value = "";
                document.AddUserForm.accountExpiryTime.disabled = true;
                document.AddUserForm.accountExpiryTime.className = "formStyleDisabled";
        }
}

function resetFields()
{
    document.AddUserForm.reset();
    document.AddUserForm.newGroup.disabled = true;
    document.AddUserForm.newGroup.className = "formStyleDisabled";
    document.AddUserForm.passwordExpiryTime.disabled = true;
    document.AddUserForm.passwordExpiryTime.className = "formStyleDisabled";
    document.AddUserForm.accountExpiryTime.disabled = true;
    document.AddUserForm.accountExpiryTime.className = "formStyleDisabled";
}
