
/** jquery.lavalamp.js ****************/
(function($) {
$.fn.lavaLamp = function(o) {
    o = $.extend({ fx: "linear", speed: 500, click: function(){} }, o || {});

    return this.each(function() {
        var me = $(this), noop = function(){},
            $back = $('<li class="back"><div class="left"></div></li>').appendTo(me),
            $li = $(">li", this), curr = $("li.current", this)[0] || $($li[0]).addClass("current")[0];

        $li.not(".back").hover(function() {
            move(this);
        }, noop);

        $(this).hover(noop, function() {
            move(curr);
        });

        $li.click(function(e) {
            setCurr(this);
            return o.click.apply(this, [e, this]);
        });

        setCurr(curr);

        function setCurr(el) {
            $back.css({ "left": el.offsetLeft+"px", "width": el.offsetWidth+"px" });
            curr = el;
        };

        function move(el) {
            $back.each(function() {
                $.dequeue(this, "fx"); }
            ).animate({
                width: el.offsetWidth,
                left: el.offsetLeft
            }, o.speed, o.fx);
        };

    });
};
})(jQuery);


/** apycom menu **/
jQuery(function () {
   var $ = jQuery;
	// retarder
	$.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', '#navigation').css({
        display: 'none',
        left: -5
    });
    $('li', '#navigation').hover(function () {
        var ul = $('ul:first', this);
        $('span', ul).css('color', 'rgb(169,169,169)');
        if (ul.length) {
            if (!ul[0].wid) {
                ul[0].wid = ul.width();
                ul[0].hei = ul.height()
            }
            ul.css({
                width: 0,
                height: 0,
                overflow: 'hidden',
                display: 'block'
            }).retarder(100, function (i) {
                i.animate({
                    width: ul[0].wid,
                    height: ul[0].hei
                },
                {
                    duration: 300,
                    complete: function () {
                        ul.css('overflow', 'visible')
                    }
                })
            })
        }
    },


    function () {
        var ul = $('ul:first', this);
        if (ul.length) {
            var css = {
                display: 'none',
                width: ul[0].wid,
                height: ul[0].hei
            };
            ul.stop().css('overflow', 'hidden').retarder(50, function (i) {
                i.animate({
                    width: 0,
                    height: 0
                },
                {
                    duration: 100,
                    complete: function () {
                        $(this).css(css)
                    }
                })
            })
        }
    });
    $('#navigation ul.lavalamp').lavaLamp({
        fx: 'easeOutBack',
        speed: 400
    });
    if (! ($.browser.msie && $.browser.version.substr(0, 1) == '6')) {
        $('ul ul a span', '#navigation').css('color', 'rgb(169,169,169)').hover(function () {
            $(this).animate({
                color: 'rgb(255,255,255)'
            },
            600)
        },


        function () {
            $(this).animate({
                color: 'rgb(169,169,169)'
            },
            200)
        })
    }
});