function archSelectYear(year, id) {
    var div = $('cur_year_' + id);

    if (div && (typeof(div) != 'undefined')) {
        div.innerHTML = year;
    }

    closeDiv('years_list_' + id);
    closeAllMnthLists(div.parentNode);
}

function archOpenCloseMnthList(id) {
    var div = $('cur_year_' + id);
    var year, mnthList;

    if (div && (typeof(div) != 'undefined')) {
        year = div.innerHTML;
        if (toInt(year)) {
            mnthList = $('year_' + toInt(year) + '_' + id);
            if (mnthList && (typeof(mnthList) != 'undefined')) {
                if (mnthList.style.display == 'none') {
                    mnthList.style.display = 'block';
                } else {
                    mnthList.style.display = 'none';
                }
            }
        }
    }
}

function closeAllMnthLists(div) {
    var i;

    if (div && (typeof(div) != 'undefined')) {
        for (i = 0; i <= div.childNodes.length; i++) {
            if (div.childNodes[i] && (typeof(div.childNodes[i]) != 'undefined') && (div.childNodes[i].id) && (typeof(div.childNodes[i].id) != 'undefined') && /^year_\d{4}_/.test(div.childNodes[i].id)) {
                div.childNodes[i].style.display = 'none';
            }

        }
    }
}

function closeSelects(current, popupId) {
    if (current && (typeof(current) != 'undefined')) {
        current.style.display = 'none';
    }

    var yearSelect = $('years_list_' + popupId);
    if (yearSelect && (typeof(yearSelect) != 'undefined')) {
        yearSelect.style.display = 'none';
    }
}