(function($) {
$.fn.lavaLamp = function(o) {
    o = $.extend({ fx: "linear", speed: 800, click: function(){} }, o || {});

    return this.each(function() {
        var me = $(this), noop = function(){},
            $back = $('<dt class="back"><div class="left"></div></dt>').appendTo(me),
            $dl= $("dl", this), curr = $("dl.current", this)[0] || $($dl[0]).addClass("current")[0];

        $dl.not(".back").hover(
			function() {move(this);$(this).find("dd").animate({ marginLeft: 50, opacity: 'show' }, 500,'backout');
		            $("#nav dl").addClass("in");$(this).addClass("out");
		},
			function() {noop;$(this).find("dd").animate({ marginLeft:0, opacity: 'hide' }, 10,'backout');
		        $(this).removeClass("out");$("#nav dl").removeClass("in")} 
			);

        $(this).hover(noop, function() {
            move(curr);
			
        });

        setCurr(curr);

        function setCurr(el) {
            $back.css({ "left": el.offsetLeft+"px", "width": el.offsetWidth+"px" });
            curr = el;
        };

        function move(el) {
            $back.each(function() {
                $(this).dequeue("fx"); }
            ).animate({
                width: el.offsetWidth,
                left: el.offsetLeft
            }, o.speed, o.fx);
        };

    });
};
})(jQuery);
