//  ui.core, ui.draggable, ui.resizable, ui.dialog
(function(d){var c=d.fn.remove;d.fn.remove=function(){d("*",this).add(this).triggerHandler("remove");return c.apply(this,arguments)};function b(f){function h(i){var j=i.style;return(j.display!="none"&&j.visibility!="hidden")}var g=h(f);(g&&d.each(d.dir(f,"parentNode"),function(){return(g=h(this))}));return g}d.extend(d.expr[":"],{data:function(g,h,f){return d.data(g,f[3])},tabbable:function(g,h,f){var j=g.nodeName.toLowerCase();return(g.tabIndex>=0&&(("a"==j&&g.href)||(/input|select|textarea|button/.test(j)&&"hidden"!=g.type&&!g.disabled))&&b(g))}});d.keyCode={BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38};function a(i,j,k,h){function g(m){var l=d[i][j][m]||[];return(typeof l=="string"?l.split(/,?\s+/):l)}var f=g("getter");if(h.length==1&&typeof h[0]=="string"){f=f.concat(g("getterSetter"))}return(d.inArray(k,f)!=-1)}d.widget=function(g,f){var h=g.split(".")[0];g=g.split(".")[1];d.fn[g]=function(l){var j=(typeof l=="string"),k=Array.prototype.slice.call(arguments,1);if(j&&l.substring(0,1)=="_"){return this}if(j&&a(h,g,l,k)){var i=d.data(this[0],g);return(i?i[l].apply(i,k):undefined)}return this.each(function(){var m=d.data(this,g);(!m&&!j&&d.data(this,g,new d[h][g](this,l)));(m&&j&&d.isFunction(m[l])&&m[l].apply(m,k))})};d[h][g]=function(k,j){var i=this;this.widgetName=g;this.widgetEventPrefix=d[h][g].eventPrefix||g;this.widgetBaseClass=h+"-"+g;this.options=d.extend({},d.widget.defaults,d[h][g].defaults,d.metadata&&d.metadata.get(k)[g],j);this.element=d(k).bind("setData."+g,function(n,l,m){return i._setData(l,m)}).bind("getData."+g,function(m,l){return i._getData(l)}).bind("remove",function(){return i.destroy()});this._init()};d[h][g].prototype=d.extend({},d.widget.prototype,f);d[h][g].getterSetter="option"};d.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName)},option:function(h,i){var g=h,f=this;if(typeof h=="string"){if(i===undefined){return this._getData(h)}g={};g[h]=i}d.each(g,function(j,k){f._setData(j,k)})},_getData:function(f){return this.options[f]},_setData:function(f,g){this.options[f]=g;if(f=="disabled"){this.element[g?"addClass":"removeClass"](this.widgetBaseClass+"-disabled")}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(g,i,h){var f=(g==this.widgetEventPrefix?g:this.widgetEventPrefix+g);i=i||d.event.fix({type:f,target:this.element[0]});return this.element.triggerHandler(f,[i,h],this.options[g])}};d.widget.defaults={disabled:false};d.ui={plugin:{add:function(g,h,k){var j=d.ui[g].prototype;for(var f in k){j.plugins[f]=j.plugins[f]||[];j.plugins[f].push([h,k[f]])}},call:function(f,h,g){var k=f.plugins[h];if(!k){return}for(var j=0;j<k.length;j++){if(f.options[k[j][0]]){k[j][1].apply(f.element,g)}}}},cssCache:{},css:function(f){if(d.ui.cssCache[f]){return d.ui.cssCache[f]}var g=d('<div class="ui-gen">').addClass(f).css({position:"absolute",top:"-5000px",left:"-5000px",display:"block"}).appendTo("body");d.ui.cssCache[f]=!!((!(/auto|default/).test(g.css("cursor"))||(/^[1-9]/).test(g.css("height"))||(/^[1-9]/).test(g.css("width"))||!(/none/).test(g.css("backgroundImage"))||!(/transparent|rgba\(0, 0, 0, 0\)/).test(g.css("backgroundColor"))));try{d("body").get(0).removeChild(g.get(0))}catch(h){}return d.ui.cssCache[f]},disableSelection:function(f){return d(f).attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},enableSelection:function(f){return d(f).attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},hasScroll:function(i,g){if(d(i).css("overflow")=="hidden"){return false}var f=(g&&g=="left")?"scrollLeft":"scrollTop",h=false;if(i[f]>0){return true}i[f]=1;h=(i[f]>0);i[f]=0;return h}};d.ui.mouse={_mouseInit:function(){var f=this;this.element.bind("mousedown."+this.widgetName,function(g){return f._mouseDown(g)});if(d.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(d.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(h){(this._mouseStarted&&this._mouseUp(h));this._mouseDownEvent=h;var g=this,i=(h.which==1),f=(typeof this.options.cancel=="string"?d(h.target).parents().add(h.target).filter(this.options.cancel).length:false);if(!i||f||!this._mouseCapture(h)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){g.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(h)&&this._mouseDelayMet(h)){this._mouseStarted=(this._mouseStart(h)!==false);if(!this._mouseStarted){h.preventDefault();return true}}this._mouseMoveDelegate=function(j){return g._mouseMove(j)};this._mouseUpDelegate=function(j){return g._mouseUp(j)};d(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);return false},_mouseMove:function(f){if(d.browser.msie&&!f.button){return this._mouseUp(f)}if(this._mouseStarted){this._mouseDrag(f);return false}if(this._mouseDistanceMet(f)&&this._mouseDelayMet(f)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,f)!==false);(this._mouseStarted?this._mouseDrag(f):this._mouseUp(f))}return !this._mouseStarted},_mouseUp:function(f){d(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._mouseStop(f)}return false},_mouseDistanceMet:function(f){return(Math.max(Math.abs(this._mouseDownEvent.pageX-f.pageX),Math.abs(this._mouseDownEvent.pageY-f.pageY))>=this.options.distance)},_mouseDelayMet:function(f){return this.mouseDelayMet},_mouseStart:function(f){},_mouseDrag:function(f){},_mouseStop:function(f){},_mouseCapture:function(f){return true}};d.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);(function(a){a.widget("ui.draggable",a.extend({},a.ui.mouse,{getHandle:function(c){var b=!this.options.handle||!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==c.target){b=true}});return b},createHelper:function(){var c=this.options;var b=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[e])):(c.helper=="clone"?this.element.clone():this.element);if(!b.parents("body").length){b.appendTo((c.appendTo=="parent"?this.element[0].parentNode:c.appendTo))}if(b[0]!=this.element[0]&&!(/(fixed|absolute)/).test(b.css("position"))){b.css("position","absolute")}return b},_init:function(){if(this.options.helper=="original"&&!(/^(?:r|a|f)/).test(this.element.css("position"))){this.element[0].style.position="relative"}(this.options.cssNamespace&&this.element.addClass(this.options.cssNamespace+"-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit()},_mouseCapture:function(b){var c=this.options;if(this.helper||c.disabled||a(b.target).is(".ui-resizable-handle")){return false}this.handle=this.getHandle(b);if(!this.handle){return false}return true},_mouseStart:function(d){var f=this.options;this.helper=this.createHelper();if(a.ui.ddmanager){a.ui.ddmanager.current=this}this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)};this.cssPosition=this.helper.css("position");this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.offset.click={left:d.pageX-this.offset.left,top:d.pageY-this.offset.top};this.cacheScrollParents();this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();if(this.offsetParent[0]==document.body&&a.browser.mozilla){b={top:0,left:0}}this.offset.parent={top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};if(this.cssPosition=="relative"){var c=this.element.position();this.offset.relative={top:c.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollTopParent.scrollTop(),left:c.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollLeftParent.scrollLeft()}}else{this.offset.relative={top:0,left:0}}this.originalPosition=this._generatePosition(d);this.cacheHelperProportions();if(f.cursorAt){this.adjustOffsetFromHelper(f.cursorAt)}a.extend(this,{PAGEY_INCLUDES_SCROLL:(this.cssPosition=="absolute"&&(!this.scrollTopParent[0].tagName||(/(html|body)/i).test(this.scrollTopParent[0].tagName))),PAGEX_INCLUDES_SCROLL:(this.cssPosition=="absolute"&&(!this.scrollLeftParent[0].tagName||(/(html|body)/i).test(this.scrollLeftParent[0].tagName))),OFFSET_PARENT_NOT_SCROLL_PARENT_Y:this.scrollTopParent[0]!=this.offsetParent[0]&&!(this.scrollTopParent[0]==document&&(/(body|html)/i).test(this.offsetParent[0].tagName)),OFFSET_PARENT_NOT_SCROLL_PARENT_X:this.scrollLeftParent[0]!=this.offsetParent[0]&&!(this.scrollLeftParent[0]==document&&(/(body|html)/i).test(this.offsetParent[0].tagName))});if(f.containment){this.setContainment()}this._propagate("start",d);this.cacheHelperProportions();if(a.ui.ddmanager&&!f.dropBehaviour){a.ui.ddmanager.prepareOffsets(this,d)}this.helper.addClass("ui-draggable-dragging");this._mouseDrag(d);return true},cacheScrollParents:function(){this.scrollTopParent=function(b){do{if(/auto|scroll/.test(b.css("overflow"))||(/auto|scroll/).test(b.css("overflow-y"))){return b}b=b.parent()}while(b[0].parentNode);return a(document)}(this.helper);this.scrollLeftParent=function(b){do{if(/auto|scroll/.test(b.css("overflow"))||(/auto|scroll/).test(b.css("overflow-x"))){return b}b=b.parent()}while(b[0].parentNode);return a(document)}(this.helper)},adjustOffsetFromHelper:function(b){if(b.left!=undefined){this.offset.click.left=b.left+this.margins.left}if(b.right!=undefined){this.offset.click.left=this.helperProportions.width-b.right+this.margins.left}if(b.top!=undefined){this.offset.click.top=b.top+this.margins.top}if(b.bottom!=undefined){this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top}},cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},setContainment:function(){var f=this.options;if(f.containment=="parent"){f.containment=this.helper[0].parentNode}if(f.containment=="document"||f.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(f.containment=="document"?document:window).width()-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),(a(f.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)]}if(!(/^(document|window|parent)$/).test(f.containment)){var c=a(f.containment)[0];var d=a(f.containment).offset();var b=(a(c).css("overflow")!="hidden");this.containment=[d.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left,d.top+(parseInt(a(c).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top,d.left+(b?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),d.top+(b?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)]}},_convertPositionTo:function(c,f){if(!f){f=this.position}var b=c=="absolute"?1:-1;return{top:(f.top+this.offset.relative.top*b+this.offset.parent.top*b-(this.cssPosition=="fixed"||this.PAGEY_INCLUDES_SCROLL||this.OFFSET_PARENT_NOT_SCROLL_PARENT_Y?0:this.scrollTopParent.scrollTop())*b+(this.cssPosition=="fixed"?a(document).scrollTop():0)*b+this.margins.top*b),left:(f.left+this.offset.relative.left*b+this.offset.parent.left*b-(this.cssPosition=="fixed"||this.PAGEX_INCLUDES_SCROLL||this.OFFSET_PARENT_NOT_SCROLL_PARENT_X?0:this.scrollLeftParent.scrollLeft())*b+(this.cssPosition=="fixed"?a(document).scrollLeft():0)*b+this.margins.left*b)}},_generatePosition:function(f){var g=this.options;var b={top:(f.pageY-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"||this.PAGEY_INCLUDES_SCROLL||this.OFFSET_PARENT_NOT_SCROLL_PARENT_Y?0:this.scrollTopParent.scrollTop())-(this.cssPosition=="fixed"?a(document).scrollTop():0)),left:(f.pageX-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"||this.PAGEX_INCLUDES_SCROLL||this.OFFSET_PARENT_NOT_SCROLL_PARENT_X?0:this.scrollLeftParent.scrollLeft())-(this.cssPosition=="fixed"?a(document).scrollLeft():0))};if(!this.originalPosition){return b}if(this.containment){if(b.left<this.containment[0]){b.left=this.containment[0]}if(b.top<this.containment[1]){b.top=this.containment[1]}if(b.left>this.containment[2]){b.left=this.containment[2]}if(b.top>this.containment[3]){b.top=this.containment[3]}}if(g.grid){var d=this.originalPosition.top+Math.round((b.top-this.originalPosition.top)/g.grid[1])*g.grid[1];b.top=this.containment?(!(d<this.containment[1]||d>this.containment[3])?d:(!(d<this.containment[1])?d-g.grid[1]:d+g.grid[1])):d;var c=this.originalPosition.left+Math.round((b.left-this.originalPosition.left)/g.grid[0])*g.grid[0];b.left=this.containment?(!(c<this.containment[0]||c>this.containment[2])?c:(!(c<this.containment[0])?c-g.grid[0]:c+g.grid[0])):c}return b},_mouseDrag:function(b){this.position=this._generatePosition(b);this.positionAbs=this._convertPositionTo("absolute");this.position=this._propagate("drag",b)||this.position;if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}if(a.ui.ddmanager){a.ui.ddmanager.drag(this,b)}return false},_mouseStop:function(c){var d=false;if(a.ui.ddmanager&&!this.options.dropBehaviour){var d=a.ui.ddmanager.drop(this,c)}if((this.options.revert=="invalid"&&!d)||(this.options.revert=="valid"&&d)||this.options.revert===true||(a.isFunction(this.options.revert)&&this.options.revert.call(this.element,d))){var b=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10)||500,function(){b._propagate("stop",c);b._clear()})}else{this._propagate("stop",c);this._clear()}return false},_clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.options.helper!="original"&&!this.cancelHelperRemoval){this.helper.remove()}this.helper=null;this.cancelHelperRemoval=false},plugins:{},uiHash:function(b){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,options:this.options}},_propagate:function(c,b){a.ui.plugin.call(this,c,[b,this.uiHash()]);if(c=="drag"){this.positionAbs=this._convertPositionTo("absolute")}return this.element.triggerHandler(c=="drag"?c:"drag"+c,[b,this.uiHash()],this.options[c])},destroy:function(){if(!this.element.data("draggable")){return}this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy()}}));a.extend(a.ui.draggable,{defaults:{appendTo:"parent",axis:false,cancel:":input",delay:0,distance:1,helper:"original",scope:"default",cssNamespace:"ui"}});a.ui.plugin.add("draggable","cursor",{start:function(d,c){var b=a("body");if(b.css("cursor")){c.options._cursor=b.css("cursor")}b.css("cursor",c.options.cursor)},stop:function(c,b){if(b.options._cursor){a("body").css("cursor",b.options._cursor)}}});a.ui.plugin.add("draggable","zIndex",{start:function(d,c){var b=a(c.helper);if(b.css("zIndex")){c.options._zIndex=b.css("zIndex")}b.css("zIndex",c.options.zIndex)},stop:function(c,b){if(b.options._zIndex){a(b.helper).css("zIndex",b.options._zIndex)}}});a.ui.plugin.add("draggable","opacity",{start:function(d,c){var b=a(c.helper);if(b.css("opacity")){c.options._opacity=b.css("opacity")}b.css("opacity",c.options.opacity)},stop:function(c,b){if(b.options._opacity){a(b.helper).css("opacity",b.options._opacity)}}});a.ui.plugin.add("draggable","iframeFix",{start:function(c,b){a(b.options.iframeFix===true?"iframe":b.options.iframeFix).each(function(){a('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(a(this).offset()).appendTo("body")})},stop:function(c,b){a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});a.ui.plugin.add("draggable","scroll",{start:function(d,c){var f=c.options;var b=a(this).data("draggable");f.scrollSensitivity=f.scrollSensitivity||20;f.scrollSpeed=f.scrollSpeed||20;b.overflowY=function(g){do{if(/auto|scroll/.test(g.css("overflow"))||(/auto|scroll/).test(g.css("overflow-y"))){return g}g=g.parent()}while(g[0].parentNode);return a(document)}(this);b.overflowX=function(g){do{if(/auto|scroll/.test(g.css("overflow"))||(/auto|scroll/).test(g.css("overflow-x"))){return g}g=g.parent()}while(g[0].parentNode);return a(document)}(this);if(b.overflowY[0]!=document&&b.overflowY[0].tagName!="HTML"){b.overflowYOffset=b.overflowY.offset()}if(b.overflowX[0]!=document&&b.overflowX[0].tagName!="HTML"){b.overflowXOffset=b.overflowX.offset()}},drag:function(f,d){var g=d.options,b=false;var c=a(this).data("draggable");if(c.overflowY[0]!=document&&c.overflowY[0].tagName!="HTML"){if((c.overflowYOffset.top+c.overflowY[0].offsetHeight)-f.pageY<g.scrollSensitivity){c.overflowY[0].scrollTop=b=c.overflowY[0].scrollTop+g.scrollSpeed}if(f.pageY-c.overflowYOffset.top<g.scrollSensitivity){c.overflowY[0].scrollTop=b=c.overflowY[0].scrollTop-g.scrollSpeed}}else{if(f.pageY-a(document).scrollTop()<g.scrollSensitivity){b=a(document).scrollTop(a(document).scrollTop()-g.scrollSpeed)}if(a(window).height()-(f.pageY-a(document).scrollTop())<g.scrollSensitivity){b=a(document).scrollTop(a(document).scrollTop()+g.scrollSpeed)}}if(c.overflowX[0]!=document&&c.overflowX[0].tagName!="HTML"){if((c.overflowXOffset.left+c.overflowX[0].offsetWidth)-f.pageX<g.scrollSensitivity){c.overflowX[0].scrollLeft=b=c.overflowX[0].scrollLeft+g.scrollSpeed}if(f.pageX-c.overflowXOffset.left<g.scrollSensitivity){c.overflowX[0].scrollLeft=b=c.overflowX[0].scrollLeft-g.scrollSpeed}}else{if(f.pageX-a(document).scrollLeft()<g.scrollSensitivity){b=a(document).scrollLeft(a(document).scrollLeft()-g.scrollSpeed)}if(a(window).width()-(f.pageX-a(document).scrollLeft())<g.scrollSensitivity){b=a(document).scrollLeft(a(document).scrollLeft()+g.scrollSpeed)}}if(b!==false){a.ui.ddmanager.prepareOffsets(c,f)}}});a.ui.plugin.add("draggable","snap",{start:function(d,c){var b=a(this).data("draggable");b.snapElements=[];a(c.options.snap.constructor!=String?(c.options.snap.items||":data(draggable)"):c.options.snap).each(function(){var g=a(this);var f=g.offset();if(this!=b.element[0]){b.snapElements.push({item:this,width:g.outerWidth(),height:g.outerHeight(),top:f.top,left:f.left})}})},drag:function(w,p){var h=a(this).data("draggable");var x=p.options.snapTolerance||20;var v=p.absolutePosition.left,u=v+h.helperProportions.width,g=p.absolutePosition.top,f=g+h.helperProportions.height;for(var s=h.snapElements.length-1;s>=0;s--){var q=h.snapElements[s].left,o=q+h.snapElements[s].width,n=h.snapElements[s].top,z=n+h.snapElements[s].height;if(!((q-x<v&&v<o+x&&n-x<g&&g<z+x)||(q-x<v&&v<o+x&&n-x<f&&f<z+x)||(q-x<u&&u<o+x&&n-x<g&&g<z+x)||(q-x<u&&u<o+x&&n-x<f&&f<z+x))){if(h.snapElements[s].snapping){(h.options.snap.release&&h.options.snap.release.call(h.element,null,a.extend(h.uiHash(),{snapItem:h.snapElements[s].item})))}h.snapElements[s].snapping=false;continue}if(p.options.snapMode!="inner"){var c=Math.abs(n-f)<=x;var y=Math.abs(z-g)<=x;var k=Math.abs(q-u)<=x;var m=Math.abs(o-v)<=x;if(c){p.position.top=h._convertPositionTo("relative",{top:n-h.helperProportions.height,left:0}).top}if(y){p.position.top=h._convertPositionTo("relative",{top:z,left:0}).top}if(k){p.position.left=h._convertPositionTo("relative",{top:0,left:q-h.helperProportions.width}).left}if(m){p.position.left=h._convertPositionTo("relative",{top:0,left:o}).left}}var j=(c||y||k||m);if(p.options.snapMode!="outer"){var c=Math.abs(n-g)<=x;var y=Math.abs(z-f)<=x;var k=Math.abs(q-v)<=x;var m=Math.abs(o-u)<=x;if(c){p.position.top=h._convertPositionTo("relative",{top:n,left:0}).top}if(y){p.position.top=h._convertPositionTo("relative",{top:z-h.helperProportions.height,left:0}).top}if(k){p.position.left=h._convertPositionTo("relative",{top:0,left:q}).left}if(m){p.position.left=h._convertPositionTo("relative",{top:0,left:o-h.helperProportions.width}).left}}if(!h.snapElements[s].snapping&&(c||y||k||m||j)){(h.options.snap.snap&&h.options.snap.snap.call(h.element,null,a.extend(h.uiHash(),{snapItem:h.snapElements[s].item})))}h.snapElements[s].snapping=(c||y||k||m||j)}}});a.ui.plugin.add("draggable","connectToSortable",{start:function(d,c){var b=a(this).data("draggable");b.sortables=[];a(c.options.connectToSortable).each(function(){if(a.data(this,"sortable")){var f=a.data(this,"sortable");b.sortables.push({instance:f,shouldRevert:f.options.revert});f._refreshItems();f._propagate("activate",d,b)}})},stop:function(d,c){var b=a(this).data("draggable");a.each(b.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;b.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert){this.instance.options.revert=true}this.instance._mouseStop(d);this.instance.element.triggerHandler("sortreceive",[d,a.extend(this.instance.ui(),{sender:b.element})],this.instance.options.receive);this.instance.options.helper=this.instance.options._helper}else{this.instance._propagate("deactivate",d,b)}})},drag:function(g,f){var d=a(this).data("draggable"),b=this;var c=function(m){var i=m.left,k=i+m.width,j=m.top,h=j+m.height;return(i<(this.positionAbs.left+this.offset.click.left)&&(this.positionAbs.left+this.offset.click.left)<k&&j<(this.positionAbs.top+this.offset.click.top)&&(this.positionAbs.top+this.offset.click.top)<h)};a.each(d.sortables,function(h){if(c.call(d,this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=a(b).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return f.helper[0]};g.target=this.instance.currentItem[0];this.instance._mouseCapture(g,true);this.instance._mouseStart(g,true,true);this.instance.offset.click.top=d.offset.click.top;this.instance.offset.click.left=d.offset.click.left;this.instance.offset.parent.left-=d.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=d.offset.parent.top-this.instance.offset.parent.top;d._propagate("toSortable",g)}if(this.instance.currentItem){this.instance._mouseDrag(g)}}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._mouseStop(g,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder){this.instance.placeholder.remove()}d._propagate("fromSortable",g)}}})}});a.ui.plugin.add("draggable","stack",{start:function(d,b){var c=a.makeArray(a(b.options.stack.group)).sort(function(g,f){return(parseInt(a(g).css("zIndex"),10)||b.options.stack.min)-(parseInt(a(f).css("zIndex"),10)||b.options.stack.min)});a(c).each(function(f){this.style.zIndex=b.options.stack.min+f});this[0].style.zIndex=b.options.stack.min+c.length}})})(jQuery);(function(a){a.widget("ui.resizable",a.extend({},a.ui.mouse,{_init:function(){var q=this,r=this.options;var u=this.element.css("position");this.originalElement=this.element;this.element.addClass("ui-resizable").css({position:/static/.test(u)?"relative":u});a.extend(r,{_aspectRatio:!!(r.aspectRatio),helper:r.helper||r.ghost||r.animate?r.helper||"proxy":null,knobHandles:r.knobHandles===true?"ui-resizable-knob-handle":r.knobHandles});var j="1px solid #DEDEDE";r.defaultTheme={"ui-resizable":{display:"block"},"ui-resizable-handle":{position:"absolute",background:"#F2F2F2",fontSize:"0.1px"},"ui-resizable-n":{cursor:"n-resize",height:"4px",left:"0px",right:"0px",borderTop:j},"ui-resizable-s":{cursor:"s-resize",height:"4px",left:"0px",right:"0px",borderBottom:j},"ui-resizable-e":{cursor:"e-resize",width:"4px",top:"0px",bottom:"0px",borderRight:j},"ui-resizable-w":{cursor:"w-resize",width:"4px",top:"0px",bottom:"0px",borderLeft:j},"ui-resizable-se":{cursor:"se-resize",width:"4px",height:"4px",borderRight:j,borderBottom:j},"ui-resizable-sw":{cursor:"sw-resize",width:"4px",height:"4px",borderBottom:j,borderLeft:j},"ui-resizable-ne":{cursor:"ne-resize",width:"4px",height:"4px",borderRight:j,borderTop:j},"ui-resizable-nw":{cursor:"nw-resize",width:"4px",height:"4px",borderLeft:j,borderTop:j}};r.knobTheme={"ui-resizable-handle":{background:"#F2F2F2",border:"1px solid #808080",height:"8px",width:"8px"},"ui-resizable-n":{cursor:"n-resize",top:"0px",left:"45%"},"ui-resizable-s":{cursor:"s-resize",bottom:"0px",left:"45%"},"ui-resizable-e":{cursor:"e-resize",right:"0px",top:"45%"},"ui-resizable-w":{cursor:"w-resize",left:"0px",top:"45%"},"ui-resizable-se":{cursor:"se-resize",right:"0px",bottom:"0px"},"ui-resizable-sw":{cursor:"sw-resize",left:"0px",bottom:"0px"},"ui-resizable-nw":{cursor:"nw-resize",left:"0px",top:"0px"},"ui-resizable-ne":{cursor:"ne-resize",right:"0px",top:"0px"}};r._nodeName=this.element[0].nodeName;if(r._nodeName.match(/canvas|textarea|input|select|button|img/i)){var b=this.element;if(/relative/.test(b.css("position"))&&a.browser.opera){b.css({position:"relative",top:"auto",left:"auto"})}b.wrap(a('<div class="ui-wrapper"	style="overflow: hidden;"></div>').css({position:b.css("position"),width:b.outerWidth(),height:b.outerHeight(),top:b.css("top"),left:b.css("left")}));var l=this.element;this.element=this.element.parent();this.element.data("resizable",this);this.element.css({marginLeft:l.css("marginLeft"),marginTop:l.css("marginTop"),marginRight:l.css("marginRight"),marginBottom:l.css("marginBottom")});l.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if(a.browser.safari&&r.preventDefault){l.css("resize","none")}r.proportionallyResize=l.css({position:"static",zoom:1,display:"block"});this.element.css({margin:l.css("margin")});this._proportionallyResize()}if(!r.handles){r.handles=!a(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}}if(r.handles.constructor==String){r.zIndex=r.zIndex||1000;if(r.handles=="all"){r.handles="n,e,s,w,se,sw,ne,nw"}var s=r.handles.split(",");r.handles={};var h={handle:"position: absolute; display: none; overflow:hidden;",n:"top: 0pt; width:100%;",e:"right: 0pt; height:100%;",s:"bottom: 0pt; width:100%;",w:"left: 0pt; height:100%;",se:"bottom: 0pt; right: 0px;",sw:"bottom: 0pt; left: 0px;",ne:"top: 0pt; right: 0px;",nw:"top: 0pt; left: 0px;"};for(var v=0;v<s.length;v++){var w=a.trim(s[v]),p=r.defaultTheme,g="ui-resizable-"+w,c=!a.ui.css(g)&&!r.knobHandles,t=a.ui.css("ui-resizable-knob-handle"),x=a.extend(p[g],p["ui-resizable-handle"]),d=a.extend(r.knobTheme[g],!t?r.knobTheme["ui-resizable-handle"]:{});var m=/sw|se|ne|nw/.test(w)?{zIndex:++r.zIndex}:{};var k=(c?h[w]:""),f=a(['<div class="ui-resizable-handle ',g,'" style="',k,h.handle,'"></div>'].join("")).css(m);r.handles[w]=".ui-resizable-"+w;this.element.append(f.css(c?x:{}).css(r.knobHandles?d:{}).addClass(r.knobHandles?"ui-resizable-knob-handle":"").addClass(r.knobHandles))}if(r.knobHandles){this.element.addClass("ui-resizable-knob").css(!a.ui.css("ui-resizable-knob")?{}:{})}}this._renderAxis=function(A){A=A||this.element;for(var o in r.handles){if(r.handles[o].constructor==String){r.handles[o]=a(r.handles[o],this.element).show()}if(r.transparent){r.handles[o].css({opacity:0})}if(this.element.is(".ui-wrapper")&&r._nodeName.match(/textarea|input|select|button/i)){var y=a(r.handles[o],this.element),z=0;z=/sw|ne|nw|se|n|s/.test(o)?y.outerHeight():y.outerWidth();var n=["padding",/ne|nw|n/.test(o)?"Top":/se|sw|s/.test(o)?"Bottom":/^e$/.test(o)?"Right":"Left"].join("");if(!r.transparent){A.css(n,z)}this._proportionallyResize()}if(!a(r.handles[o]).length){continue}}};this._renderAxis(this.element);r._handles=a(".ui-resizable-handle",q.element);if(r.disableSelection){r._handles.each(function(n,o){a.ui.disableSelection(o)})}r._handles.mouseover(function(){if(!r.resizing){if(this.className){var i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}q.axis=r.axis=i&&i[1]?i[1]:"se"}});if(r.autoHide){r._handles.hide();a(q.element).addClass("ui-resizable-autohide").hover(function(){a(this).removeClass("ui-resizable-autohide");r._handles.show()},function(){if(!r.resizing){a(this).addClass("ui-resizable-autohide");r._handles.hide()}})}this._mouseInit()},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,options:this.options,originalSize:this.originalSize,originalPosition:this.originalPosition}},_propagate:function(c,b){a.ui.plugin.call(this,c,[b,this.ui()]);if(c!="resize"){this.element.triggerHandler(["resize",c].join(""),[b,this.ui()],this.options[c])}},destroy:function(){var d=this.element,c=d.children(".ui-resizable").get(0);this._mouseDestroy();var b=function(f){a(f).removeClass("ui-resizable ui-resizable-disabled").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};b(d);if(d.is(".ui-wrapper")&&c){d.parent().append(a(c).css({position:d.css("position"),width:d.outerWidth(),height:d.outerHeight(),top:d.css("top"),left:d.css("left")})).end().remove();b(c)}},_mouseCapture:function(d){if(this.options.disabled){return false}var c=false;for(var b in this.options.handles){if(a(this.options.handles[b])[0]==d.target){c=true}}if(!c){return false}return true},_mouseStart:function(j){var c=this.options,b=this.element.position(),d=this.element,i=function(n){return parseInt(n,10)||0},h=a.browser.msie&&a.browser.version<7;c.resizing=true;c.documentScroll={top:a(document).scrollTop(),left:a(document).scrollLeft()};if(d.is(".ui-draggable")||(/absolute/).test(d.css("position"))){var k=a.browser.msie&&!c.containment&&(/absolute/).test(d.css("position"))&&!(/relative/).test(d.parent().css("position"));var l=k?c.documentScroll.top:0,g=k?c.documentScroll.left:0;d.css({position:"absolute",top:(b.top+l),left:(b.left+g)})}if(a.browser.opera&&/relative/.test(d.css("position"))){d.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var m=i(this.helper.css("left")),f=i(this.helper.css("top"));if(c.containment){m+=a(c.containment).scrollLeft()||0;f+=a(c.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:m,top:f};this.size=c.helper||h?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=c.helper||h?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:m,top:f};this.sizeDiff={width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:j.pageX,top:j.pageY};c.aspectRatio=(typeof c.aspectRatio=="number")?c.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);if(c.preserveCursor){a("body").css("cursor",this.axis+"-resize")}this._propagate("start",j);return true},_mouseDrag:function(j){var d=this.helper,c=this.options,k={},n=this,g=this.originalMousePosition,l=this.axis;var p=(j.pageX-g.left)||0,m=(j.pageY-g.top)||0;var f=this._change[l];if(!f){return false}var i=f.apply(this,[j,p,m]),h=a.browser.msie&&a.browser.version<7,b=this.sizeDiff;if(c._aspectRatio||j.shiftKey){i=this._updateRatio(i,j)}i=this._respectSize(i,j);this._propagate("resize",j);d.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!c.helper&&c.proportionallyResize){this._proportionallyResize()}this._updateCache(i);this.element.triggerHandler("resize",[j,this.ui()],this.options.resize);return false},_mouseStop:function(j){this.options.resizing=false;var f=this.options,i=function(n){return parseInt(n,10)||0},l=this;if(f.helper){var d=f.proportionallyResize,b=d&&(/textarea/i).test(d.get(0).nodeName),c=b&&a.ui.hasScroll(d.get(0),"left")?0:l.sizeDiff.height,h=b?0:l.sizeDiff.width;var m={width:(l.size.width-h),height:(l.size.height-c)},g=(parseInt(l.element.css("left"),10)+(l.position.left-l.originalPosition.left))||null,k=(parseInt(l.element.css("top"),10)+(l.position.top-l.originalPosition.top))||null;if(!f.animate){this.element.css(a.extend(m,{top:k,left:g}))}if(f.helper&&!f.animate){this._proportionallyResize()}}if(f.preserveCursor){a("body").css("cursor","auto")}this._propagate("stop",j);if(f.helper){this.helper.remove()}return false},_updateCache:function(b){var c=this.options;this.offset=this.helper.offset();if(b.left){this.position.left=b.left}if(b.top){this.position.top=b.top}if(b.height){this.size.height=b.height}if(b.width){this.size.width=b.width}},_updateRatio:function(d,f){var g=this.options,h=this.position,c=this.size,b=this.axis;if(d.height){d.width=(c.height*g.aspectRatio)}else{if(d.width){d.height=(c.width/g.aspectRatio)}}if(b=="sw"){d.left=h.left+(c.width-d.width);d.top=null}if(b=="nw"){d.top=h.top+(c.height-d.height);d.left=h.left+(c.width-d.width)}return d},_respectSize:function(i,j){var g=this.helper,f=this.options,p=f._aspectRatio||j.shiftKey,n=this.axis,r=i.width&&f.maxWidth&&f.maxWidth<i.width,k=i.height&&f.maxHeight&&f.maxHeight<i.height,d=i.width&&f.minWidth&&f.minWidth>i.width,q=i.height&&f.minHeight&&f.minHeight>i.height;if(d){i.width=f.minWidth}if(q){i.height=f.minHeight}if(r){i.width=f.maxWidth}if(k){i.height=f.maxHeight}var c=this.originalPosition.left+this.originalSize.width,m=this.position.top+this.size.height;var h=/sw|nw|w/.test(n),b=/nw|ne|n/.test(n);if(d&&h){i.left=c-f.minWidth}if(r&&h){i.left=c-f.maxWidth}if(q&&b){i.top=m-f.minHeight}if(k&&b){i.top=m-f.maxHeight}var l=!i.width&&!i.height;if(l&&!i.left&&i.top){i.top=null}else{if(l&&!i.top&&i.left){i.left=null}}return i},_proportionallyResize:function(){var h=this.options;if(!h.proportionallyResize){return}var f=h.proportionallyResize,d=this.helper||this.element;if(!h.borderDif){var c=[f.css("borderTopWidth"),f.css("borderRightWidth"),f.css("borderBottomWidth"),f.css("borderLeftWidth")],g=[f.css("paddingTop"),f.css("paddingRight"),f.css("paddingBottom"),f.css("paddingLeft")];h.borderDif=a.map(c,function(b,k){var j=parseInt(b,10)||0,l=parseInt(g[k],10)||0;return j+l})}f.css({height:(d.height()-h.borderDif[0]-h.borderDif[2])+"px",width:(d.width()-h.borderDif[1]-h.borderDif[3])+"px"})},_renderProxy:function(){var c=this.element,g=this.options;this.elementOffset=c.offset();if(g.helper){this.helper=this.helper||a('<div style="overflow:hidden;"></div>');var b=a.browser.msie&&a.browser.version<7,d=(b?1:0),f=(b?2:-1);this.helper.addClass(g.helper).css({width:c.outerWidth()+f,height:c.outerHeight()+f,position:"absolute",left:this.elementOffset.left-d+"px",top:this.elementOffset.top-d+"px",zIndex:++g.zIndex});this.helper.appendTo("body");if(g.disableSelection){a.ui.disableSelection(this.helper.get(0))}}else{this.helper=c}},_change:{e:function(d,c,b){return{width:this.originalSize.width+c}},w:function(g,c,b){var h=this.options,d=this.originalSize,f=this.originalPosition;return{left:f.left+c,width:d.width-c}},n:function(g,c,b){var h=this.options,d=this.originalSize,f=this.originalPosition;return{top:f.top+b,height:d.height-b}},s:function(d,c,b){return{height:this.originalSize.height+b}},se:function(d,c,b){return a.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[d,c,b]))},sw:function(d,c,b){return a.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[d,c,b]))},ne:function(d,c,b){return a.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[d,c,b]))},nw:function(d,c,b){return a.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[d,c,b]))}}}));a.extend(a.ui.resizable,{defaults:{cancel:":input",distance:1,delay:0,preventDefault:true,transparent:false,minWidth:10,minHeight:10,aspectRatio:false,disableSelection:true,preserveCursor:true,autoHide:false,knobHandles:false}});a.ui.plugin.add("resizable","containment",{start:function(j,l){var f=l.options,n=a(this).data("resizable"),h=n.element;var c=f.containment,g=(c instanceof a)?c.get(0):(/parent/.test(c))?h.parent().get(0):c;if(!g){return}n.containerElement=a(g);if(/document/.test(c)||c==document){n.containerOffset={left:0,top:0};n.containerPosition={left:0,top:0};n.parentData={element:a(document),left:0,top:0,width:a(document).width(),height:a(document).height()||document.body.parentNode.scrollHeight}}else{n.containerOffset=a(g).offset();n.containerPosition=a(g).position();n.containerSize={height:a(g).innerHeight(),width:a(g).innerWidth()};var k=n.containerOffset,b=n.containerSize.height,i=n.containerSize.width,d=(a.ui.hasScroll(g,"left")?g.scrollWidth:i),m=(a.ui.hasScroll(g)?g.scrollHeight:b);n.parentData={element:g,left:k.left,top:k.top,width:d,height:m}}},resize:function(i,l){var f=l.options,p=a(this).data("resizable"),c=p.containerSize,k=p.containerOffset,h=p.size,j=p.position,m=f._aspectRatio||i.shiftKey,b={top:0,left:0},d=p.containerElement;if(d[0]!=document&&/static/.test(d.css("position"))){b=p.containerPosition}if(j.left<(f.helper?k.left:b.left)){p.size.width=p.size.width+(f.helper?(p.position.left-k.left):(p.position.left-b.left));if(m){p.size.height=p.size.width/f.aspectRatio}p.position.left=f.helper?k.left:b.left}if(j.top<(f.helper?k.top:0)){p.size.height=p.size.height+(f.helper?(p.position.top-k.top):p.position.top);if(m){p.size.width=p.size.height*f.aspectRatio}p.position.top=f.helper?k.top:0}var g=(f.helper?p.offset.left-k.left:(p.position.left-b.left))+p.sizeDiff.width,n=(f.helper?p.offset.top-k.top:p.position.top)+p.sizeDiff.height;if(g+p.size.width>=p.parentData.width){p.size.width=p.parentData.width-g;if(m){p.size.height=p.size.width/f.aspectRatio}}if(n+p.size.height>=p.parentData.height){p.size.height=p.parentData.height-n;if(m){p.size.width=p.size.height*f.aspectRatio}}},stop:function(i,l){var c=l.options,n=a(this).data("resizable"),j=n.position,k=n.containerOffset,b=n.containerPosition,d=n.containerElement;var f=a(n.helper),p=f.offset(),m=f.innerWidth(),g=f.innerHeight();if(c.helper&&!c.animate&&/relative/.test(d.css("position"))){a(this).css({left:(p.left-k.left),top:(p.top-k.top),width:m,height:g})}if(c.helper&&!c.animate&&/static/.test(d.css("position"))){a(this).css({left:b.left+(p.left-k.left),top:b.top+(p.top-k.top),width:m,height:g})}}});a.ui.plugin.add("resizable","grid",{resize:function(i,k){var d=k.options,m=a(this).data("resizable"),h=m.size,f=m.originalSize,g=m.originalPosition,l=m.axis,j=d._aspectRatio||i.shiftKey;d.grid=typeof d.grid=="number"?[d.grid,d.grid]:d.grid;var c=Math.round((h.width-f.width)/(d.grid[0]||1))*(d.grid[0]||1),b=Math.round((h.height-f.height)/(d.grid[1]||1))*(d.grid[1]||1);if(/^(se|s|e)$/.test(l)){m.size.width=f.width+c;m.size.height=f.height+b}else{if(/^(ne)$/.test(l)){m.size.width=f.width+c;m.size.height=f.height+b;m.position.top=g.top-b}else{if(/^(sw)$/.test(l)){m.size.width=f.width+c;m.size.height=f.height+b;m.position.left=g.left-c}else{m.size.width=f.width+c;m.size.height=f.height+b;m.position.top=g.top-b;m.position.left=g.left-c}}}}});a.ui.plugin.add("resizable","animate",{stop:function(j,l){var g=l.options,m=a(this).data("resizable");var f=g.proportionallyResize,b=f&&(/textarea/i).test(f.get(0).nodeName),c=b&&a.ui.hasScroll(f.get(0),"left")?0:m.sizeDiff.height,i=b?0:m.sizeDiff.width;var d={width:(m.size.width-i),height:(m.size.height-c)},h=(parseInt(m.element.css("left"),10)+(m.position.left-m.originalPosition.left))||null,k=(parseInt(m.element.css("top"),10)+(m.position.top-m.originalPosition.top))||null;m.element.animate(a.extend(d,k&&h?{top:k,left:h}:{}),{duration:g.animateDuration||"slow",easing:g.animateEasing||"swing",step:function(){var n={width:parseInt(m.element.css("width"),10),height:parseInt(m.element.css("height"),10),top:parseInt(m.element.css("top"),10),left:parseInt(m.element.css("left"),10)};if(f){f.css({width:n.width,height:n.height})}m._updateCache(n);m._propagate("animate",j)}})}});a.ui.plugin.add("resizable","ghost",{start:function(f,d){var g=d.options,b=a(this).data("resizable"),h=g.proportionallyResize,c=b.size;if(!h){b.ghost=b.element.clone()}else{b.ghost=h.clone()}b.ghost.css({opacity:0.25,display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof g.ghost=="string"?g.ghost:"");b.ghost.appendTo(b.helper)},resize:function(d,c){var f=c.options,b=a(this).data("resizable"),g=f.proportionallyResize;if(b.ghost){b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})}},stop:function(d,c){var f=c.options,b=a(this).data("resizable"),g=f.proportionallyResize;if(b.ghost&&b.helper){b.helper.get(0).removeChild(b.ghost.get(0))}}});a.ui.plugin.add("resizable","alsoResize",{start:function(f,c){var g=c.options,b=a(this).data("resizable"),d=function(h){a(h).each(function(){a(this).data("resizable-alsoresize",{width:parseInt(a(this).width(),10),height:parseInt(a(this).height(),10),left:parseInt(a(this).css("left"),10),top:parseInt(a(this).css("top"),10)})})};if(typeof(g.alsoResize)=="object"){if(g.alsoResize.length){g.alsoResize=g.alsoResize[0];d(g.alsoResize)}else{a.each(g.alsoResize,function(h,i){d(h)})}}else{d(g.alsoResize)}},resize:function(g,f){var h=f.options,c=a(this).data("resizable"),d=c.originalSize,j=c.originalPosition;var i={height:(c.size.height-d.height)||0,width:(c.size.width-d.width)||0,top:(c.position.top-j.top)||0,left:(c.position.left-j.left)||0},b=function(k,l){a(k).each(function(){var o=a(this).data("resizable-alsoresize"),n={},m=l&&l.length?l:["width","height","top","left"];a.each(m||["width","height","top","left"],function(p,r){var q=(o[r]||0)+(i[r]||0);if(q&&q>=0){n[r]=q||null}});a(this).css(n)})};if(typeof(h.alsoResize)=="object"){a.each(h.alsoResize,function(k,l){b(k,l)})}else{b(h.alsoResize)}},stop:function(c,b){a(this).removeData("resizable-alsoresize-start")}})})(jQuery);(function(b){var a={dragStart:"start.draggable",drag:"drag.draggable",dragStop:"stop.draggable",maxHeight:"maxHeight.resizable",minHeight:"minHeight.resizable",maxWidth:"maxWidth.resizable",minWidth:"minWidth.resizable",resizeStart:"start.resizable",resize:"drag.resizable",resizeStop:"stop.resizable"};b.widget("ui.dialog",{_init:function(){this.originalTitle=this.element.attr("title");this.options.title=this.options.title||this.originalTitle;var l=this,m=this.options,g=this.element.removeAttr("title").addClass("ui-dialog-content").wrap("<div/>").wrap("<div/>"),i=(this.uiDialogContainer=g.parent()).addClass("ui-dialog-container").css({position:"relative",width:"100%",height:"100%"}),f=(this.uiDialogTitlebar=b("<div/>")).addClass("ui-dialog-titlebar").append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>').prependTo(i),k=m.title||"&nbsp;",c=b.ui.dialog.getTitleId(this.element),d=b("<span/>").addClass("ui-dialog-title").attr("id",c).html(k).prependTo(f),j=(this.uiDialog=i.parent()).appendTo(document.body).hide().addClass("ui-dialog").addClass(m.dialogClass).addClass(g.attr("className")).removeClass("ui-dialog-content").css({position:"absolute",width:m.width,height:m.height,overflow:"hidden",zIndex:m.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(n){(m.closeOnEscape&&n.keyCode&&n.keyCode==b.keyCode.ESCAPE&&l.close())}).mousedown(function(){l._moveToTop()}),h=(this.uiDialogButtonPane=b("<div/>")).addClass("ui-dialog-buttonpane").css({position:"absolute",bottom:0}).appendTo(j);this.uiDialogTitlebarClose=b(".ui-dialog-titlebar-close",f).hover(function(){b(this).addClass("ui-dialog-titlebar-close-hover")},function(){b(this).removeClass("ui-dialog-titlebar-close-hover")}).mousedown(function(n){n.stopPropagation()}).click(function(){l.close();return false});f.find("*").add(f).each(function(){b.ui.disableSelection(this)});(m.draggable&&b.fn.draggable&&this._makeDraggable());(m.resizable&&b.fn.resizable&&this._makeResizable());this._createButtons(m.buttons);this._isOpen=false;(m.bgiframe&&b.fn.bgiframe&&j.bgiframe());(m.autoOpen&&this.open())},destroy:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide();this.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content").hide().appendTo("body");this.uiDialog.remove();(this.originalTitle&&this.element.attr("title",this.originalTitle))},close:function(){if(false===this._trigger("beforeclose",null,{options:this.options})){return}(this.overlay&&this.overlay.destroy());this.uiDialog.hide(this.options.hide).unbind("keypress.ui-dialog");this._trigger("close",null,{options:this.options});b.ui.dialog.overlay.resize();this._isOpen=false},isOpen:function(){return this._isOpen},open:function(){if(this._isOpen){return}this.overlay=this.options.modal?new b.ui.dialog.overlay(this):null;(this.uiDialog.next().length&&this.uiDialog.appendTo("body"));this._position(this.options.position);this.uiDialog.show(this.options.show);(this.options.autoResize&&this._size());this._moveToTop(true);(this.options.modal&&this.uiDialog.bind("keypress.ui-dialog",function(f){if(f.keyCode!=b.keyCode.TAB){return}var d=b(":tabbable",this),g=d.filter(":first")[0],c=d.filter(":last")[0];if(f.target==c&&!f.shiftKey){setTimeout(function(){g.focus()},1)}else{if(f.target==g&&f.shiftKey){setTimeout(function(){c.focus()},1)}}}));this.uiDialog.find(":tabbable:first").focus();this._trigger("open",null,{options:this.options});this._isOpen=true},_createButtons:function(g){var f=this,c=false,d=this.uiDialogButtonPane;d.empty().hide();b.each(g,function(){return !(c=true)});if(c){d.show();b.each(g,function(h,i){b('<button type="button"></button>').text(h).click(function(){i.apply(f.element[0],arguments)}).appendTo(d)})}},_makeDraggable:function(){var c=this,d=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content",helper:d.dragHelper,handle:".ui-dialog-titlebar",start:function(){c._moveToTop();(d.dragStart&&d.dragStart.apply(c.element[0],arguments))},drag:function(){(d.drag&&d.drag.apply(c.element[0],arguments))},stop:function(){(d.dragStop&&d.dragStop.apply(c.element[0],arguments));b.ui.dialog.overlay.resize()}})},_makeResizable:function(g){g=(g===undefined?this.options.resizable:g);var c=this,f=this.options,d=typeof g=="string"?g:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",helper:f.resizeHelper,maxWidth:f.maxWidth,maxHeight:f.maxHeight,minWidth:f.minWidth,minHeight:f.minHeight,start:function(){(f.resizeStart&&f.resizeStart.apply(c.element[0],arguments))},resize:function(){(f.autoResize&&c._size.apply(c));(f.resize&&f.resize.apply(c.element[0],arguments))},handles:d,stop:function(){(f.autoResize&&c._size.apply(c));(f.resizeStop&&f.resizeStop.apply(c.element[0],arguments));b.ui.dialog.overlay.resize()}})},_moveToTop:function(f){if((this.options.modal&&!f)||(!this.options.stack&&!this.options.modal)){return this._trigger("focus",null,{options:this.options})}var d=this.options.zIndex,c=this.options;b(".ui-dialog:visible").each(function(){d=Math.max(d,parseInt(b(this).css("z-index"),10)||c.zIndex)});(this.overlay&&this.overlay.$el.css("z-index",++d));this.uiDialog.css("z-index",++d);this._trigger("focus",null,{options:this.options})},_position:function(i){var d=b(window),f=b(document),g=f.scrollTop(),c=f.scrollLeft(),h=g;if(b.inArray(i,["center","top","right","bottom","left"])>=0){i=[i=="right"||i=="left"?i:"center",i=="top"||i=="bottom"?i:"middle"]}if(i.constructor!=Array){i=["center","middle"]}if(i[0].constructor==Number){c+=i[0]}else{switch(i[0]){case"left":c+=0;break;case"right":c+=d.width()-this.uiDialog.width();break;default:case"center":c+=(d.width()-this.uiDialog.width())/2}}if(i[1].constructor==Number){g+=i[1]}else{switch(i[1]){case"top":g+=0;break;case"bottom":g+=d.height()-this.uiDialog.height();break;default:case"middle":g+=(d.height()-this.uiDialog.height())/2}}g=Math.max(g,h);this.uiDialog.css({top:g,left:c})},_setData:function(d,f){(a[d]&&this.uiDialog.data(a[d],f));switch(d){case"buttons":this._createButtons(f);break;case"draggable":(f?this._makeDraggable():this.uiDialog.draggable("destroy"));break;case"height":this.uiDialog.height(f);break;case"position":this._position(f);break;case"resizable":var c=this.uiDialog,g=this.uiDialog.is(":data(resizable)");(g&&!f&&c.resizable("destroy"));(g&&typeof f=="string"&&c.resizable("option","handles",f));(g||this._makeResizable(f));break;case"title":b(".ui-dialog-title",this.uiDialogTitlebar).html(f||"&nbsp;");break;case"width":this.uiDialog.width(f);break}b.widget.prototype._setData.apply(this,arguments)},_size:function(){var d=this.uiDialogContainer,h=this.uiDialogTitlebar,f=this.element,g=(parseInt(f.css("margin-top"),10)||0)+(parseInt(f.css("margin-bottom"),10)||0),c=(parseInt(f.css("margin-left"),10)||0)+(parseInt(f.css("margin-right"),10)||0);f.height(d.height()-h.outerHeight()-g);f.width(d.width()-c)}});b.extend(b.ui.dialog,{defaults:{autoOpen:true,autoResize:true,bgiframe:false,buttons:{},closeOnEscape:true,draggable:true,height:200,minHeight:100,minWidth:150,modal:false,overlay:{},position:"center",resizable:true,stack:true,width:300,zIndex:1000},getter:"isOpen",uuid:0,getTitleId:function(c){return"ui-dialog-title-"+(c.attr("id")||++this.uuid)},overlay:function(c){this.$el=b.ui.dialog.overlay.create(c)}});b.extend(b.ui.dialog.overlay,{instances:[],events:b.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(c){return c+".dialog-overlay"}).join(" "),create:function(d){if(this.instances.length===0){setTimeout(function(){b("a, :input").bind(b.ui.dialog.overlay.events,function(){var g=false;var i=b(this).parents(".ui-dialog");if(i.length){var f=b(".ui-dialog-overlay");if(f.length){var h=parseInt(f.css("z-index"),10);f.each(function(){h=Math.max(h,parseInt(b(this).css("z-index"),10))});g=parseInt(i.css("z-index"),10)>h}else{g=true}}return g})},1);b(document).bind("keydown.dialog-overlay",function(f){(d.options.closeOnEscape&&f.keyCode&&f.keyCode==b.keyCode.ESCAPE&&d.close())});b(window).bind("resize.dialog-overlay",b.ui.dialog.overlay.resize)}var c=b("<div/>").appendTo(document.body).addClass("ui-dialog-overlay").css(b.extend({borderWidth:0,margin:0,padding:0,position:"absolute",top:0,left:0,width:this.width(),height:this.height()},d.options.overlay));(d.options.bgiframe&&b.fn.bgiframe&&c.bgiframe());this.instances.push(c);return c},destroy:function(c){this.instances.splice(b.inArray(this.instances,c),1);if(this.instances.length===0){b("a, :input").add([document,window]).unbind(".dialog-overlay")}c.remove()},height:function(){if(b.browser.msie&&b.browser.version<7){var d=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);var c=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);if(d<c){return b(window).height()+"px"}else{return d+"px"}}else{if(b.browser.opera){return Math.max(window.innerHeight,b(document).height())+"px"}else{return b(document).height()+"px"}}},width:function(){if(b.browser.msie&&b.browser.version<7){var c=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);var d=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);if(c<d){return b(window).width()+"px"}else{return c+"px"}}else{if(b.browser.opera){return Math.max(window.innerWidth,b(document).width())+"px"}else{return b(document).width()+"px"}}},resize:function(){var c=b([]);b.each(b.ui.dialog.overlay.instances,function(){c=c.add(this)});c.css({width:0,height:0}).css({width:b.ui.dialog.overlay.width(),height:b.ui.dialog.overlay.height()})}});b.extend(b.ui.dialog.overlay.prototype,{destroy:function(){b.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);