function check_date() {
    var bdate = document.getElementById('bdate');
    var edate = document.getElementById('edate');
    var regexp = /^\d{2}\.\d{2}\.\d{4}$/;
    if ( (bdate == '' || regexp.test(bdate.value)) && (edate == '' || regexp.test(edate.value)) ) {
        frm_search.submit();
    }
    else {
        alert("Неправильное значение начальной или конечной даты.\n" + "Дата должна быть в виде дд.мм.гггг");
    }
    return false;
}

function set_calendar(obj, dname) {
    setCalendarPosition(obj);
    document.getElementById('calendar').style.display='block';
    calendar.calendarAction="parent.document.getElementById('" + dname + "').value=this.value;"
                            + "parent.document.getElementById('calendar').style.display='none';";
    calendar.calendarClose="parent.document.getElementById('calendar').style.display='none';";
}
function show_page(n) {
    document.getElementById('page').value = n;
    frm_pager.submit();
}

var exdate=new Date();
exdate.setDate(exdate.getDate()+360);

function show_country(n, cookiename) {
    if ( n == prev_selected ) {
        return false;
    }
    if ( document.getElementById("a_country_" + n).className.match("gb") ) {
        document.getElementById("a_country_" + n).className="active gb";
    }
    else {
        document.getElementById("a_country_" + n).className="active";
    }
    if ( document.getElementById("a_country_" + prev_selected).className.match("gb") ) {
        document.getElementById("a_country_" + prev_selected).className = "gb";
    }
    else {
        document.getElementById("a_country_" + prev_selected).className="";
    }
    document.getElementById("country_" + prev_selected).style.display = "none";
    document.getElementById("country_" + n).style.display = "";
    prev_selected = n;
    if ( GetCookie(cookiename) != n ) {
        SetCookie(cookiename, n, exdate);
    }
    return false;
}

function show_mgraph( str ) {
    window.open("/cgi-bin/macro/graphic_gist.cgi?"+str,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=625, height=525");
}
