﻿var loadingDiv;
var countryDiv;
var listButtonPos;

/* 
 * Select/deselect all the source checkboxes
 */
function SelectAllSources(isSelected) {
   
    var sources = document.getElementsByTagName("input");
    for (var i = 0; i < sources.length; i++) {
        var source = sources[i];
        if (!source["type"] || source["type"] != "checkbox" || source["id"].indexOf("cbxSrc_") != 0 || source["id"] == "cbxSrc_All") {
            continue;
        }
        
        source.checked = isSelected;
    }
}

/* 
 * Select/deselect all the statistical area checkboxes
 */
function SelectAllStatisticalAreas(isSelected) {
    
    var areas = $("cblCountries", "table").getElementsByTagName("input");
    
    for (var i = 0; i < areas.length; i++) {
        var area = areas[i];
        if (!area["type"] || area["type"] != "checkbox") {
            continue;
        }
        area.checked = isSelected;
    } 
}

/*
 * Enable/disable year text boxes based on which year is currently selected
 */
function ToggleYears() {
    $("txtYearLow", "input", "text").disabled = 
    $("txtYearHigh", "input", "text").disabled = 
    !$("yearBetween", "input", "radio").checked;
        
    $("txtYears", "input", "text").disabled = 
    !$("years", "input", "radio").checked;        
}

