/*
 * jquery.layout 1.2.0
 *
 * Copyright (c) 2008 
 *   Fabrizio Balliano (http://www.fabrizioballiano.net)
 *   Kevin Dalman (http://allpro.net)
 *
 * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
 * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
 *
 * $Date: 2008-12-27 02:17:22 +0100 (sab, 27 dic 2008) $
 * $Rev: 203 $
 * 
 * NOTE: For best code readability, view this with a fixed-space font and tabs equal to 4-chars
 */(function($){$.fn.layout=function(opts){function keyDown(e){if(!e)return!0;var t=e.keyCode;if(t<33)return!0;var n={38:"north",40:"south",37:"west",39:"east"},r=t>=37&&t<=40,i=e.altKey,s=e.shiftKey,o=e.ctrlKey,u=!1,a,f,l,h,p;if(!o&&!s)return!0;r&&options[n[t]].enableCursorHotkey?u=n[t]:$.each(c.borderPanes.split(","),function(e,n){f=options[n];l=f.customHotkey;h=f.customHotkeyModifier;if(s&&h=="SHIFT"||o&&h=="CTRL"||o&&s)if(l&&t==(isNaN(l)||l<=9?l.toUpperCase().charCodeAt(0):l)){u=n;return!1}});if(!u)return!0;f=options[u];a=state[u];if(!f.enableCursorHotkey||a.isHidden||!$Ps[u])return!0;p=e.target||e.srcElement;if(p&&s&&r&&(p.tagName=="TEXTAREA"||p.tagName=="INPUT"&&(t==37||t==39)))return!0;toggle(u);e.stopPropagation();e.returnValue=!1;return!1}function allowOverflow(e){this&&this.tagName&&(e=this);var t;typeof e=="string"?t=$Ps[e]:$(e).attr("pane")?t=$(e):t=$(e).parents("div[pane]:first");if(!t.length)return;var n=t.attr("pane"),r=state[n];r.cssSaved&&resetOverflow(n);if(r.isSliding||r.isResizing||r.isClosed){r.cssSaved=!1;return}var i={zIndex:c.zIndex.pane_normal+1},s={},o=t.css("overflow"),u=t.css("overflowX"),a=t.css("overflowY");if(o!="visible"){s.overflow=o;i.overflow="visible"}if(u&&u!="visible"&&u!="auto"){s.overflowX=u;i.overflowX="visible"}if(a&&a!="visible"&&a!="auto"){s.overflowY=u;i.overflowY="visible"}r.cssSaved=s;t.css(i);$.each(c.allPanes.split(","),function(e,t){t!=n&&resetOverflow(t)})}function resetOverflow(e){this&&this.tagName&&(e=this);var t;typeof e=="string"?t=$Ps[e]:$(e).hasClass("ui-layout-pane")?t=$(e):t=$(e).parents("div[pane]:first");if(!t.length)return;var n=t.attr("pane"),r=state[n],i=r.cssSaved||{};!r.isSliding&&!r.isResizing&&t.css("zIndex",c.zIndex.pane_normal);t.css(i);r.cssSaved=!1}function getBtn(e,t,n){var r=$(e),i="Error Adding Button \n\nInvalid ";if(!r.length)alert(i+"selector: "+e);else{if(c.borderPanes.indexOf(t)!=-1){var s=options[t].buttonClass+"-"+n;r.addClass(s+" "+s+"-"+t);return r}alert(i+"pane: "+t)}return!1}function addToggleBtn(e,t){var n=getBtn(e,t,"toggle");n&&n.attr("title",state[t].isClosed?"Open":"Close").click(function(e){toggle(t);e.stopPropagation()})}function addOpenBtn(e,t){var n=getBtn(e,t,"open");n&&n.attr("title","Open").click(function(e){open(t);e.stopPropagation()})}function addCloseBtn(e,t){var n=getBtn(e,t,"close");n&&n.attr("title","Close").click(function(e){close(t);e.stopPropagation()})}function addPinBtn(e,t){var n=getBtn(e,t,"pin");if(n){var r=state[t];n.click(function(e){setPinState($(this),t,r.isSliding||r.isClosed);r.isSliding||r.isClosed?open(t):close(t);e.stopPropagation()});setPinState(n,t,!r.isClosed&&!r.isSliding);c[t].pins.push(e)}}function syncPinBtns(e,t){$.each(c[e].pins,function(n,r){setPinState($(r),e,t)})}function setPinState(e,t,n){var r=e.attr("pin");if(r&&n==(r=="down"))return;var i=options[t].buttonClass,s=i+"-pin",o=s+"-"+t,u=s+"-up",a=o+"-up",f=s+"-down",l=o+"-down";e.attr("pin",n?"down":"up").attr("title",n?"Un-Pin":"Pin").removeClass(n?u:f).removeClass(n?a:l).addClass(n?f:u).addClass(n?l:a)}var prefix="ui-layout-",defaults={paneClass:prefix+"pane",resizerClass:prefix+"resizer",togglerClass:prefix+"toggler",togglerInnerClass:prefix+"",buttonClass:prefix+"button",contentSelector:"."+prefix+"content",contentIgnoreSelector:"."+prefix+"ignore"},options={name:"",scrollToBookmarkOnLoad:!0,defaults:{applyDefaultStyles:!1,closable:!0,resizable:!0,slidable:!0,contentSelector:defaults.contentSelector,contentIgnoreSelector:defaults.contentIgnoreSelector,paneClass:defaults.paneClass,resizerClass:defaults.resizerClass,togglerClass:defaults.togglerClass,buttonClass:defaults.buttonClass,resizerDragOpacity:1,maskIframesOnResize:!0,minSize:0,maxSize:0,spacing_open:6,spacing_closed:6,togglerLength_open:50,togglerLength_closed:50,togglerAlign_open:"center",togglerAlign_closed:"center",togglerTip_open:"Close",togglerTip_closed:"Open",resizerTip:"Resize",sliderTip:"Slide Open",sliderCursor:"pointer",slideTrigger_open:"click",slideTrigger_close:"mouseout",hideTogglerOnSlide:!1,togglerContent_open:"",togglerContent_closed:"",showOverflowOnHover:!1,enableCursorHotkey:!0,customHotkeyModifier:"SHIFT",fxName:"slide",fxSpeed:null,fxSettings:{},initClosed:!1,initHidden:!1},north:{paneSelector:"."+prefix+"north",size:"auto",resizerCursor:"n-resize"},south:{paneSelector:"."+prefix+"south",size:"auto",resizerCursor:"s-resize"},east:{paneSelector:"."+prefix+"east",size:200,resizerCursor:"e-resize"},west:{paneSelector:"."+prefix+"west",size:200,resizerCursor:"w-resize"},center:{paneSelector:"."+prefix+"center"}},effects={slide:{all:{duration:"fast"},north:{direction:"up"},south:{direction:"down"},east:{direction:"right"},west:{direction:"left"}},drop:{all:{duration:"slow"},north:{direction:"up"},south:{direction:"down"},east:{direction:"right"},west:{direction:"left"}},scale:{all:{duration:"fast"}}},config={allPanes:"north,south,east,west,center",borderPanes:"north,south,east,west",zIndex:{resizer_normal:1,pane_normal:2,mask:4,sliding:100,resizing:1e4,animation:1e4},resizers:{cssReq:{position:"absolute",padding:0,margin:0,fontSize:"1px",textAlign:"left",overflow:"hidden",zIndex:1},cssDef:{background:"#DDD",border:"none"}},togglers:{cssReq:{position:"absolute",display:"block",padding:0,margin:0,overflow:"hidden",textAlign:"center",fontSize:"1px",cursor:"pointer",zIndex:1},cssDef:{background:"#AAA"}},content:{cssReq:{overflow:"auto"},cssDef:{}},defaults:{cssReq:{position:"absolute",margin:0,zIndex:2},cssDef:{padding:"10px",background:"#FFF",border:"1px solid #BBB",overflow:"auto"}},north:{edge:"top",sizeType:"height",dir:"horz",cssReq:{top:0,bottom:"auto",left:0,right:0,width:"auto"}},south:{edge:"bottom",sizeType:"height",dir:"horz",cssReq:{top:"auto",bottom:0,left:0,right:0,width:"auto"}},east:{edge:"right",sizeType:"width",dir:"vert",cssReq:{left:"auto",right:0,top:"auto",bottom:"auto",height:"auto"}},west:{edge:"left",sizeType:"width",dir:"vert",cssReq:{left:0,right:"auto",top:"auto",bottom:"auto",height:"auto"}},center:{dir:"center",cssReq:{left:"auto",right:"auto",top:"auto",bottom:"auto",height:"auto",width:"auto"}}},state={id:Math.floor(Math.random()*1e4),container:{},north:{},south:{},east:{},west:{},center:{}},altEdge={top:"bottom",bottom:"top",left:"right",right:"left"},altSide={north:"south",south:"north",east:"west",west:"east"},isStr=function(e){if(typeof e=="string")return!0;if(typeof e=="object")try{var t=e.constructor.toString().match(/string/i);return t!==null}catch(n){}return!1},str=function(e){return typeof e=="string"||isStr(e)?$.trim(e):e},min=function(e,t){return Math.min(e,t)},max=function(e,t){return Math.max(e,t)},transformData=function(e){var t={defaults:{fxSettings:{}},north:{fxSettings:{}},south:{fxSettings:{}},east:{fxSettings:{}},west:{fxSettings:{}},center:{fxSettings:{}}};e=e||{};e.effects||e.defaults||e.north||e.south||e.west||e.east||e.center?t=$.extend(t,e):$.each(e,function(e,n){a=e.split("__");t[a[1]?a[0]:"defaults"][a[1]?a[1]:a[0]]=n});return t},setFlowCallback=function(e,t,n){function o(e,n){i=c[e];if(!i.doCallback){i.doCallback=!0;i.callback=r}else{cpPane=i.callback.split(",")[1];cpPane!=e&&cpPane!=t&&o(cpPane,!0)}}var r=e+","+t+","+(n?1:0),i,s;$.each(c.borderPanes.split(","),function(e,t){if(c[t].isMoving){o(t);return!1}})},execFlowCallback=function(e){var t=c[e];c.isLayoutBusy=!1;delete t.isMoving;if(!t.doCallback||!t.callback)return;t.doCallback=!1;var n=t.callback.split(","),r=n[2]>0?!0:!1;n[0]=="open"?open(n[1],r):n[0]=="close"&&close(n[1],r);t.doCallback||(t.callback=null)},execUserCallback=function(pane,v_fn){if(!v_fn)return;var fn;try{if(typeof v_fn=="function")fn=v_fn;else{if(typeof v_fn!="string")return;if(v_fn.indexOf(",")>0){var args=v_fn.split(","),fn=eval(args[0]);if(typeof fn=="function"&&args.length>1)return fn(args[1])}else fn=eval(v_fn)}if(typeof fn=="function")return fn(pane,$Ps[pane],$.extend({},state[pane]),$.extend({},options[pane]),options.name)}catch(ex){}},cssNum=function(e,t){var n=0,r=!1,i="";if(!$.browser.msie&&$.css(e[0],"display",true)=="none"){r=!0;i=$.css(e[0],"visibility",!0);e.css({display:"block",visibility:"hidden"})}n=parseInt($.css(e[0],t,!0),10)||0;if(r){e.css({display:"none"});i&&i!="hidden"&&e.css({visibility:i})}return n},cssW=function(e,t){var n;if(isStr(e)){e=str(e);n=$Ps[e]}else n=$(e);if(t<=0)return 0;t>0||(t=isStr(e)?getPaneSize(e):n.outerWidth());return $.boxModel?t-cssNum(n,"paddingLeft")-cssNum(n,"paddingRight")-($.css(n[0],"borderLeftStyle",true)=="none"?0:cssNum(n,"borderLeftWidth"))-($.css(n[0],"borderRightStyle",true)=="none"?0:cssNum(n,"borderRightWidth")):t},cssH=function(e,t){var n;if(isStr(e)){e=str(e);n=$Ps[e]}else n=$(e);if(t<=0)return 0;t>0||(t=isStr(e)?getPaneSize(e):n.outerHeight());return $.boxModel?t-cssNum(n,"paddingTop")-cssNum(n,"paddingBottom")-($.css(n[0],"borderTopStyle",true)=="none"?0:cssNum(n,"borderTopWidth"))-($.css(n[0],"borderBottomStyle",true)=="none"?0:cssNum(n,"borderBottomWidth")):t},cssSize=function(e,t){return c[e].dir=="horz"?cssH(e,t):cssW(e,t)},getPaneSize=function(e,t){var n=$Ps[e],r=options[e],i=state[e],s=t?r.spacing_open:0,o=t?r.spacing_closed:0;return!n||i.isHidden?0:i.isClosed||i.isSliding&&t?o:c[e].dir=="horz"?n.outerHeight()+s:n.outerWidth()+s},setPaneMinMaxSizes=function(e){var t=cDims,n=c[e].edge,r=c[e].dir,i=options[e],s=state[e],o=$Ps[e],u=$Ps[altSide[e]],a=i.spacing_open,f=options[altSide[e]].spacing_open,l=u?r=="horz"?u.outerHeight():u.outerWidth():0,h=r=="horz"?t.innerHeight:t.innerWidth,p=h-a-l-f,d=s.minSize||0,v=Math.min(s.maxSize||9999,p),m,g;switch(e){case"north":m=t.offsetTop+d;g=t.offsetTop+v;break;case"west":m=t.offsetLeft+d;g=t.offsetLeft+v;break;case"south":m=t.offsetTop+t.innerHeight-v;g=t.offsetTop+t.innerHeight-d;break;case"east":m=t.offsetLeft+t.innerWidth-v;g=t.offsetLeft+t.innerWidth-d}$.extend(s,{minSize:d,maxSize:v,minPosition:m,maxPosition:g})},getPaneDims=function(){var d={top:getPaneSize("north",!0),bottom:getPaneSize("south",!0),left:getPaneSize("west",!0),right:getPaneSize("east",!0),width:0,height:0};with(d){width=cDims.innerWidth-left-right;height=cDims.innerHeight-bottom-top;top+=cDims.top;bottom+=cDims.bottom;left+=cDims.left;right+=cDims.right}return d},getElemDims=function(e){var t={},n,r,i;$.each("Left,Right,Top,Bottom".split(","),function(){n=str(this);r=t["border"+n]=cssNum(e,"border"+n+"Width");i=t["padding"+n]=cssNum(e,"padding"+n);t["offset"+n]=r+i;e==$Container&&(t[n.toLowerCase()]=$.boxModel?i:0)});t.innerWidth=t.outerWidth=e.outerWidth();t.innerHeight=t.outerHeight=e.outerHeight();if($.boxModel){t.innerWidth-=t.offsetLeft+t.offsetRight;t.innerHeight-=t.offsetTop+t.offsetBottom}return t},setTimer=function(e,t,n,r){var i=window.layout=window.layout||{},s=i.timers=i.timers||{},o="layout_"+state.id+"_"+e+"_"+t;if(s[o])return;s[o]=setTimeout(n,r)},clearTimer=function(e,t){var n=window.layout=window.layout||{},r=n.timers=n.timers||{},i="layout_"+state.id+"_"+e+"_"+t;if(r[i]){clearTimeout(r[i]);delete r[i];return!0}return!1},create=function(){initOptions();initContainer();initPanes();initHandles();initResizable();sizeContent("all");if(options.scrollToBookmarkOnLoad)with(self.location)hash&&replace(hash);initHotkeys();$(window).resize(function(){var e="timerLayout_"+state.id;window[e]&&clearTimeout(window[e]);window[e]=null;window[e]=setTimeout(resizeAll,100)})},initContainer=function(){try{if($Container[0].tagName=="BODY"){$("html").css({height:"100%",overflow:"hidden"});$("body").css({position:"relative",height:"100%",overflow:"hidden",margin:0,padding:0,border:"none"})}else{var e={overflow:"hidden"},t=$Container.css("position"),n=$Container.css("height");if(!$Container.hasClass("ui-layout-pane")){if(!t||"fixed,absolute,relative".indexOf(t)<0)e.position="relative";if(!n||n=="auto")e.height="100%"}$Container.css(e)}}catch(r){}cDims=state.container=getElemDims($Container)},initHotkeys=function(){$.each(c.borderPanes.split(","),function(e,t){var n=options[t];if(n.enableCursorHotkey||n.customHotkey){$(document).keydown(keyDown);return!1}})},initOptions=function(){opts=transformData(opts);if(opts.effects){$.extend(effects,opts.effects);delete opts.effects}$.each("name,scrollToBookmarkOnLoad".split(","),function(e,t){if(opts[t]!==undefined)options[t]=opts[t];else if(opts.defaults[t]!==undefined){options[t]=opts.defaults[t];delete opts.defaults[t]}});$.each("paneSelector,resizerCursor,customHotkey".split(","),function(e,t){delete opts.defaults[t]});$.extend(options.defaults,opts.defaults);c.center=$.extend(!0,{},c.defaults,c.center);$.extend(options.center,opts.center);var e=$.extend(!0,{},options.defaults,opts.defaults,options.center);$.each("paneClass,contentSelector,contentIgnoreSelector,applyDefaultStyles,showOverflowOnHover".split(","),function(t,n){options.center[n]=e[n]});var t=options.defaults;$.each(c.borderPanes.split(","),function(e,n){c[n]=$.extend(!0,{},c.defaults,c[n]);o=options[n]=$.extend(!0,{},options.defaults,options[n],opts.defaults,opts[n]);o.paneClass||(o.paneClass=defaults.paneClass);o.resizerClass||(o.resizerClass=defaults.resizerClass);o.togglerClass||(o.togglerClass=defaults.togglerClass);$.each(["_open","_close",""],function(e,r){var i="fxName"+r,s="fxSpeed"+r,u="fxSettings"+r;o[i]=opts[n][i]||opts[n].fxName||opts.defaults[i]||opts.defaults.fxName||o[i]||o.fxName||t[i]||t.fxName||"none";var a=o[i];if(a=="none"||!$.effects||!$.effects[a]||!effects[a]&&!o[u]&&!o.fxSettings)a=o[i]="none";var f=effects[a]||{},l=f.all||{},c=f[n]||{};o[u]=$.extend({},l,c,t.fxSettings||{},t[u]||{},o.fxSettings,o[u],opts.defaults.fxSettings,opts.defaults[u]||{},opts[n].fxSettings,opts[n][u]||{});o[s]=opts[n][s]||opts[n].fxSpeed||opts.defaults[s]||opts.defaults.fxSpeed||o[s]||o[u].duration||o.fxSpeed||o.fxSettings.duration||t.fxSpeed||t.fxSettings.duration||c.duration||l.duration||"normal"})})},initPanes=function(){$.each(c.allPanes.split(","),function(){var e=str(this),t=options[e],n=state[e],r=n.fx,i=c[e].dir,s=t.size=="auto"||isNaN(t.size)?0:t.size,o=t.minSize||1,u=t.maxSize||9999,a=t.spacing_open||0,f=t.paneSelector,l=$.browser.msie&&$.browser.version<7,h={},p,d;$Cs[e]=!1;if(f.substr(0,1)==="#")p=$Ps[e]=$Container.find(f+":first");else{p=$Ps[e]=$Container.children(f+":first");p.length||(p=$Ps[e]=$Container.children("form:first").children(f+":first"))}if(!p.length){$Ps[e]=!1;return!0}p.attr("pane",e).addClass(t.paneClass+" "+t.paneClass+"-"+e);if(e!="center"){n.isClosed=!1;n.isSliding=!1;n.isResizing=!1;n.isHidden=!1;n.noRoom=!1;c[e].pins=[]}h=$.extend({visibility:"visible",display:"block"},c.defaults.cssReq,c[e].cssReq);t.applyDefaultStyles&&$.extend(h,c.defaults.cssDef,c[e].cssDef);p.css(h);h={};switch(e){case"north":h.top=cDims.top;h.left=cDims.left;h.right=cDims.right;break;case"south":h.bottom=cDims.bottom;h.left=cDims.left;h.right=cDims.right;break;case"west":h.left=cDims.left;break;case"east":h.right=cDims.right;break;case"center":}if(i=="horz"){if(s===0||s=="auto"){p.css({height:"auto"});s=p.outerHeight()}s=max(s,o);s=min(s,u);s=min(s,cDims.innerHeight-a);h.height=max(1,cssH(e,s));n.size=s;n.maxSize=u;n.minSize=max(o,s-h.height+1);p.css(h)}else if(i=="vert"){if(s===0||s=="auto"){p.css({width:"auto","float":"left"});s=p.outerWidth();p.css({"float":"none"})}s=max(s,o);s=min(s,u);s=min(s,cDims.innerWidth-a);h.width=max(1,cssW(e,s));n.size=s;n.maxSize=u;n.minSize=max(o,s-h.width+1);p.css(h);sizeMidPanes(e,null,!0)}else if(e=="center"){p.css(h);sizeMidPanes("center",null,!0)}if(t.initClosed&&t.closable){p.hide().addClass("closed");n.isClosed=!0}else if(t.initHidden||t.initClosed){hide(e,!0);n.isHidden=!0}else p.addClass("open");t.showOverflowOnHover&&p.hover(allowOverflow,resetOverflow);if(t.contentSelector){d=$Cs[e]=p.children(t.contentSelector+":first");if(!d.length){$Cs[e]=!1;return!0}d.css(c.content.cssReq);t.applyDefaultStyles&&d.css(c.content.cssDef);p.css({overflow:"hidden"})}})},initHandles=function(){$.each(c.borderPanes.split(","),function(){var e=str(this),t=options[e],n=state[e],r=t.resizerClass,i=t.togglerClass,s=$Ps[e];$Rs[e]=!1;$Ts[e]=!1;if(!s||!t.closable&&!t.resizable)return;var o=c[e].edge,u=s.is(":visible"),a=u?t.spacing_open:t.spacing_closed,f="-"+e,l=u?"-open":"-closed",h,p;h=$Rs[e]=$("<span></span>");(!u||!t.resizable)&&!u&&t.slidable&&h.attr("title",t.sliderTip).css("cursor",t.sliderCursor);h.attr("id",t.paneSelector.substr(0,1)=="#"?t.paneSelector.substr(1)+"-resizer":"").attr("resizer",e).css(c.resizers.cssReq).css(o,cDims[o]+getPaneSize(e)).addClass(r+" "+r+f+" "+r+l+" "+r+f+l).appendTo($Container);t.applyDefaultStyles&&h.css(c.resizers.cssDef);if(t.closable){p=$Ts[e]=$("<div></div>");p.attr("id",t.paneSelector.substr(0,1)=="#"?t.paneSelector.substr(1)+"-toggler":"").css(c.togglers.cssReq).attr("title",u?t.togglerTip_open:t.togglerTip_closed).click(function(t){toggle(e);t.stopPropagation()}).mouseover(function(e){e.stopPropagation()}).addClass(i+" "+i+f+" "+i+l+" "+i+f+l).appendTo(h);t.togglerContent_open&&$("<span>"+t.togglerContent_open+"</span>").addClass("content content-open").css("display",n.isClosed?"none":"block").appendTo(p);t.togglerContent_closed&&$("<span>"+t.togglerContent_closed+"</span>").addClass("content content-closed").css("display",n.isClosed?"block":"none").appendTo(p);t.applyDefaultStyles&&p.css(c.togglers.cssDef);u||bindStartSlidingEvent(e,!0)}});sizeHandles("all",!0)},initResizable=function(){var e=typeof $.fn.draggable=="function",t,n,r;$.each(c.borderPanes.split(","),function(){var t=str(this),n=options[t],i=state[t];if(!e||!$Ps[t]||!n.resizable){n.resizable=!1;return!0}var s=n.resizerClass,o=s+"-drag",u=s+"-"+t+"-drag",a=s+"-dragging",f=s+"-"+t+"-dragging",l=!1,h=$Ps[t],p=$Rs[t];i.isClosed||p.attr("title",n.resizerTip).css("cursor",n.resizerCursor);p.draggable({containment:$Container[0],axis:c[t].dir=="horz"?"y":"x",delay:200,distance:1,helper:"clone",opacity:n.resizerDragOpacity,zIndex:c.zIndex.resizing,start:function(e,s){if(!1===execUserCallback(t,n.onresize_start))return!1;i.isResizing=!0;clearTimer(t,"closeSlider");p.addClass(o+" "+u);l=!1;var a=t=="east"||t=="south"?n.spacing_open:0;setPaneMinMaxSizes(t);i.minPosition-=a;i.maxPosition-=a;r=c[t].dir=="horz"?"top":"left";$(n.maskIframesOnResize===!0?"iframe":n.maskIframesOnResize).each(function(){$('<div class="ui-layout-mask"/>').css({background:"#fff",opacity:"0.001",zIndex:9,position:"absolute",width:this.offsetWidth+"px",height:this.offsetHeight+"px"}).css($(this).offset()).appendTo(this.parentNode)})},drag:function(e,n){if(!l){$(".ui-draggable-dragging").addClass(a+" "+f).children().css("visibility","hidden");l=!0;i.isSliding&&$Ps[t].css("zIndex",c.zIndex.sliding)}n.position[r]<i.minPosition?n.position[r]=i.minPosition:n.position[r]>i.maxPosition&&(n.position[r]=i.maxPosition)},stop:function(e,n){var r=n.position,s,a;p.removeClass(o+" "+u);switch(t){case"north":s=r.top;break;case"west":s=r.left;break;case"south":s=cDims.outerHeight-r.top-p.outerHeight();break;case"east":s=cDims.outerWidth-r.left-p.outerWidth()}a=s-cDims[c[t].edge];sizePane(t,a);$("div.ui-layout-mask").remove();i.isResizing=!1}})})},hide=function(e,t){var n=options[e],r=state[e],i=$Ps[e],s=$Rs[e];if(!i||r.isHidden)return;if(!1===execUserCallback(e,n.onhide_start))return;r.isSliding=!1;s&&s.hide();if(t||r.isClosed){r.isClosed=!0;r.isHidden=!0;i.hide();sizeMidPanes(c[e].dir=="horz"?"all":"center");execUserCallback(e,n.onhide_end||n.onhide)}else{r.isHiding=!0;close(e,!1)}},show=function(e,t){var n=options[e],r=state[e],i=$Ps[e],s=$Rs[e];if(!i||!r.isHidden)return;if(!1===execUserCallback(e,n.onshow_start))return;r.isSliding=!1;r.isShowing=!0;s&&n.spacing_open>0&&s.show();t===!1?close(e,!0):open(e)},toggle=function(e){var t=state[e];t.isHidden?show(e):t.isClosed?open(e):close(e)},close=function(e,t,n){function b(){bindStartSlidingEvent(e,!0);g||execUserCallback(e,o.onclose_end||o.onclose);g&&execUserCallback(e,o.onshow_end||o.onshow);y&&execUserCallback(e,o.onhide_end||o.onhide);execFlowCallback(e)}var r=$Ps[e],i=$Rs[e],s=$Ts[e],o=options[e],u=state[e],a=!n&&!u.isClosed&&o.fxName_close!="none",f=c[e].edge,l=o.resizerClass,h=o.togglerClass,p="-"+e,d="-open",v="-sliding",m="-closed",g=u.isShowing,y=u.isHiding;delete u.isShowing;delete u.isHiding;if(!r||!o.resizable&&!o.closable)return;if(!t&&u.isClosed&&!g)return;if(c.isLayoutBusy){setFlowCallback("close",e,t);return}if(!g&&!1===execUserCallback(e,o.onclose_start))return;c[e].isMoving=!0;c.isLayoutBusy=!0;u.isClosed=!0;y?u.isHidden=!0:g&&(u.isHidden=!1);syncPinBtns(e,!1);u.isSliding||sizeMidPanes(c[e].dir=="horz"?"all":"center");if(i){i.css(f,cDims[f]).removeClass(l+d+" "+l+p+d).removeClass(l+v+" "+l+p+v).addClass(l+m+" "+l+p+m);o.resizable&&i.draggable("disable").css("cursor","default").attr("title","");s&&s.removeClass(h+d+" "+h+p+d).addClass(h+m+" "+h+p+m).attr("title",o.togglerTip_closed);sizeHandles()}if(a){lockPaneForFX(e,!0);r.hide(o.fxName_close,o.fxSettings_close,o.fxSpeed_close,function(){lockPaneForFX(e,!1);if(!u.isClosed)return;b()})}else{r.hide();b()}},open=function(e,t,n){function y(){u.isSliding||sizeMidPanes(c[e].dir=="vert"?"center":"all");if(i){i.css(f,cDims[f]+getPaneSize(e)).removeClass(l+v+" "+l+p+v).addClass(l+d+" "+l+p+d).addClass(u.isSliding?l+m+" "+l+p+m:"");o.resizable?i.draggable("enable").css("cursor",o.resizerCursor).attr("title",o.resizerTip):i.css("cursor","default");s&&s.removeClass(h+v+" "+h+p+v).addClass(h+d+" "+h+p+d).attr("title",o.togglerTip_open);sizeHandles("all")}sizeContent(e);syncPinBtns(e,!u.isSliding);execUserCallback(e,o.onopen_end||o.onopen);g&&execUserCallback(e,o.onshow_end||o.onshow);execFlowCallback(e)}var r=$Ps[e],i=$Rs[e],s=$Ts[e],o=options[e],u=state[e],a=!n&&u.isClosed&&o.fxName_open!="none",f=c[e].edge,l=o.resizerClass,h=o.togglerClass,p="-"+e,d="-open",v="-closed",m="-sliding",g=u.isShowing;delete u.isShowing;if(!r||!o.resizable&&!o.closable)return;if(!u.isClosed&&!u.isSliding)return;if(u.isHidden&&!g){show(e,!0);return}if(c.isLayoutBusy){setFlowCallback("open",e,t);return}if(!1===execUserCallback(e,o.onopen_start))return;c[e].isMoving=!0;c.isLayoutBusy=!0;u.isSliding&&!t&&bindStopSlidingEvents(e,!1);u.isClosed=!1;g&&(u.isHidden=!1);setPaneMinMaxSizes(e);u.size>u.maxSize&&r.css(c[e].sizeType,max(1,cssSize(e,u.maxSize)));bindStartSlidingEvent(e,!1);if(a){lockPaneForFX(e,!0);r.show(o.fxName_open,o.fxSettings_open,o.fxSpeed_open,function(){lockPaneForFX(e,!1);if(u.isClosed)return;y()})}else{r.show();y()}},lockPaneForFX=function(e,t){var n=$Ps[e];if(t){n.css({zIndex:c.zIndex.animation});e=="south"?n.css({top:cDims.top+cDims.innerHeight-n.outerHeight()}):e=="east"&&n.css({left:cDims.left+cDims.innerWidth-n.outerWidth()})}else{state[e].isSliding||n.css({zIndex:c.zIndex.pane_normal});e=="south"?n.css({top:"auto"}):e=="east"&&n.css({left:"auto"})}},bindStartSlidingEvent=function(e,t){var n=options[e],r=$Rs[e],i=n.slideTrigger_open;if(!r||!n.slidable)return;i!="click"&&i!="dblclick"&&i!="mouseover"&&(i="click");r[t?"bind":"unbind"](i,slideOpen).css("cursor",t?n.sliderCursor:"default").attr("title",t?n.sliderTip:"")},bindStopSlidingEvents=function(e,t){function a(t){clearTimer(e,"closeSlider");t.stopPropagation()}var n=options[e],r=state[e],i=n.slideTrigger_close,s=t?"bind":"unbind",o=$Ps[e],u=$Rs[e];r.isSliding=t;clearTimer(e,"closeSlider");o.css({zIndex:t?c.zIndex.sliding:c.zIndex.pane_normal});u.css({zIndex:t?c.zIndex.sliding:c.zIndex.resizer_normal});i!="click"&&i!="mouseout"&&(i="mouseout");if(t){o.bind(i,slideClosed);u.bind(i,slideClosed);if(i="mouseout"){o.bind("mouseover",a);u.bind("mouseover",a)}}else{o.unbind(i);u.unbind(i);if(i="mouseout"){o.unbind("mouseover");u.unbind("mouseover");clearTimer(e,"closeSlider")}}},slideOpen=function(){var e=$(this).attr("resizer");if(state[e].isClosed){bindStopSlidingEvents(e,!0);open(e,!0)}},slideClosed=function(){function i(){bindStopSlidingEvents(t,!1);r.isClosed||close(t)}var e=$(this),t=e.attr("pane")||e.attr("resizer"),n=options[t],r=state[t];if(r.isClosed||r.isResizing)return;n.slideTrigger_close=="click"?i():setTimer(t,"closeSlider",i,300)},sizePane=function(e,t){var n=c[e].edge,r=c[e].dir,i=options[e],s=state[e],o=$Ps[e],u=$Rs[e];setPaneMinMaxSizes(e);s.minSize=max(s.minSize,i.minSize);i.maxSize>0&&(s.maxSize=min(s.maxSize,i.maxSize));t=max(t,s.minSize);t=min(t,s.maxSize);s.size=t;u.css(n,t+cDims[n]);o.css(c[e].sizeType,max(1,cssSize(e,t)));s.isSliding||sizeMidPanes(r=="horz"?"all":"center");sizeHandles();sizeContent(e);execUserCallback(e,i.onresize_end||i.onresize)},sizeMidPanes=function(e,t,n){if(!e||e=="all")e="east,west,center";var r=getPaneDims();t&&$.extend(r,t);$.each(e.split(","),function(){if(!$Ps[this])return;var e=str(this),t=options[e],i=state[e],s=$Ps[e],o=$Rs[e],u=!0,a={};if(e=="center"){r=getPaneDims();a=$.extend({},r);a.width=max(1,cssW(e,a.width));a.height=max(1,cssH(e,a.height));u=a.width>1&&a.height>1;if($.browser.msie&&(!$.boxModel||$.browser.version<7)){$Ps.north&&$Ps.north.css({width:cssW($Ps.north,cDims.innerWidth)});$Ps.south&&$Ps.south.css({width:cssW($Ps.south,cDims.innerWidth)})}}else{a.top=r.top;a.bottom=r.bottom;a.height=max(1,cssH(e,r.height));u=a.height>1}if(u){s.css(a);if(i.noRoom){i.noRoom=!1;if(i.isHidden)return;show(e,!i.isClosed)}if(!n){sizeContent(e);execUserCallback(e,t.onresize_end||t.onresize)}}else if(!i.noRoom){i.noRoom=!0;if(i.isHidden)return;if(n){s.hide();o&&o.hide()}else hide(e)}})},sizeContent=function(e){if(!e||e=="all")e=c.allPanes;$.each(e.split(","),function(){if(!$Cs[this])return;var e=str(this),t=options[e].contentIgnoreSelector,n=$Ps[e],r=$Cs[e],i=r[0],s=cssH(n);n.children().each(function(){if(this==i)return;var e=$(this);if(!t||!e.is(t))s-=e.outerHeight()});s>0&&(s=cssH(r,s));s<1?r.hide():r.css({height:s}).show()})},sizeHandles=function(e,t){if(!e||e=="all")e=c.borderPanes;$.each(e.split(","),function(){var e=str(this),n=options[e],r=state[e],i=$Ps[e],s=$Rs[e],o=$Ts[e];if(!i||!s||!n.resizable&&!n.closable)return;var u=c[e].dir,a=r.isClosed?"_closed":"_open",f=n["spacing"+a],l=n["togglerAlign"+a],h=n["togglerLength"+a],p,d,v={};if(f==0){s.hide();return}!r.noRoom&&!r.isHidden&&s.show();if(u=="horz"){p=i.outerWidth();s.css({width:max(1,cssW(s,p)),height:max(1,cssH(s,f)),left:cssNum(i,"left")})}else{p=i.outerHeight();s.css({height:max(1,cssH(s,p)),width:max(1,cssW(s,f)),top:cDims.top+getPaneSize("north",!0)})}if(o){if(h==0||r.isSliding&&n.hideTogglerOnSlide){o.hide();return}o.show();if(!(h>0)||h=="100%"||h>p){h=p;d=0}else if(typeof l=="string")switch(l){case"top":case"left":d=0;break;case"bottom":case"right":d=p-h;break;case"middle":case"center":default:d=Math.floor((p-h)/2)}else{var m=parseInt(l);l>=0?d=m:d=p-h+m}var g=n.togglerContent_open?o.children(".content-open"):!1,y=n.togglerContent_closed?o.children(".content-closed"):!1,b=r.isClosed?y:g;g&&g.css("display",r.isClosed?"none":"block");y&&y.css("display",r.isClosed?"block":"none");if(u=="horz"){var w=cssW(o,h);o.css({width:max(0,w),height:max(1,cssH(o,f)),left:d});b&&b.css("marginLeft",Math.floor((w-b.outerWidth())/2))}else{var E=cssH(o,h);o.css({height:max(0,E),width:max(1,cssW(o,f)),top:d});b&&b.css("marginTop",Math.floor((E-b.outerHeight())/2))}}if(t&&n.initHidden){s.hide();o&&o.hide()}})},resizeAll=function(){var e=cDims.innerWidth,t=cDims.innerHeight;cDims=state.container=getElemDims($Container);var n=cDims.innerHeight<t,r=cDims.innerWidth<e,i,s;(n||r)&&$.each(["south","north","east","west"],function(e,t){i=state[t];s=c[t].dir;if(!i.isClosed&&(n&&s=="horz"||r&&s=="vert")){setPaneMinMaxSizes(t);i.size>i.maxSize&&sizePane(t,i.maxSize)}});sizeMidPanes("all");sizeHandles("all")},$Container=$(this).css({overflow:"hidden"}),$Ps={},$Cs={},$Rs={},$Ts={},c=config,cDims=state.container;create();return{options:options,state:state,panes:$Ps,toggle:toggle,open:open,close:close,hide:hide,show:show,resizeContent:sizeContent,sizePane:sizePane,resizeAll:resizeAll,addToggleBtn:addToggleBtn,addOpenBtn:addOpenBtn,addCloseBtn:addCloseBtn,addPinBtn:addPinBtn,allowOverflow:allowOverflow,resetOverflow:resetOverflow,cssWidth:cssW,cssHeight:cssH}}})(jQuery);