﻿
function getRadioValue(RadioName) {
    var colRadio = document.getElementsByName(RadioName);
    for (var i = 0; i < colRadio.length; i++) {
        if (colRadio[i].checked) {
            return colRadio[i].value;            
        }
    }
    return null;
}

function Anonymous_Change() 
{
    var sValue;
    var sDivAnonymous, sDivAnonymousDetails;

    sValue = getRadioValue("ctl00$PlaceHolderMain$AbccOnlineEnquiryForm$editmodepanel1$rbAnonymousChoice");
    sDivAnonymous = document.getElementById("OnlineEnquiryAnonymousLabel");
    sDivAnonymousDetails = document.getElementById("OnlineEnquiryAnonymousDetails");    
    
    if (sValue == "Yes") 
    {
        sDivAnonymous.style.display = "block";
        sDivAnonymousDetails.style.display = "none";
    }
    else if (sValue == "No")
    {
        sDivAnonymous.style.display = "none";
        sDivAnonymousDetails.style.display = "block";
    }
}

function Check_EmailAddress() 
{
    var selected
    var message;

    selected = document.getElementById("chkInformation").checked;
    message = document.getElementById("noEmailAddress");   

    if (selected == true) 
    {
        var address;

        address = document.getElementById("txtEmailAddress").value;

        if (address.length == 0) 
        {
            message.style.display = "inline";
        }
    }
    else 
    {
        message.style.display = "none";
    }
}

function Update_OtherTextLabels() 
{
   Update_OtherTextLabel("ddPositionDescription", "txtPositionDescriptionOther", "lblPositionDescriptionOther", "lblPositionDescriptionOtherRequired");
   Update_OtherTextLabel("ddEnquiryCategory", "txtEnquiryCategoryOther", "lblEnquiryCategoryOther", "lblEnquiryCategoryOtherRequired");
   Update_OtherTextLabel("ddAboutAbcc", "txtAboutAbccOther", "lblAboutAbccOtherLabel", "lblAboutAbccOtherLabelRequired");
}

function Update_OtherTextLabel(controlID, otherControlID, otherLabelID, otherLabelRequiredID) 
{
    var control;
    var otherControl;
    var otherLabel;
    var otherLabelRequired;

    control = document.getElementById(controlID);
    otherControl = document.getElementById(otherControlID);
    otherLabel = document.getElementById(otherLabelID);
    otherLabelRequired = document.getElementById(otherLabelRequiredID);
   
    if (control != null) {
        if (control.value == "Other")
        {            
            otherLabelRequired.style.display = "inline";
            otherControl.focus();
        }
        else 
        {
                 otherLabelRequired.style.display = "none";
        }
    }
}


