(function(k){k.fn.lavaLamp=function(o){o=k.extend({fx:'swing',speed:500,click:function(){return true},startItem:'no',autoReturn:true,returnDelay:0,setOnClick:true,homeTop:0,homeLeft:0,homeWidth:0,homeHeight:0,returnHome:false},o||{});var j;if(o.homeTop||o.homeLeft){j=k('<li class="homeLava selectedLava"></li>').css({left:o.homeLeft,top:o.homeTop,width:o.homeWidth,height:o.homeHeight,position:'absolute'});k(this).prepend(j)}return this.each(function(){var c=location.pathname+location.search+location.hash;var d=new Object;var f;var g;var h;var i=k('li[class!=noLava]',this);if(o.startItem=='no')d=k('li a[href$="'+c+'"]',this).parent('li');if(d.length==0&&o.startItem=='no')d=k('li a[href$="'+location.pathname.substring(location.pathname.lastIndexOf('/')+1)+location.search+location.hash+'"]',this).parent('li');if(d.length==0||o.startItem!='no'){if(o.startItem=='no')o.startItem=0;d=k(i[o.startItem])}h=k('li.selectedLava',this)[0]||k(d).addClass('selectedLava')[0];i.mouseenter(function(){if(k(this).hasClass('homeLava')){h=k(this)[0]}move(this)});g=k('<li class="backLava"><div class="leftLava"></div><div class="bottomLava"></div><div class="cornerLava"></div></li>').appendTo(this);k(this).mouseleave(function(){if(o.autoReturn){if(o.returnHome&&j){move(j[0])}else if(o.returnDelay){if(f)clearTimeout(f);f=setTimeout(function(){move(null)},o.returnDelay+o.speed)}else{move(null)}}$(".currentItem a").css("color","#0083a8")});i.click(function(e){if(o.setOnClick){k(h).removeClass('selectedLava');k(this).addClass('selectedLava');h=this}return o.click.apply(this,[e,this])});if(o.homeTop||o.homeLeft)g.css({left:o.homeLeft,top:o.homeTop,width:o.homeWidth,height:o.homeHeight});else g.css({left:h.offsetLeft,top:h.offsetTop,width:h.offsetWidth,height:h.offsetHeight});function move(a){if(!a)a=h;var b=0,by=0;if(!k.browser.msie){b=(g.outerWidth()-g.innerWidth())/2;by=(g.outerHeight()-g.innerHeight())/2}g.stop().animate({left:a.offsetLeft-b,top:a.offsetTop-by,width:a.offsetWidth,height:a.offsetHeight},o.speed,o.fx)}})}})(jQuery);
