
$(function () {

    $(".clicked").removeClass("clicked");
    var buts = $(".but, .item");
    buts.click(
        function (e) {
            var n = $("a", this)[0].href || "",
                t = "a" != e.target.tagName.toLowerCase();
            if (t && n)
                setTimeout(
                    function () {
                        window.location.replace(n); },
                    100); });
    buts.hover(
        function () {
            $(this).addClass("hover"); },
        function () {
            $(this).removeClass("clicked");
            $(this).removeClass("hover"); });
    buts.mousedown(
        function () {
            $(this).addClass("clicked"); });
    buts.mouseup(
        function () {
            $(this).removeClass("clicked"); });

    /*
    var pop_menu = $(".progmenu");
    if (pop_menu.length) {
        var pop_time,
            pop_visible = false,
            pop_on = $(".program-list > h4 > span, .progmenu, .progmenu *"),
            pop_off = $(".program-list, .progmenu, .progmenu *");
        var pop_kill = function () {
            if (pop_visible) {
                pop_menu.hide("normal");
                pop_visible = false;
            }
            pop_cancel();
        };
        var pop_hide = function () {
            if (pop_visible && !pop_time)
                pop_time = setTimeout(pop_kill, 1111);
        };
        var pop_cancel = function () {
            if (pop_time) {
                clearTimeout(pop_time);
                pop_time = null;
            }
        };
        var pop_show = function () {
            pop_cancel();
            if (!pop_visible) {
                pop_menu.show("normal");
                pop_visible = true;
            }
        };
        pop_on.mouseover(pop_show);
        pop_off.mouseout(pop_hide);
    }
    */

    var goprog = function () {
        var n = parseInt(this.value);
        if (!n || n <= 1) return;
        window.location.replace("/program/" + n + ".htm");
    };

    if ($.browser.msie)
        setTimeout(
            function () {
                $(".unit select").each(
                    function () {
                        o = document.createElement("option");
                        o.value = -1;
                        o.selected = true;
                        o.defaultSelected = true;
                        o.innerHTML = " ";
                        this.appendChild(o);
                    });
            },
            234);

    $(".unit select").change(goprog);
    $(".unit select option").click(goprog);

});
