/**
 * jquery.LavaLamp v1.3.5 - light up your menus with fluid, jQuery powered animations.
 * Requires jQuery v1.2.3 or better from http://jquery.com
 * Tested on jQuery 1.4.4, 1.3.2 and 1.2.6
 * http://nixbox.com/projects/jquery-lavalamp/
 * Source code Copyright (c) 2008, 2009, 2010 Jolyon Terwilliger, jolyon@nixbox.com
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function($){jQuery.fn.lavaLamp=function(o){o=$.extend({'target':'li','container':'','fx':'swing','speed':500,'click':function(){return true},'startItem':'','includeMargins':false,'autoReturn':true,'returnDelay':0,'setOnClick':true,'homeTop':0,'homeLeft':0,'homeWidth':0,'homeHeight':0,'returnHome':false,'autoResize':false},o||{});function getInt(arg){var myint=parseInt(arg);return(isNaN(myint)?0:myint);}
if(o.container=='')
o.container=o.target;if(o.autoResize)
$(window).resize(function(){$(o.target+'.selectedLava').trigger('mouseenter');});return this.each(function(){if($(this).css('position')=='static')
$(this).css('position','relative');if(o.homeTop||o.homeLeft){var $home=$('<'+o.container+' class="homeLava"></'+o.container+'>').css({'left':o.homeLeft,'top':o.homeTop,'width':o.homeWidth,'height':o.homeHeight,'position':'absolute','display':'block'});$(this).prepend($home);}
var path=location.pathname+location.search+location.hash,$selected,$back,$lt=$(o.target+'[class!=noLava]',this),delayTimer,bx=0,by=0,mh=0,mw=0,ml=0,mt=0;$selected=$(o.target+'.selectedLava',this);if(o.startItem!='')
$selected=$lt.eq(o.startItem);if((o.homeTop||o.homeLeft)&&$selected.length<1)
$selected=$home;if($selected.length<1){var pathmatch_len=0,$pathel;$lt.each(function(){var thishref=$('a:first',this).attr('href');if(path.indexOf(thishref)>-1&&thishref.length>pathmatch_len)
{$pathel=$(this);pathmatch_len=thishref.length;}});if(pathmatch_len>0){$selected=$pathel;}}
if($selected.length<1)
$selected=$lt.eq(0);$selected=$($selected.eq(0).addClass('selectedLava'));$lt.bind('mouseenter',function(){if(delayTimer){clearTimeout(delayTimer);delayTimer=null;}
move($(this));}).click(function(e){if(o.setOnClick){$selected.removeClass('selectedLava');$selected=$(this).addClass('selectedLava');}
return o.click.apply(this,[e,this]);});$back=$('<'+o.container+' class="backLava"><div class="leftLava"></div><div class="bottomLava"></div><div class="cornerLava"></div></'+o.container+'>').css({'position':'absolute','display':'block','margin':0,'padding':0}).prependTo(this);if(o.includeMargins){mh=getInt($selected.css('marginTop'))+getInt($selected.css('marginBottom'));mw=getInt($selected.css('marginLeft'))+getInt($selected.css('marginRight'));}
bx=getInt($back.css('borderLeftWidth'))+getInt($back.css('borderRightWidth'))+getInt($back.css('paddingLeft'))+getInt($back.css('paddingRight'))-mw;by=getInt($back.css('borderTopWidth'))+getInt($back.css('borderBottomWidth'))+getInt($back.css('paddingTop'))+getInt($back.css('paddingBottom'))-mh;if(o.homeTop||o.homeLeft)
$back.css({'left':o.homeLeft,'top':o.homeTop,'width':o.homeWidth,'height':o.homeHeight});else
{if(!o.includeMargins){ml=(getInt($selected.css('marginLeft')));mt=(getInt($selected.css('marginTop')));}
$back.css({'left':$selected.position().left+ml,'top':$selected.position().top+mt,'width':$selected.outerWidth()-bx+20,'height':$selected.outerHeight()-by});}
$(this).bind('mouseleave',function(){var $returnEl=null;if(o.returnHome)
$returnEl=$home;else if(!o.autoReturn)
return true;if(o.returnDelay){if(delayTimer)clearTimeout(delayTimer);delayTimer=setTimeout(function(){move($returnEl);},o.returnDelay);}
else{move($returnEl);}
return true;});function move($el){if(!$el)$el=$selected;if(!o.includeMargins){ml=(getInt($el.css('marginLeft')));mt=(getInt($el.css('marginTop')));}
var dims={'left':$el.position().left+ml,'top':$el.position().top+mt,'width':$el.outerWidth()-bx+20,'height':$el.outerHeight()-by};$back.stop().animate(dims,o.speed,o.fx);};});};})(jQuery);
