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