

/** altsc menu ****************/
altsc = {};
altsc.colors = {};
altsc.colors.submenu = {
    item: '#4c535a',
    hover: '#393c45'
};
jQuery(function () {
    var $ = jQuery;
    $.fn.retarder = function (delay, method) {
        var node = this;
        if (node.length) {
            if (node[0]._timer_) clearTimeout(node[0]._timer_);
            node[0]._timer_ = setTimeout(function () {
                method(node)
            }, delay)
        }
        return this
    };

    $('ul ul li', '#menusektor').hover(function () {
        var ul = $('div:first', this);
        ul.find('ul:first>li>a>span').css('white-space', 'nowrap');
        if (ul.length) {
            if (!ul[0].wid) ul[0].wid = ul.width();
            ul.css({
                width: 0,
                overflow: 'hidden'
            }).retarder(100, function (i) {
                i.css('visibility', 'visible').animate({
                    width: ul[0].wid
                }, {
                    duration: 300,
                    complete: function () {
                        ul.css('overflow', 'visible');
                        ul.find('ul:first>li>a>span').css('white-space', 'normal')
                    }
                })
            })
        }
    }, function () {
        var ul = $('div:first', this);
        if (ul.length) {
            var css = {
                visibility: 'hidden',
                width: ul[0].wid
            };
            ul.stop().retarder(1, function (i) {
                i.css(css)
            })
        }
    });
    if (!($.browser.msie && $.browser.version.substr(0, 1) == '6')) {
        $('#menusektor>ul.menusektor>li:not(.active)').attr('pos', 1080).attr('iid', 0);
        $('#menusektor>ul.menusektor>li:not(.active)>a').css('backgroundPosition', 'left -1080px');
        $('#menusektor>ul.menusektor>li:not(.active)>a>span').css('backgroundPosition', 'right -1125px')
    }
    $('#menusektor>ul.menusektor>li').hover(function () {
        if (!($.browser.msie && $.browser.version.substr(0, 1) == '6')) if (!$(this).hasClass("active")) {
            var li = this;
            clearInterval(parseInt($(li).attr('iid')));
            $(li).attr('iid', setInterval(function () {
                var iid = parseInt($(li).attr('iid'));
                var pos = $(li).attr('pos');
                pos = parseInt(pos) - 90;
                if (pos < 90) {
                    pos = 90;
                    clearInterval(iid)
                }
                $(li).attr('pos', pos);
                $('>a', li).css('backgroundPosition', 'left -' + pos + 'px');
                $('>a>span', li).css('backgroundPosition', 'right -' + (pos + 45) + 'px')
            }, 50))
        }
    }, function () {
        if (!($.browser.msie && $.browser.version.substr(0, 1) == '6')) if (!$(this).hasClass("active")) {
            var li = this;
            clearInterval(parseInt($(li).attr('iid')));
            $(li).attr('iid', setInterval(function () {
                var iid = parseInt($(li).attr('iid'));
                var pos = $(li).attr('pos');
                pos = parseInt(pos) + 90;
                if (pos > 990) {
                    pos = 990;
                    clearInterval(iid)
                }
                $(li).attr('pos', pos);
                $('>a', li).css('backgroundPosition', 'left -' + pos + 'px');
                $('>a>span', li).css('backgroundPosition', 'right -' + (pos + 45) + 'px')
            }, 50))
        }
    });
    $('ul.menusektor ul li', '#menusektor').css('backgroundColor', altsc.colors.submenu.item).hover(function () {
        $(this).animate({
            backgroundColor: altsc.colors.submenu.hover
        }, 500)
    }, function () {
        $(this).animate({
            backgroundColor: altsc.colors.submenu.item
        }, 500)
    })
});

