(function($){$.fn.PullOut=function(options){var settings=jQuery.extend({position:"left",fixed:true,hideHeadline:true,width:"auto",height:"auto",offset:"auto",margin:"auto",opacity:0.8,duration:800,sensibility:800,orientation:"bt",handlerPadding:10,debug:false},options);var $this=$(this);$this[0]["pushInTimeout"]=-1;$this[0]["pulledOut"]=false;$this[0]["zIndex"]=1000;var labelText="? PullOut ?";if(settings.debug==true){jQuery.log("PullOut: Creating PullOut on element "+this.tagName+"#"+this.id);}$this.addClass("pulloutcontainer");var pocntr=$this;var pocont=$('<div class="pulloutcontent" />');var poback=$('<div class="pulloutbackground" />');var pohndl=$('<div class="pullouthandler" />');var pohndlback=$('<div class="pullouthandlerback" />');if($this.children("h1").length>0){labelText=$this.children("h1:first").text();if(settings.hideHeadline){$this.children("h1:first").remove();}}pohndl.append('<span class="pullouthandlerlabel" />');pohndl.children(".pullouthandlerlabel").text(labelText).css({position:"relative",top:settings.handlerPadding,left:settings.handlerPadding});pocont.html($this.html());$this.empty();pocont.appendTo($this);poback.appendTo($this);pohndl.appendTo($this);pohndlback.appendTo($this);if(settings.height=="auto"){settings.height=((settings.position=="top")||(settings.position=="bottom"))?Math.floor(0.33*pocntr.parent().height()):"100%";}if(settings.width=="auto"){settings.width=((settings.position=="left")||(settings.position=="right"))?Math.floor(0.33*pocntr.parent().width()):"100%";}if(pocntr.parent().children(".pulloutcontainer"+settings.position).length==0){if(settings.offset=="auto"){settings.offset=50;}}else{if(settings.margin=="auto"){settings.margin=20;}var lastchild=pocntr.parent().children(".pulloutcontainer"+settings.position+":last");var offset=lastchild.children(".pullouthandler").offset();if((settings.position=="top")||(settings.position=="bottom")){settings.offset=offset.left+lastchild.children(".pullouthandler").width()+settings.margin;}else{settings.offset=offset.top+lastchild.children(".pullouthandler").height()+settings.margin;}}handlerwidth=pohndl.children("span").width()+2*settings.handlerPadding;handlerheight=pohndl.children("span").height()+2*settings.handlerPadding;if((settings.position=="left")||(settings.position=="right")){var t=handlerwidth;handlerwidth=handlerheight;handlerheight=t;pohndl.children(".pullouthandlerlabel").html(labelText).css({whiteSpace:"noWrap"});pohndl.children(".pullouthandlerlabel").mbFlipText(settings.orientation=="tb");}pohndl.css({width:handlerwidth,height:handlerheight});pohndlback.css({width:handlerwidth,height:handlerheight,opacity:settings.opacity});pocont.css({width:settings.width,height:settings.height});poback.css({width:settings.width,height:settings.height,opacity:settings.opacity});switch(settings.position){case"top":pocntr.css({zIndex:$(this)[0]["zIndex"],left:0,top:-settings.height,height:settings.height,width:settings.width}).addClass("pulloutcontainertop");pohndl.css({top:settings.height,left:settings.offset});pohndlback.css({top:settings.height,left:settings.offset});pocont.css({top:0,left:0});poback.css({top:0,left:0});break;case"right":pocntr.css({zIndex:$(this)[0]["zIndex"],right:-settings.width,top:0,height:settings.height,width:settings.width}).addClass("pulloutcontainerright");pohndl.css({right:settings.width,top:settings.offset});pohndlback.css({right:settings.width,top:settings.offset});pocont.css({top:0,right:0});poback.css({top:0,right:0});break;case"bottom":pocntr.css({zIndex:$(this)[0]["zIndex"],left:0,bottom:-settings.height,height:settings.height,width:settings.width}).addClass("pulloutcontainerbottom");pohndl.css({left:settings.offset,bottom:settings.height});pohndlback.css({left:settings.offset,bottom:settings.height});pocont.css({top:0,bottom:0});poback.css({top:0,bottom:0});break;case"left":pocntr.css({zIndex:$(this)[0]["zIndex"],left:-settings.width,top:0,height:settings.height,width:settings.width}).addClass("pulloutcontainerleft");pohndl.css({left:settings.width,top:settings.offset});pohndlback.css({left:settings.width,top:settings.offset});pocont.css({left:0,top:0});poback.css({left:0,top:0});break;}if(settings.fixed==true){pocntr.css({position:""});}function pullOut(){clearTimeout($this[0]["pushInTimeout"]);$this[0]["pushInTimeout"]=-1;if($this[0]["pulledOut"]){return;}switch(settings.position){case"top":pocntr.stop().animate({top:0},settings.duration);break;case"right":pocntr.stop().animate({right:0},settings.duration);break;case"bottom":pocntr.stop().animate({bottom:0},settings.duration);break;case"left":pocntr.stop().animate({left:0},settings.duration);break;}pocntr.parent().children(".pulloutcontainer").each(function(){if($(this)[0]["pulledOut"]){$(this).css({zIndex:$(this)[0]["zIndex"]});$(this).trigger("mouseleave");}});$this[0]["pulledOut"]=true;pocntr.css({zIndex:parseInt($this[0]["zIndex"]-1)});}function pushIn(){$this[0]["pulledOut"]=false;$this[0]["pushInTimeout"]=-1;pocntr.css({zIndex:parseInt($this[0]["zIndex"]-2)});switch(settings.position){case"top":pocntr.stop().animate({top:-settings.height},settings.duration,function(){pocntr.css({zIndex:$this[0]["zIndex"]});});break;case"right":pocntr.stop().animate({right:-settings.width},settings.duration,function(){pocntr.css({zIndex:$this[0]["zIndex"]});});break;case"bottom":pocntr.stop().animate({bottom:-settings.height},settings.duration,function(){pocntr.css({zIndex:$this[0]["zIndex"]});});break;case"left":pocntr.stop().animate({left:-settings.width},settings.duration,function(){pocntr.css({zIndex:$this[0]["zIndex"]});});break;}}pocntr.bind("mouseenter",pullOut);pocntr.bind("mouseleave",function(){if($this[0]["pushInTimeout"]!=-1){clearTimeout($this[0]["pushInTimeout"]);pushIn();}else{$this[0]["pushInTimeout"]=setTimeout(pushIn,settings.sensibility);}});};$.log=function(text){if(console&&console.log){console.log(text);}};})(jQuery);
