﻿/*
    This Script designed for Registration.aspx and loadesd on Grneral master page
    therefore if you have a control that named in listed below, this script will
    execute on that control too.
    
    'TextBoxUserName',
    'TextBoxUserPassword',
    'TextBoxPasswordConfirmation',
    'TextBoxUserEmail',
    'TextBoxBlogURL',
    'TextBoxBlogTitle
*/

var CPH='ctl00_ContentPlaceHolderMain_'

function SetTextChange()
{
    controlID = new Array(
    'TextBoxUserName',
    'TextBoxUserPassword',
    'TextBoxPasswordConfirmation',
    'TextBoxUserEmail',
    'TextBoxBlogURL',
    'CaptchaControl_TextBoxCaptchaTextConfirm',
    'TextBoxBlogTitle');

    var i=0
    for (i=0;i<7;i++)
    {
            controlID[i] = CPH + controlID[i];
            SetBorderColor(controlID[i]);
    }
}

function SetBorderColor(controlID)
{
    validatorID = new Array(
    'RequiredFieldValidator',
    'RegularExpressionValidator',
    'CustomValidator',
    'CompareValidator'
    );

    var i
    
    if ((controlID.toString().match('PasswordConfirmation')=='PasswordConfirmation') &&
    !(document.getElementById(CPH + 'CompareValidatorUserPassword').style.display == "none"))
    {
        document.getElementById(CPH + 'TextBoxUserPasswordConfirmation').style.border='red thin solid';
        return;
    }
    
            
    for (i=0;i<4;i++)
    {
        try
        {
            if (document.getElementById(controlID.toString().replace(/TextBox/,validatorID[i])).style.display == "none")
            {
                document.getElementById(controlID).style.border='none';
                if (document.getElementById(CPH + 'CompareValidatorUserPassword').style.display == "none")
                {
                    document.getElementById(CPH + 'TextBoxUserPasswordConfirmation').style.border='none';
                }
            }
            else
            {
                document.getElementById(controlID).style.border='red thin solid';
                return;
            }
        }
        catch(err){}    
    }
}