(function ($) {
    $.fn.lavaLamp = function (o) {
        o = $.extend({
            fx: "linear",
            speed: 500,
            click: function () { }
        }, o || {});
        return this.each(function () {
            var b = $(this);
            var noop = function () { }
            var setCurr = function (curr, back) { back.css({ "left": curr.offsetLeft + "px", "width": curr.offsetWidth + "px" }); }
            var move = function (curr, back) {
                if (typeof (curr) != 'undefined') {
                    back.each(function () { $.dequeue(this, "fx") }).animate({ width: curr.offsetWidth, left: curr.offsetLeft }, o.speed, o.fx);
                }
                else {
                    back.each(function () { $.dequeue(this, "fx") }).animate({ width: 0, left: 0 }, o.speed, o.fx);
                }
            }
            var back = $('<li class="back"><div class="left"></div></li>').appendTo(b);
            var li = $("li", this);
            var curr = $("li.current", this)[0];
            li.not(".back").hover(function () { move(this, back) }, noop); $(this).hover(noop, function () { move(curr, back) });
            if (typeof (curr) != 'undefined') { setCurr(curr, back); }
        });
    }
})(jQuery);


