﻿function LanguageChange(dropDown, divPanelId) {
    // show other language div if required, otherwise hide it
    var isOther = dropDown.options[dropDown.selectedIndex].value == "Other";
    document.getElementById(divPanelId).style.display = isOther ? "block" : "none";
}

function CourtOrdersChange(dropDown, rowId) {
    // show court orders if required, otherwise hide it
    var hasCourtOrders = dropDown.options[dropDown.selectedIndex].value == "1";
    document.getElementById(rowId).style.display = hasCourtOrders ? "" : "none";
}

function AddressNotApplicable(checkbox, rowIds) {
    // show address if required, otherwise hide it
    var visiblity = checkbox.checked ? "none" : "";
    for (var i = 0; i < rowIds.length; i++) {
        document.getElementById(rowIds[i]).style.display = visiblity;
    }
}

function DateRangeChange(dropDown, rowIds) {
    // show custom date rows if required, otherwise hide it
    var isDateRange = dropDown.options[dropDown.selectedIndex].value == "dateRange";
    for (var i = 0; i < rowIds.length; i++) {
        document.getElementById(rowIds[i]).style.display = isDateRange ? "" : "none";
    } 
}

/*This function is used for showing popups in the application.
 I know - I am hard coding the behavior ID here because I need it to act on ajax load()
 so there's no easy way to inject the behavior ID - this means *one popup per page allowed* which is OK for now.
*/
function showPopup() {
    var behavior = $find('childPopup');
    behavior._popupBehavior.show();
    behavior._popupVisible = true;

    Sys.Application.remove_load(showPopup);

}

function hidePopup() {
    var behavior = $find('childPopup');
    behavior._popupBehavior.hide();
    behavior._popupVisible = false;
}