(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);$(curr).removeClass('current');},noop);$(this).hover(noop,function(){move(curr);$(curr).addClass('current');});$li.click(function(e){setCurr(this);return o.click.apply(this,[e,this]);});setCurr=function(el){var $el=$(el),width=o.margin?(parseInt($el.width())-parseInt(o.margin)*2):$el.width();$back.css({left:el.offsetLeft+"px",width:width+"px"});curr=el;$li.not($el).removeClass('hover');$el.addClass('hover');}

me.data('setCurr',setCurr);setCurr(curr);if(o.margin){$back.css('margin-left',o.margin);$back.css('margin-right',o.margin);}

function move(el){var $el=$(el),width=o.margin?(parseInt($el.width())-parseInt(o.margin)*2):$el.width();$li.not($el).removeClass('hover');$el.addClass('hover');$back.stop().animate({width:width+'px',left:el.offsetLeft+'px'},o.speed,o.fx);};});};})(jQuery);
