Ffunction JavaScriptOfWindows() {
    ddlZone_SelectedIndexChanged();
}

function JavaScriptOfForms() {
    ddlZone_SelectedIndexChanged();
}

function rdbExcludeUser_CheckedChanged(str1, str2) {
    try {
        //alert('asdf');
        //alert(_TblMainClientId);
        var rdoUser = document.getElementById(_RdbExcludeUserClientId);
        var rdoGroup = document.getElementById(_RdbExcludeGroupClientId);
        var lblMessage = document.getElementById(_LblExcludedAccountClientId);
        if ((rdoUser != null) && (rdoGroup != null) && (lblMessage != null)) {
            if (rdoUser.checked) {
                lblMessage.innerHTML = str2;
            }
            else if (rdoGroup.checked) {
                lblMessage.innerHTML = str1;
            }
        }
    }
    catch (ex) {
        alert(ex);
    }
}

function Split(str, separator, index) {
    var temp = str;
    try {
        var indexSeparator = temp.indexOf(separator)
        var indexValue = 0;
        while (indexSeparator > 0) {
            if (indexValue == index) {
                return temp.substring(0, indexSeparator);
            }
            temp = temp.substring(indexSeparator + separator.length);
            indexSeparator = temp.indexOf(separator);
            indexValue++;
            if (indexValue > 1000) {
                break;
            }
        }
        if (indexValue == index) {
            return temp;
        }
    }
    catch (ex) {
        alert(ex);
    }
    return temp;
}

var SplitItem = "~#~";
var SplitValueText = "~;~";

function SetSplitItem(strValue) {
    SplitItem = strValue;
}

function SetSplitValueText(strValue) {
    SplitValueText = strValue;
}

function ddlZone_SelectedIndexChanged() {
    try {
        var lblChooseMode = document.getElementById(_LblChooseModeClientId);
        var rdbQuestion = document.getElementById(_RdbQuestionClientId);
        var rdbEmail = document.getElementById(_RdbEmailClientId);

        var ddlZones = document.getElementById(_DdlZonesClientId);
        var lblAutMode = document.getElementById(_LblAuthenticationModeDetailClientId);
        var lblMsProvider = document.getElementById(_LblMembershipProviderDetailClientId);
        var lblMsProviderDescription = document.getElementById(_LblMembershipProviderClientId);
        var lblZoneUrl = document.getElementById(_LblZoneUrlDetailClientId);
        var lbClaimType = document.getElementById(_LbClaimTypeClientId);
        var rdbFBAClaims = document.getElementById(_RdbFBAClaimsClientId);
        var rdbWindowsClaims = document.getElementById(_RdbWindowsClaimsClientId);
        var chkRequiredSecurityQuestion = document.getElementById(_ChkRequiredSecurityQuestionClientId);
        var tblAdmin = document.getElementById(_TblAdministrativeOptionsClientId);

        if ((ddlZones != null) && (lblAutMode != null) &&
			(lblMsProviderDescription != null) && (lblMsProvider != null) &&
			(lblZoneUrl != null) && (tblAdmin != null) && (lbClaimType != null) && (rdbFBAClaims != null) && (rdbWindowsClaims != null) &&
			(chkRequiredSecurityQuestion != null)) {
            //Display all controls
            lblAutMode.style.display = '';
            lblMsProviderDescription.style.display = '';
            var tdProvider = lblMsProviderDescription.parentNode;
            if (tdProvider != null) {
                tdProvider.style.display = '';
            }
            lblMsProvider.style.display = '';
            lblZoneUrl.style.display = '';
            tblAdmin.style.display = '';
            chkRequiredSecurityQuestion.style.display = '';
            lbClaimType.style.display = '';
            rdbWindowsClaims.style.display = '';
            var tdWindowsClaims = rdbWindowsClaims.parentNode;
            if (tdWindowsClaims != null) {
                tdWindowsClaims.style.display = '';
            }

            rdbFBAClaims.style.display = '';
            var tdrdbFBAClaims = rdbFBAClaims.parentNode;
            if (tdrdbFBAClaims != null) {
                tdrdbFBAClaims.style.display = '';
            }
            var tdRequiredSecurityQuestion = chkRequiredSecurityQuestion.parentNode;
            if (tdRequiredSecurityQuestion != null) {
                tdRequiredSecurityQuestion.style.display = '';
            }
            lblChooseMode.style.display = '';
            rdbQuestion.style.display = '';
            var tdQuestion = rdbQuestion.parentNode;
            if (tdQuestion != null) {
                tdQuestion.style.display = '';
            }
            rdbEmail.style.display = '';
            var tdEmail = rdbEmail.parentNode;
            if (tdEmail != null) {
                tdEmail.style.display = '';
            }

            //Value of zone
            var item = ddlZones.value;

            //Zone information
            var authenticationMode = '';
            var membershipProvider = '';
            var zoneUrl = '';
            var useWindowsClaim = '';
            var useFBAClaim = '';
            if (item.indexOf(SplitValueText) > 0) {
                authenticationMode = Split(item, SplitValueText, 0);
                membershipProvider = Split(item, SplitValueText, 1);
                zoneUrl = Split(item, SplitValueText, 2);
                useWindowsClaim = Split(item, SplitValueText, 3);
                useFBAClaim = Split(item, SplitValueText, 4);

                lblAutMode.innerHTML = authenticationMode;
                lblMsProvider.innerHTML = membershipProvider;
                lblZoneUrl.innerHTML = zoneUrl;

                if (authenticationMode == 'Windows') {
                    lblMsProvider.style.display = 'none';
                    lblMsProviderDescription.style.display = 'none';
                    if (tdProvider != null) {
                        tdProvider.style.display = 'none';
                    }
                    lbClaimType.style.display = 'none';
                    rdbWindowsClaims.style.display = 'none';
                    if (tdrdbFBAClaims != null) {
                        tdrdbFBAClaims.style.display = 'none';
                    }
                    if (tdWindowsClaims != null) {
                        tdWindowsClaims.style.display = 'none';
                    }

                    rdbFBAClaims.style.display = 'none';
                    chkRequiredSecurityQuestion.style.display = 'none';
                    if (tdRequiredSecurityQuestion != null) {
                        tdRequiredSecurityQuestion.style.display = 'none';
                    }
                    WindowModeToResetPassword();
                }
                else {
                    if (useWindowsClaim == 'true' && useFBAClaim == 'true') {
                        if (rdbFBAClaims.checked) {
                            tblAdmin.style.display = 'none';
                            lblChooseMode.style.display = 'none';
                            rdbQuestion.style.display = 'none';
                            if (tdQuestion != null) {
                                tdQuestion.style.display = 'none';
                            }
                            rdbEmail.style.display = 'none';
                            if (tdEmail != null) {
                                tdEmail.style.display = 'none';
                            }

                            FormModeToResetPassword();
                        }
                        else if (rdbWindowsClaims.checked) {
                            lblMsProvider.style.display = 'none';
                            lblMsProviderDescription.style.display = 'none';
                            if (tdProvider != null) {
                                tdProvider.style.display = 'none';
                            }
                            chkRequiredSecurityQuestion.style.display = 'none';
                            if (tdRequiredSecurityQuestion != null) {
                                tdRequiredSecurityQuestion.style.display = 'none';
                            }
                            WindowModeToResetPassword();
                        }
                    }
                    else {
                        lbClaimType.style.display = 'none';
                        rdbWindowsClaims.style.display = 'none';
                        if (tdrdbFBAClaims != null) {
                            tdrdbFBAClaims.style.display = 'none';
                        }
                        if (tdWindowsClaims != null) {
                            tdWindowsClaims.style.display = 'none';
                        }
                        if (useFBAClaim == 'true') {

                            tblAdmin.style.display = 'none';
                            lblChooseMode.style.display = 'none';
                            rdbQuestion.style.display = 'none';
                            if (tdQuestion != null) {
                                tdQuestion.style.display = 'none';
                            }
                            rdbEmail.style.display = 'none';
                            if (tdEmail != null) {
                                tdEmail.style.display = 'none';
                            }
                            rdbFBAClaims.Checked = true;
                            FormModeToResetPassword();
                        }
                        else if (useWindowsClaim == 'true') {
                            lblMsProvider.style.display = 'none';
                            lblMsProviderDescription.style.display = 'none';
                            if (tdProvider != null) {
                                tdProvider.style.display = 'none';
                            }
                            chkRequiredSecurityQuestion.style.display = 'none';
                            if (tdRequiredSecurityQuestion != null) {
                                tdRequiredSecurityQuestion.style.display = 'none';
                            }
                            rdbWindowsClaims.Checked = true;
                            WindowModeToResetPassword();
                        }
                    }
                }
            }
        }
        //alert('ddlZone_SelectedIndexChanged');
    }
    catch (ex) {
        alert("ddlZone_SelectedIndexChanged: " + ex);
    }
}

function FormModeToResetPassword() {
    try {
        var chkRequiredSecurityQuestion = document.getElementById(_ChkRequiredSecurityQuestionClientId);
        var lbClaimType = document.getElementById(_LbClaimTypeClientId);
        var rdbFBAClaims = document.getElementById(_RdbFBAClaimsClientId);
        var rdbWindowsClaims = document.getElementById(_RdbWindowsClaimsClientId);

        var administratorOption = document.getElementById(_TblAdministrativeOptionsClientId);
        var securityQuestion = document.getElementById(_TblSecurityQuestionsClientId);
        var emailOption = document.getElementById(_TblEmailOptionClientId);
        var confirmEmailOption = document.getElementById(_TblConfirmEmailOptionClientId);
        var newEmailOption = document.getElementById(_TblNewEmailOptionClientId);

        var chkLocalServerUserGroup = document.getElementById(_ChkLocalServerUserGroupClientId);
        var lblSiteCollectionUrl = document.getElementById(_LblSiteCollectionUrlClientId);
        var txtSiteCollectionUrl = document.getElementById(_TxtSiteCollectionUrlClientId);

        administratorOption.style.display = 'none';
        securityQuestion.style.display = 'none';
        emailOption.style.display = 'none';
        confirmEmailOption.style.display = 'none';
        newEmailOption.style.display = 'none';

        chkLocalServerUserGroup.style.display = 'none';
        lblSiteCollectionUrl.style.display = 'none';
        txtSiteCollectionUrl.style.display = 'none';

        var tdLocalServer = chkLocalServerUserGroup.parentNode;
        if (tdLocalServer != null) {
            tdLocalServer.style.display = 'none';
        }
        var tdSiteCollectionUrl = txtSiteCollectionUrl.parentNode;
        if (tdSiteCollectionUrl) {
            tdSiteCollectionUrl.style.display = 'none';
        }
        var tdLblSiteCollectionUrl = lblSiteCollectionUrl.parentNode;
        if (tdLblSiteCollectionUrl) {
            tdLblSiteCollectionUrl.style.display = 'none';
        }

        if (chkRequiredSecurityQuestion.checked) {
            //Internet -> Check Provider requires security question and answer -> Nothing
        }
        else {
            //Internet -> Uncheck Provider requires security question and answer -> Site
            //                                                                   -> E-mail Options
            //                                                                   -> Confirmation E-mail Properties
            //                                                                   -> New E-mail Properties

            //Site
            lblSiteCollectionUrl.style.display = '';
            txtSiteCollectionUrl.style.display = '';

            if (tdSiteCollectionUrl) {
                tdSiteCollectionUrl.style.display = '';
            }
            if (tdLblSiteCollectionUrl) {
                tdLblSiteCollectionUrl.style.display = '';
            }

            //E-mail Options
            emailOption.style.display = '';

            //Confirmation E-mail Properties
            confirmEmailOption.style.display = '';

            //New E-mail Properties
            newEmailOption.style.display = '';
        }
    }
    catch (ex) {
        alert("FormModeToResetPassword: " + ex);
    }
}

function WindowModeToResetPassword() {
    try {
        var rdbQuestion = document.getElementById(_RdbQuestionClientId);
        var rdbEmail = document.getElementById(_RdbEmailClientId);
		var ckbEmail =  document.getElementById(_CkbEmailClientId);  

        var administratorOption = document.getElementById(_TblAdministrativeOptionsClientId);
        var securityQuestion = document.getElementById(_TblSecurityQuestionsClientId);
        var emailOption = document.getElementById(_TblEmailOptionClientId);
        var confirmEmailOption = document.getElementById(_TblConfirmEmailOptionClientId);
        var newEmailOption = document.getElementById(_TblNewEmailOptionClientId);

        var chkLocalServerUserGroup = document.getElementById(_ChkLocalServerUserGroupClientId);
        var lblSiteCollectionUrl = document.getElementById(_LblSiteCollectionUrlClientId);
        var txtSiteCollectionUrl = document.getElementById(_TxtSiteCollectionUrlClientId);

        administratorOption.style.display = 'none';
        securityQuestion.style.display = 'none';
        emailOption.style.display = 'none';
        confirmEmailOption.style.display = 'none';
        newEmailOption.style.display = 'none';

        chkLocalServerUserGroup.style.display = 'none';
        lblSiteCollectionUrl.style.display = 'none';
        txtSiteCollectionUrl.style.display = 'none';
		ckbEmail.style.display = 'none';

        var tdLocalServer = chkLocalServerUserGroup.parentNode;
        if (tdLocalServer != null) {
            tdLocalServer.style.display = 'none';
        }
		
		var tdCkbEmail = ckbEmail.parentNode;
		if (tdCkbEmail != null) {
            tdCkbEmail.style.display = 'none';
        }
		
        var tdSiteCollectionUrl = txtSiteCollectionUrl.parentNode;
        if (tdSiteCollectionUrl) {
            tdSiteCollectionUrl.style.display = 'none';
        }
        var tdLblSiteCollectionUrl = lblSiteCollectionUrl.parentNode;
        if (tdLblSiteCollectionUrl) {
            tdLblSiteCollectionUrl.style.display = 'none';
        }

        if (rdbQuestion.checked) {
            //Default -> Security Question (No Local and Site) -> Administrative Options
            //                                                 -> Security Question
            //                                                 -> E-mail Options
            //                                                 -> Confirmation E-mail Options

            administratorOption.style.display = '';
            securityQuestion.style.display = '';
			ckbEmail.style.display = '';
			if (tdCkbEmail != null) {
                tdCkbEmail.style.display = '';
            }
			if (ckbEmail.checked) 
			{
				emailOption.style.display = '';
				confirmEmailOption.style.display = '';
			}
        }
        else if (rdbEmail.checked) {
            //Default -> Use e-mail address -> Local and Site -> Administrative Options
            //                                                -> E-mail Options
            //                                                -> Confirmation E-mail Options
            //                                                -> New E-mail Options

            administratorOption.style.display = '';
            emailOption.style.display = '';
            confirmEmailOption.style.display = '';
            newEmailOption.style.display = '';

            chkLocalServerUserGroup.style.display = '';
            txtSiteCollectionUrl.style.display = '';

            if (tdLocalServer != null) {
                tdLocalServer.style.display = '';
            }
            if (tdSiteCollectionUrl) {
                tdSiteCollectionUrl.style.display = '';
            }
            if (tdLblSiteCollectionUrl) {
                tdLblSiteCollectionUrl.style.display = '';
            }
        }
    }
    catch (ex) {
        alert("WindowModeToResetPassword: " + ex);
    }
}
function Claims_Select() {
    try {
        var lblChooseMode = document.getElementById(_LblChooseModeClientId);
        var rdbQuestion = document.getElementById(_RdbQuestionClientId);
        var rdbEmail = document.getElementById(_RdbEmailClientId);

        var ddlZones = document.getElementById(_DdlZonesClientId);
        var lblAutMode = document.getElementById(_LblAuthenticationModeDetailClientId);
        var lblMsProvider = document.getElementById(_LblMembershipProviderDetailClientId);
        var lblMsProviderDescription = document.getElementById(_LblMembershipProviderClientId);
        var lblZoneUrl = document.getElementById(_LblZoneUrlDetailClientId);
        var lbClaimType = document.getElementById(_LbClaimTypeClientId);
        var rdbFBAClaims = document.getElementById(_RdbFBAClaimsClientId);
        var rdbWindowsClaims = document.getElementById(_RdbWindowsClaimsClientId);
        var chkRequiredSecurityQuestion = document.getElementById(_ChkRequiredSecurityQuestionClientId);
        var tblAdmin = document.getElementById(_TblAdministrativeOptionsClientId);

        if ((ddlZones != null) && (lblAutMode != null) &&
		        (lblMsProviderDescription != null) && (lblMsProvider != null) &&
		        (lblZoneUrl != null) && (tblAdmin != null) && (lbClaimType != null) && (rdbFBAClaims != null) && (rdbWindowsClaims != null) &&
		        (chkRequiredSecurityQuestion != null)) {
            //Display all controls
            lblAutMode.style.display = '';
            lblMsProviderDescription.style.display = '';
            var tdProvider = lblMsProviderDescription.parentNode;
            if (tdProvider != null) {
                tdProvider.style.display = '';
            }
            lblMsProvider.style.display = '';
            lblZoneUrl.style.display = '';
            tblAdmin.style.display = '';
            chkRequiredSecurityQuestion.style.display = '';
            lbClaimType.style.display = '';
            rdbWindowsClaims.style.display = '';
            var tdWindowsClaims = rdbWindowsClaims.parentNode;
            if (tdWindowsClaims != null) {
                tdWindowsClaims.style.display = '';
            }

            rdbFBAClaims.style.display = '';
            var tdrdbFBAClaims = rdbFBAClaims.parentNode;
            if (tdrdbFBAClaims != null) {
                tdrdbFBAClaims.style.display = '';
            }
            var tdRequiredSecurityQuestion = chkRequiredSecurityQuestion.parentNode;
            if (tdRequiredSecurityQuestion != null) {
                tdRequiredSecurityQuestion.style.display = '';
            }
            lblChooseMode.style.display = '';
            rdbQuestion.style.display = '';
            var tdQuestion = rdbQuestion.parentNode;
            if (tdQuestion != null) {
                tdQuestion.style.display = '';
            }
            rdbEmail.style.display = '';
            var tdEmail = rdbEmail.parentNode;
            if (tdEmail != null) {
                tdEmail.style.display = '';
            }

            //Value of zone
            var item = ddlZones.value;

            //Zone information
            var authenticationMode = '';
            var membershipProvider = '';
            var zoneUrl = '';
            if (item.indexOf(SplitValueText) > 0) {
                authenticationMode = Split(item, SplitValueText, 0);
                membershipProvider = Split(item, SplitValueText, 1);
                zoneUrl = Split(item, SplitValueText, 2);

                lblAutMode.innerHTML = authenticationMode;
                lblMsProvider.innerHTML = membershipProvider;
                lblZoneUrl.innerHTML = zoneUrl;
                if (rdbFBAClaims.checked) {
                    tblAdmin.style.display = 'none';
                    lblChooseMode.style.display = 'none';
                    rdbQuestion.style.display = 'none';
                    if (tdQuestion != null) {
                        tdQuestion.style.display = 'none';
                    }
                    rdbEmail.style.display = 'none';
                    if (tdEmail != null) {
                        tdEmail.style.display = 'none';
                    }

                    FormModeToResetPassword();
                }
                else if (rdbWindowsClaims.checked) {
                    lblMsProvider.style.display = 'none';
                    lblMsProviderDescription.style.display = 'none';
                    if (tdProvider != null) {
                        tdProvider.style.display = 'none';
                    }
                    chkRequiredSecurityQuestion.style.display = 'none';
                    if (tdRequiredSecurityQuestion != null) {
                        tdRequiredSecurityQuestion.style.display = 'none';
                    }
                    WindowModeToResetPassword();
                }
            }
        }
    }
    catch (ex) {
        alert("ddlZone_SelectedIndexChanged: " + ex);
    }
}
