/*
 * jQuery UI 1.0 - New Wave User Interface
 *
 * Copyright (c) 2007 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 */
(function($){$.ui=$.ui||{};$.extend($.ui,{plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,arguments){var c=instance.plugins[name];if(!c)return;var o=instance.interaction?instance.interaction.options:instance.options;var e=instance.interaction?instance.interaction.element:instance.element;for(var i=0;i<c.length;i++){if(o[c[i][0]])c[i][1].apply(e,arguments);}}},cssCache:{},css:function(name){if($.ui.cssCache[name])return $.ui.cssCache[name];var tmp=$("<div class='ui-resizable-gen'>").addClass(name).css({position:'absolute',top:'-5000px',left:'-5000px',display:'block'}).appendTo('body');$.ui.cssCache[name]=!!((/^[1-9]/.test(tmp.css('height'))||/^[1-9]/.test(tmp.css('width'))||!/none/.test(tmp.css('backgroundImage'))||!/transparent|rgba\(0, 0, 0, 0\)/.test(tmp.css('backgroundColor'))));try{$('body').get(0).removeChild(tmp.get(0));}catch(e){}
return $.ui.cssCache[name];},disableSelection:function(e){if(!e)return;e.unselectable="on";e.onselectstart=function(){return false;};if(e.style)e.style.MozUserSelect="none";},enableSelection:function(e){if(!e)return;e.unselectable="off";e.onselectstart=function(){return true;};if(e.style)e.style.MozUserSelect="";}});$.fn.extend({mouseInteraction:function(o){return this.each(function(){new $.ui.mouseInteraction(this,o);});},removeMouseInteraction:function(o){return this.each(function(){if($.data(this,"ui-mouse"))
$.data(this,"ui-mouse").destroy();});}});$.ui.mouseInteraction=function(element,options){var self=this;this.element=element;$.data(this.element,"ui-mouse",this);this.options=$.extend({},options);$(element).bind('mousedown.draggable',function(){return self.click.apply(self,arguments);});if($.browser.msie)$(element).attr('unselectable','on');};$.extend($.ui.mouseInteraction.prototype,{destroy:function(){$(this.element).unbind('mousedown.draggable');},trigger:function(){return this.click.apply(this,arguments);},click:function(e){if(e.which!=1||$.inArray(e.target.nodeName.toLowerCase(),this.options.dragPrevention)!=-1||(this.options.condition&&!this.options.condition.apply(this.options.executor||this,[e,this.element])))return true;var self=this;var initialize=function(){window.focus();self._MP={left:e.pageX,top:e.pageY};$(document).bind('mouseup.draggable',function(){return self.stop.apply(self,arguments);});$(document).bind('mousemove.draggable',function(){return self.drag.apply(self,arguments);});};if(this.options.delay){if(this.timer)clearInterval(this.timer);this.timer=setTimeout(initialize,this.options.delay);}else{initialize();}
return false;},stop:function(e){var o=this.options;if(!this.initialized)return $(document).unbind('mouseup.draggable').unbind('mousemove.draggable');if(this.options.stop)this.options.stop.call(this.options.executor||this,e,this.element);$(document).unbind('mouseup.draggable').unbind('mousemove.draggable');this.initialized=false;return false;},drag:function(e){var o=this.options;if($.browser.msie&&!e.button)return this.stop.apply(this,[e]);if(!this.initialized&&(Math.abs(this._MP.left-e.pageX)>=o.distance||Math.abs(this._MP.top-e.pageY)>=o.distance)){if(this.options.start)this.options.start.call(this.options.executor||this,e,this.element);this.initialized=true;}else{if(!this.initialized)return false;}
if(o.drag)o.drag.call(this.options.executor||this,e,this.element);return false;}});})(jQuery);
(function($){$.extend($.expr[':'],{draggable:"(' '+a.className+' ').indexOf(' ui-draggable ')"});$.fn.extend({makeDraggable:function(o){return this.each(function(){if(!$.data(this,"ui-draggable"))new $.ui.draggable(this,o);});},removeDraggable:function(){return this.each(function(){if($.data(this,"ui-draggable"))$.data(this,"ui-draggable").destroy();});},changeDraggable:function(key,value){var ret=null;this.each(function(){if($.data(this,"ui-draggable"))ret=$.data(this,"ui-draggable")[key](value);});return ret||this;},enableDraggable:function(){return this.each(function(){if($.data(this,"ui-draggable"))$.data(this,"ui-draggable").enable();});},disableDraggable:function(){return this.each(function(){if($.data(this,"ui-draggable"))$.data(this,"ui-draggable").disable();});}});$.ui.draggable=function(element,options){var self=this;this.element=$(element);$.data(element,"ui-draggable",this);this.element.addClass("ui-draggable");this.options=$.extend({},options);var o=this.options;$.extend(o,{helper:o.ghosting==true?'clone':(o.helper||'original'),handle:o.handle?($(o.handle,element)[0]?$(o.handle,element):this.element):this.element,appendTo:o.appendTo||'parent'});$(o.handle).mouseInteraction({executor:this,delay:o.delay,distance:o.distance||0,dragPrevention:o.prevention?o.prevention.toLowerCase().split(','):['input','textarea','button','select','option'],start:this.start,stop:this.stop,drag:this.drag,condition:function(e){return!(e.target.className.indexOf("ui-resizable-handle")!=-1||this.disabled);}});if(o.helper=='original'&&(this.element.css('position')=='static'||this.element.css('position')==''))
this.element.css('position','relative');};$.extend($.ui.draggable.prototype,{plugins:{},ui:function(e){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,instance:this,options:this.options};},propagate:function(n,e){$.ui.plugin.call(this,n,[e,this.ui()]);this.element.triggerHandler(n=="drag"?n:"drag"+n,[e,this.ui()],this.options[n]);},destroy:function(){this.element.removeClass("ui-draggable ui-draggable-disabled");this.handle.removeMouseInteraction();},enable:function(){this.element.removeClass("ui-draggable-disabled");this.disabled=false;},disable:function(){this.element.addClass("ui-draggable-disabled");this.disabled=true;},start:function(e){var o=this.options;if($.ui.ddmanager)$.ui.ddmanager.current=this;this.helper=typeof o.helper=='function'?$(o.helper.apply(this.element[0],[e])):(o.helper=='clone'?this.element.clone().appendTo((o.appendTo=='parent'?this.element[0].parentNode:o.appendTo)):this.element);if(this.helper[0]!=this.element[0])this.helper.css('position','absolute');this.offsetParent=(function(cp){while(cp){if(cp.style&&(/(absolute|relative|fixed)/).test($.css(cp,'position')))return $(cp);cp=cp.parentNode?cp.parentNode:null;};return $("body");})(this.helper[0].parentNode);this.elementOffset=this.element.offset();this.offsetParentOffset=this.offsetParent.offset();var elementPosition={left:this.elementOffset.left-this.offsetParentOffset.left,top:this.elementOffset.top-this.offsetParentOffset.top};this._pageX=e.pageX;this._pageY=e.pageY;this.clickOffset={left:e.pageX-this.elementOffset.left,top:e.pageY-this.elementOffset.top};var r=this.helper.css('position')=='relative';this.originalPosition={left:(r?parseInt(this.helper.css('left'))||0:elementPosition.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft)),top:(r?parseInt(this.helper.css('top'))||0:elementPosition.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop))};this.offset={left:e.pageX-this.originalPosition.left,top:e.pageY-this.originalPosition.top};this.propagate("start",e);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if($.ui.ddmanager&&!o.dropBehaviour)$.ui.ddmanager.prepareOffsets(this,e);if(o.cursorAt){if(o.cursorAt.top!=undefined||o.cursorAt.bottom!=undefined){this.offset.top-=this.clickOffset.top-(o.cursorAt.top!=undefined?o.cursorAt.top:(this.helperProportions.height-o.cursorAt.bottom));this.clickOffset.top=(o.cursorAt.top!=undefined?o.cursorAt.top:(this.helperProportions.height-o.cursorAt.bottom));}
if(o.cursorAt.left!=undefined||o.cursorAt.right!=undefined){this.offset.left-=this.clickOffset.left-(o.cursorAt.left!=undefined?o.cursorAt.left:(this.helperProportions.width-o.cursorAt.right));this.clickOffset.left=(o.cursorAt.left!=undefined?o.cursorAt.left:(this.helperProportions.width-o.cursorAt.right));}}
return false;},clear:function(){if($.ui.ddmanager)$.ui.ddmanager.current=null;this.helper=null;},stop:function(e){if($.ui.ddmanager&&!this.options.dropBehaviour)
$.ui.ddmanager.drop(this,e);this.propagate("stop",e);if(this.cancelHelperRemoval)return false;if(this.options.helper!='original')this.helper.remove();this.clear();return false;},drag:function(e){this.position={top:e.pageY-this.offset.top,left:e.pageX-this.offset.left};this.positionAbs={left:e.pageX-this.clickOffset.left,top:e.pageY-this.clickOffset.top};this.propagate("drag",e);this.helper.css({left:this.position.left+'px',top:this.position.top+'px'});if($.ui.ddmanager)$.ui.ddmanager.drag(this,e);return false;}});})(jQuery);
(function($){$.ui.plugin.add("draggable","cursor",{start:function(e,ui){var t=$('body');if(t.css("cursor"))ui.options._cursor=t.css("cursor");t.css("cursor",ui.options.cursor);},stop:function(e,ui){if(ui.options._cursor)$('body').css("cursor",ui.options._cursor);}});$.ui.plugin.add("draggable","zIndex",{start:function(e,ui){var t=$(ui.helper);if(t.css("zIndex"))ui.options._zIndex=t.css("zIndex");t.css('zIndex',ui.options.zIndex);},stop:function(e,ui){if(ui.options._zIndex)$(ui.helper).css('zIndex',ui.options._zIndex);}});$.ui.plugin.add("draggable","opacity",{start:function(e,ui){var t=$(ui.helper);if(t.css("opacity"))ui.options._opacity=t.css("opacity");t.css('opacity',ui.options.opacity);},stop:function(e,ui){if(ui.options._opacity)$(ui.helper).css('opacity',ui.options._opacity);}});$.ui.plugin.add("draggable","revert",{stop:function(e,ui){var self=ui.instance;self.cancelHelperRemoval=true;$(ui.helper).animate({left:self.originalPosition.left,top:self.originalPosition.top},parseInt(ui.options.revert,10)||500,function(){if(ui.options.helper!='original')self.helper.remove();self.clear();});}});$.ui.plugin.add("draggable","iframeFix",{start:function(e,ui){var o=ui.options;if(ui.instance.slowMode)return;if(o.iframeFix.constructor==Array){for(var i=0;i<o.iframeFix.length;i++){var co=$(o.iframeFix[i]).offset({border:false});$("<div class='DragDropIframeFix' style='background: #fff;'></div>").css("width",$(o.iframeFix[i])[0].offsetWidth+"px").css("height",$(o.iframeFix[i])[0].offsetHeight+"px").css("position","absolute").css("opacity","0.001").css("z-index","1000").css("top",co.top+"px").css("left",co.left+"px").appendTo("body");}}else{$("iframe").each(function(){var co=$(this).offset({border:false});$("<div class='DragDropIframeFix' style='background: #fff;'></div>").css("width",this.offsetWidth+"px").css("height",this.offsetHeight+"px").css("position","absolute").css("opacity","0.001").css("z-index","1000").css("top",co.top+"px").css("left",co.left+"px").appendTo("body");});}},stop:function(e,ui){if(ui.options.iframeFix)$("div.DragDropIframeFix").each(function(){this.parentNode.removeChild(this);});}});$.ui.plugin.add("draggable","containment",{start:function(e,ui){var o=ui.options;if((o.containment.left!=undefined||o.containment.constructor==Array)&&!o._containment)return;if(!o._containment)o._containment=o.containment;if(o._containment=='parent')o._containment=this[0].parentNode;if(o._containment=='document'){o.containment=[0,0,$(document).width(),($(document).height()||document.body.parentNode.scrollHeight)];}else{var ce=$(o._containment)[0];var co=$(o._containment).offset();o.containment=[co.left,co.top,co.left+(ce.offsetWidth||ce.scrollWidth),co.top+(ce.offsetHeight||ce.scrollHeight)];}},drag:function(e,ui){var o=ui.options;var h=ui.helper;var c=o.containment;var self=ui.instance;if(c.constructor==Array){if((ui.absolutePosition.left<c[0]))self.position.left=c[0]-(self.offset.left-self.clickOffset.left);if((ui.absolutePosition.top<c[1]))self.position.top=c[1]-(self.offset.top-self.clickOffset.top);if(ui.absolutePosition.left-c[2]+self.helperProportions.width>=0)self.position.left=c[2]-(self.offset.left-self.clickOffset.left)-self.helperProportions.width;if(ui.absolutePosition.top-c[3]+self.helperProportions.height>=0)self.position.top=c[3]-(self.offset.top-self.clickOffset.top)-self.helperProportions.height;}else{if((ui.position.left<c.left))self.position.left=c.left;if((ui.position.top<c.top))self.position.top=c.top;if(ui.position.left-self.offsetParent.innerWidth()+self.helperProportions.width+c.right+(parseInt(self.offsetParent.css("borderLeftWidth"),10)||0)+(parseInt(self.offsetParent.css("borderRightWidth"),10)||0)>=0)self.position.left=self.offsetParent.innerWidth()-self.helperProportions.width-c.right-(parseInt(self.offsetParent.css("borderLeftWidth"),10)||0)-(parseInt(self.offsetParent.css("borderRightWidth"),10)||0);if(ui.position.top-self.offsetParent.innerHeight()+self.helperProportions.height+c.bottom+(parseInt(self.offsetParent.css("borderTopWidth"),10)||0)+(parseInt(self.offsetParent.css("borderBottomWidth"),10)||0)>=0)self.position.top=self.offsetParent.innerHeight()-self.helperProportions.height-c.bottom-(parseInt(self.offsetParent.css("borderTopWidth"),10)||0)-(parseInt(self.offsetParent.css("borderBottomWidth"),10)||0);}}});$.ui.plugin.add("draggable","grid",{drag:function(e,ui){var o=ui.options;ui.instance.position.left=ui.instance.originalPosition.left+Math.round((e.pageX-ui.instance._pageX)/o.grid[0])*o.grid[0];ui.instance.position.top=ui.instance.originalPosition.top+Math.round((e.pageY-ui.instance._pageY)/o.grid[1])*o.grid[1];}});$.ui.plugin.add("draggable","axis",{drag:function(e,ui){var o=ui.options;if(o.constraint)o.axis=o.constraint;o.axis=='x'?ui.instance.position.top=ui.instance.originalPosition.top:ui.instance.position.left=ui.instance.originalPosition.left;}});$.ui.plugin.add("draggable","scroll",function(e,ui){drag:function(e,ui){var o=ui.options;o.scrollSensitivity=o.scrollSensitivity||20;o.scrollSpeed=o.scrollSpeed||20;if(o.pp&&o.ppOverflow){}else{if((ui.draggable.rpos[1]-$(window).height())-$(document).scrollTop()>-o.scrollSensitivity)window.scrollBy(0,o.scrollSpeed);if(ui.draggable.rpos[1]-$(document).scrollTop()<o.scrollSensitivity)window.scrollBy(0,-o.scrollSpeed);if((ui.draggable.rpos[0]-$(window).width())-$(document).scrollLeft()>-o.scrollSensitivity)window.scrollBy(o.scrollSpeed,0);if(ui.draggable.rpos[0]-$(document).scrollLeft()<o.scrollSensitivity)window.scrollBy(-o.scrollSpeed,0);}}});$.ui.plugin.add("draggable","drag","wrapHelper",{drag:function(e,ui){var o=ui.options;if(o.cursorAtIgnore)return;var t=ui.helper;if(!o.pp||!o.ppOverflow){var wx=$(window).width()-($.browser.mozilla?20:0);var sx=$(document).scrollLeft();var wy=$(window).height();var sy=$(document).scrollTop();}else{var wx=o.pp.offsetWidth+o.po.left-20;var sx=o.pp.scrollLeft;var wy=o.pp.offsetHeight+o.po.top-20;var sy=o.pp.scrollTop;}
ui.draggable.pos[0]-=((ui.draggable.rpos[0]-o.cursorAt.left-wx+t.offsetWidth+o.margins.right)-sx>0||(ui.draggable.rpos[0]-o.cursorAt.left+o.margins.left)-sx<0)?(t.offsetWidth+o.margins.left+o.margins.right-o.cursorAt.left*2):0;ui.draggable.pos[1]-=((ui.draggable.rpos[1]-o.cursorAt.top-wy+t.offsetHeight+o.margins.bottom)-sy>0||(ui.draggable.rpos[1]-o.cursorAt.top+o.margins.top)-sy<0)?(t.offsetHeight+o.margins.top+o.margins.bottom-o.cursorAt.top*2):0;}});})(jQuery);
(function($){$.extend($.expr[':'],{droppable:"(' '+a.className+' ').indexOf(' ui-droppable ')"});$.fn.extend({makeDroppable:function(o){return this.each(function(){if(!$.data(this,"ui-droppable"))new $.ui.droppable(this,o);});},removeDroppable:function(){return this.each(function(){if($.data(this,"ui-droppable"))$.data(this,"ui-droppable").destroy();});},changeDroppable:function(key,value){var ret=null;this.each(function(){if($.data(this,"ui-droppable"))ret=$.data(this,"ui-droppable")[key](value);});return ret||this;},enableDroppable:function(){return this.each(function(){if($.data(this,"ui-droppable"))$.data(this,"ui-droppable").enable();});},disableDroppable:function(){return this.each(function(){if($.data(this,"ui-droppable"))$.data(this,"ui-droppable").disable();});}});$.ui.droppable=function(element,options){this.element=$(element);$.data(element,"ui-droppable",this);this.element.addClass("ui-droppable");this.options=$.extend({},options);var o=this.options;var accept=o.accept;$.extend(o,{accept:o.accept&&o.accept.constructor==Function?o.accept:function(d){return $(d).is(accept);},tolerance:o.tolerance||'intersect'});this.proportions={width:this.element.outerWidth(),height:this.element.outerHeight()};$.ui.ddmanager.droppables.push({item:this,over:0,out:1});};$.extend($.ui.droppable.prototype,{plugins:{},ui:function(c){return{draggable:c,instance:this,element:c.element,helper:c.helper,position:c.position,absolutePosition:c.positionAbs,options:this.options};},destroy:function(){$(this.element).removeClass("ui-droppable ui-droppable-disabled");for(var i=0;i<$.ui.ddmanager.droppables.length;i++){if($.ui.ddmanager.droppables[i].item==this)$.ui.ddmanager.droppables.splice(i,1);}},enable:function(){$(this.element).removeClass("ui-droppable-disabled");this.disabled=false;},disable:function(){$(this.element).addClass("ui-droppable-disabled");this.disabled=true;},over:function(e){var draggable=$.ui.ddmanager.current;if(!draggable||draggable.element==this.element)return;if(this.options.accept(draggable.element)){$.ui.plugin.call(this,'over',[e,this.ui(draggable)]);$(this.element).triggerHandler("dropover",[e,this.ui(draggable)],this.options.over);}},out:function(e){var draggable=$.ui.ddmanager.current;if(!draggable||draggable.element==this.element)return;if(this.options.accept(draggable.element)){$.ui.plugin.call(this,'out',[e,this.ui(draggable)]);$(this.element).triggerHandler("dropout",[e,this.ui(draggable)],this.options.out);}},drop:function(e){var draggable=$.ui.ddmanager.current;if(!draggable||draggable.element==this.element)return;if(this.options.accept(draggable.element)){$.ui.plugin.call(this,'drop',[e,this.ui(draggable)]);$(this.element).triggerHandler("drop",[e,this.ui(draggable)],this.options.drop);}},activate:function(e){var draggable=$.ui.ddmanager.current;$.ui.plugin.call(this,'activate',[e,this.ui(draggable)]);if(draggable)$(this.element).triggerHandler("dropactivate",[e,this.ui(draggable)],this.options.activate);},deactivate:function(e){var draggable=$.ui.ddmanager.current;$.ui.plugin.call(this,'deactivate',[e,this.ui(draggable)]);if(draggable)$(this.element).triggerHandler("dropdeactivate",[e,this.ui(draggable)],this.options.deactivate);}});$.ui.intersect=function(draggable,droppable,toleranceMode){if(!droppable.offset)return false;var x1=draggable.positionAbs.left,x2=x1+draggable.helperProportions.width,y1=draggable.positionAbs.top,y2=y1+draggable.helperProportions.height;var l=droppable.offset.left,r=l+droppable.item.proportions.width,t=droppable.offset.top,b=t+droppable.item.proportions.height;switch(toleranceMode){case'fit':return(l<x1&&x2<r&&t<y1&&y2<b);break;case'intersect':return(l<x1+(draggable.helperProportions.width/2)&&x2-(draggable.helperProportions.width/2)<r&&t<y1+(draggable.helperProportions.height/2)&&y2-(draggable.helperProportions.height/2)<b);break;case'pointer':return(l<(draggable.positionAbs.left+draggable.clickOffset.left)&&(draggable.positionAbs.left+draggable.clickOffset.left)<r&&t<(draggable.positionAbs.top+draggable.clickOffset.top)&&(draggable.positionAbs.top+draggable.clickOffset.top)<b);break;case'touch':return((l<x1&&x1<r&&t<y1&&y1<b)||(l<x1&&x1<r&&t<y2&&y2<b)||(l<x2&&x2<r&&t<y1&&y1<b)||(l<x2&&x2<r&&t<y2&&y2<b));break;default:return false;break;}};$.ui.ddmanager={current:null,droppables:[],prepareOffsets:function(t,e){var m=$.ui.ddmanager.droppables;for(var i=0;i<m.length;i++){if(m[i].item.disabled)continue;m[i].offset=$(m[i].item.element).offset();if(t&&m[i].item.options.accept(t.element))
m[i].item.activate.call(m[i].item,e);}},drop:function(draggable,e){$.each($.ui.ddmanager.droppables,function(){if(!this.item.disabled&&$.ui.intersect(draggable,this,this.item.options.tolerance))
this.item.drop.call(this.item,e);if(!this.item.disabled&&this.item.options.accept(draggable.element)){this.out=1;this.over=0;this.item.deactivate.call(this.item,e);}});},drag:function(draggable,e){if(draggable.options.refreshPositions)$.ui.ddmanager.prepareOffsets();$.each($.ui.ddmanager.droppables,function(){if(this.item.disabled)return false;var intersects=$.ui.intersect(draggable,this,this.item.options.tolerance);var c=!intersects&&this.over==1?'out':(intersects&&this.over==0?'over':null);if(!c)return;this[c]=1;this[c=='out'?'over':'out']=0;this.item[c].call(this.item,e);});}};})(jQuery);
(function($){$.ui.plugin.add("droppable","activeClass",{activate:function(e,ui){$(this).addClass(ui.options.activeClass);},deactivate:function(e,ui){$(this).removeClass(ui.options.activeClass);},drop:function(e,ui){$(this).removeClass(ui.options.activeClass);}});$.ui.plugin.add("droppable","hoverClass",{over:function(e,ui){$(this).addClass(ui.options.hoverClass);},out:function(e,ui){$(this).removeClass(ui.options.hoverClass);},drop:function(e,ui){$(this).removeClass(ui.options.hoverClass);}});})(jQuery);
if(window.Node&&Node.prototype&&!Node.prototype.contains){Node.prototype.contains=function(arg){return!!(this.compareDocumentPosition(arg)&16);};}
(function($){$.extend($.expr[':'],{sortable:"(' '+a.className+' ').indexOf(' ui-sortable ')"});$.fn.extend({makeSortable:function(o){return this.each(function(){if(!$.data(this,"ui-sortable"))new $.ui.sortable(this,o);});},removeSortable:function(){return this.each(function(){if($.data(this,"ui-sortable"))$.data(this,"ui-sortable").destroy();});},changeSortable:function(key,value){var ret=null;this.each(function(){if($.data(this,"ui-sortable"))ret=$.data(this,"ui-sortable")[key](value);});return ret||this;},enableSortable:function(){return this.each(function(){if($.data(this,"ui-sortable"))$.data(this,"ui-sortable").enable();});},disableSortable:function(){return this.each(function(){if($.data(this,"ui-sortable"))$.data(this,"ui-sortable").disable();});}});$.ui.sortable=function(element,options){var self=this;this.element=$(element);$.data(element,"ui-sortable",this);this.element.addClass("ui-sortable");this.options=$.extend({},options);var o=this.options;$.extend(o,{items:this.options.items||'> *',zIndex:this.options.zIndex||1000,startCondition:function(){return!self.disabled;}});this.refresh();this.floating=/left|right/.test(this.items[0].item.css('float'));if(!/(relative|absolute|fixed)/.test(this.element.css('position')))this.element.css('position','relative');this.offset=this.element.offset({border:false});this.element.mouseInteraction({executor:this,delay:o.delay,distance:o.distance||0,dragPrevention:o.prevention?o.prevention.toLowerCase().split(','):['input','textarea','button','select','option'],start:this.start,stop:this.stop,drag:this.drag,condition:function(e){if(this.disabled)return false;var currentItem=null,nodes=$(e.target).parents().andSelf().each(function(){if($.data(this,'ui-sortable-item'))currentItem=$(this);});if(currentItem){this.currentItem=currentItem;return true;}else return false;}});};$.extend($.ui.sortable.prototype,{plugins:{},ui:function(){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,instance:this,options:this.options};},propagate:function(n,e){$.ui.plugin.call(this,n,[e,this.ui()]);this.element.triggerHandler(n=="sort"?n:"sort"+n,[e,this.ui()],this.options[n]);},serialize:function(o){var items=$(this.options.items,this.element);var str='';o=o||{};$(this.options.items,this.element).each(function(){var res=(this.getAttribute(o.attribute||'id')||'').match(o.expression||/(.+)[-=_](.+)/);if(res)str+=res[1]+'[]='+res[2];});return str;},intersectsWith:function(item){var x1=this.positionAbs.left,x2=x1+this.helperProportions.width,y1=this.positionAbs.top,y2=y1+this.helperProportions.height;var l=item.left,r=l+item.width,t=item.top,b=t+item.height;return(l<x1+(this.helperProportions.width/2)&&x2-(this.helperProportions.width/2)<r&&t<y1+(this.helperProportions.height/2)&&y2-(this.helperProportions.height/2)<b);},refresh:function(){this.items=[];var items=this.items;var queries=[$(this.options.items,this.element)];if(this.options.connectWith){for(var i=this.options.connectWith.length-1;i>=0;i--){var inst=$.data($(this.options.connectWith[i])[0],'ui-sortable');if(inst&&!inst.disabled)queries.push($(inst.options.items,inst.element));};}
for(var i=queries.length-1;i>=0;i--){queries[i].each(function(){$.data(this,'ui-sortable-item',true);items.push({item:$(this),width:0,height:0,left:0,top:0});});};},refreshPositions:function(){for(var i=this.items.length-1;i>=0;i--){this.items[i].width=this.items[i].item.outerWidth();this.items[i].height=this.items[i].item.outerHeight();var p=this.items[i].item.offset();this.items[i].left=p.left;this.items[i].top=p.top;};},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled");this.element.removeMouseInteraction();for(var i=this.items.length-1;i>=0;i--){$.data(this.items[i].item[0],'ui-sortable-item',null);};$.data(this.element[0],'ui-sortable',null);},enable:function(){this.element.removeClass("ui-sortable-disabled");this.disabled=false;},disable:function(){this.element.addClass("ui-sortable-disabled");this.disabled=true;},start:function(e){var o=this.options;this.refresh();this.refreshPositions();this.helper=typeof o.helper=='function'?$(o.helper.apply(this.element[0],[e,this.currentItem])):this.currentItem.clone();this.helper.appendTo(this.currentItem[0].parentNode).css('position','absolute');this.offsetParent=(function(cp){while(cp){if(cp.style&&(/(absolute|relative|fixed)/).test($.css(cp,'position')))return $(cp);cp=cp.parentNode?cp.parentNode:null;};return $("body");})(this.helper[0].parentNode);this.elementOffset=this.currentItem.offset();this.offsetParentOffset=this.offsetParent.offset();var elementPosition={left:this.elementOffset.left-this.offsetParentOffset.left,top:this.elementOffset.top-this.offsetParentOffset.top};this._pageX=e.pageX;this._pageY=e.pageY;this.clickOffset={left:e.pageX-this.elementOffset.left,top:e.pageY-this.elementOffset.top};var r=this.helper.css('position')=='relative';this.originalPosition={left:(r?parseInt(this.helper.css('left'))||0:elementPosition.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft)),top:(r?parseInt(this.helper.css('top'))||0:elementPosition.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop))};this.offset={left:e.pageX-this.originalPosition.left+(parseInt(this.currentItem.css('marginLeft'))||0),top:e.pageY-this.originalPosition.top+(parseInt(this.currentItem.css('marginTop'))||0)};this.position={top:e.pageY-this.offset.top,left:e.pageX-this.offset.left};this.positionAbs={left:e.pageX-this.clickOffset.left,top:e.pageY-this.clickOffset.top};this.positionDOM=this.currentItem.prev()[0];this.propagate("start",e);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};$(this.currentItem).css('visibility','hidden');return false;},stop:function(e){this.propagate("stop",e);if(this.positionDOM!=this.currentItem.prev()[0])this.propagate("update",e);if(this.cancelHelperRemoval)return false;$(this.currentItem).css('visibility','visible');this.helper.remove();return false;},drag:function(e){this.direction=(this.floating&&this.positionAbs.left>e.pageX-this.clickOffset.left)||(this.positionAbs.top>e.pageY-this.clickOffset.top)?'down':'up';this.position={top:e.pageY-this.offset.top,left:e.pageX-this.offset.left};this.positionAbs={left:e.pageX-this.clickOffset.left,top:e.pageY-this.clickOffset.top};for(var i=this.items.length-1;i>=0;i--){if(this.intersectsWith(this.items[i])&&this.items[i].item[0]!=this.currentItem[0]&&!this.currentItem[0].contains(this.items[i].item[0])){this.items[i].item[this.direction=='down'?'before':'after'](this.currentItem);this.refreshPositions();this.propagate("change",e);break;}}
this.propagate("sort",e);this.helper.css({left:this.position.left+'px',top:this.position.top+'px'});return false;}});})(jQuery);
(function($)
{var methods="destroy,enable,disable,toggle,refresh".split(",");for(var i=0;i<methods.length;i++){var cur=methods[i],f;eval('f = function() {'+'var a = arguments;'+'return this.each(function() {'+'if(jQuery(this).is(".ui-selectable"))'+'jQuery.data(this, "ui-selectable")["'+cur+'"](a);'+'});'+'}');$.fn["selectable"+cur.substr(0,1).toUpperCase()+cur.substr(1)]=f;};$.extend($.expr[':'],{selectable:"(' '+a.className+' ').indexOf(' ui-selectable ')"});$.extend($.expr[':'],{selectee:"(' '+a.className+' ').indexOf(' ui-selectee ')"});$.fn.selectable=function(o){return this.each(function(){if(!$(this).is(".ui-selectable"))new $.ui.selectable(this,o);});}
$.ui.selectable=function(el,o){var options={appendTo:'body',autoRefresh:true,filter:'*',tolerance:'touch'};var o=o||{};$.extend(options,o);this.element=el;var self=this;$.data(this.element,"ui-selectable",this);self.dragged=false;$.extend(options,{helper:function(){return $(document.createElement('div')).css({border:'1px dotted black'});},_start:function(h,p,c,t,e){self.start.apply(t,[self,e]);},_drag:function(h,p,c,t,e){self.dragged=true;self.drag.apply(t,[self,e]);},_stop:function(h,p,c,t,e){self.stop.apply(t,[self,e]);self.dragged=false;}});var selectees;this.refresh=function(){selectees=$(options.filter,self.element);selectees.each(function(){var $this=$(this);var pos=$this.offset();$.data(this,"ui-selectee",{element:this,$element:$this,left:pos.left,top:pos.top,right:pos.left+$this.width(),bottom:pos.top+$this.height(),startselected:false,selected:$this.hasClass('ui-selected'),selecting:$this.hasClass('ui-selecting'),unselecting:$this.hasClass('ui-unselecting')});});}
this.refresh();this.selectees=selectees;this.mouse=new $.ui.mouseInteraction(el,options);$(this.element).addClass("ui-selectable");this.selectees.addClass("ui-selectee");}
$.extend($.ui.selectable.prototype,{toggle:function(){if(this.disabled){this.enable();}else{this.disable();}},destroy:function(){$(this.element).removeClass("ui-selectable").removeClass("ui-selectable-disabled");this.mouse.destroy();},enable:function(){$(this.element).removeClass("ui-selectable-disabled");this.disabled=false;},disable:function(){$(this.element).addClass("ui-selectable-disabled");this.disabled=true;},start:function(self,ev){if(self.disabled)
return;var options=this.options;self.selectees=$(options.filter,self.element);$(self.element).triggerHandler("selectablestart",[ev,{"selectable":self.element,"options":options}],options.start);$(self.mouse.helper).css({"z-index":100,"position":"absolute","left":ev.clientX,"top":ev.clientY,"width":0,"height":0});if(options.autoRefresh){self.refresh();}
self.selectees.filter('.ui-selected').each(function(){var selectee=$.data(this,"ui-selectee");selectee.startselected=true;if(!ev.ctrlKey){selectee.$element.removeClass('ui-selected');selectee.selected=false;selectee.$element.addClass('ui-unselecting');selectee.unselecting=true;$(self.element).triggerHandler("selectableunselecting",[ev,{selectable:self.element,unselecting:selectee.element,options:options}],options.unselecting);}});},drag:function(self,ev){if(self.disabled)
return;var options=this.options;var x1=self.mouse.opos[0],y1=self.mouse.opos[1],x2=ev.pageX,y2=ev.pageY;if(x1>x2){var tmp=x2;x2=x1;x1=tmp;}
if(y1>y2){var tmp=y2;y2=y1;y1=tmp;}
$(self.mouse.helper).css({left:x1,top:y1,width:x2-x1,height:y2-y1});self.selectees.each(function(){var selectee=$.data(this,"ui-selectee");if(selectee.element==self.mouse.helper)
return;var hit=false;if(options.tolerance=='touch'){hit=(!(selectee.left>x2||selectee.right<x1||selectee.top>y2||selectee.bottom<y1));}else if(options.tolerance=='fit'){hit=(selectee.left>x1&&selectee.right<x2&&selectee.top>y1&&selectee.bottom<y2);}
if(hit){if(selectee.selected){selectee.$element.removeClass('ui-selected');selectee.selected=false;}
if(selectee.unselecting){selectee.$element.removeClass('ui-unselecting');selectee.unselecting=false;}
if(!selectee.selecting){selectee.$element.addClass('ui-selecting');selectee.selecting=true;$(self.element).triggerHandler("selectableselecting",[ev,{selectable:self.element,selecting:selectee.element,options:options}],options.selecting);}}else{if(selectee.selecting){if(ev.ctrlKey&&selectee.startselected){selectee.$element.removeClass('ui-selecting');selectee.selecting=false;selectee.$element.addClass('ui-selected');selectee.selected=true;}else{selectee.$element.removeClass('ui-selecting');selectee.selecting=false;if(selectee.startselected){selectee.$element.addClass('ui-unselecting');selectee.unselecting=true;}
$(self.element).triggerHandler("selectableunselecting",[ev,{selectable:self.element,unselecting:selectee.element,options:options}],options.unselecting);}}
if(selectee.selected){if(!ev.ctrlKey&&!selectee.startselected){selectee.$element.removeClass('ui-selected');selectee.selected=false;selectee.$element.addClass('ui-unselecting');selectee.unselecting=true;$(self.element).triggerHandler("selectableunselecting",[ev,{selectable:self.element,unselecting:selectee.element,options:options}],options.unselecting);}}}});},stop:function(self,ev){var options=this.options;$('.ui-unselecting',self.element).each(function(){var selectee=$.data(this,"ui-selectee");selectee.$element.removeClass('ui-unselecting');selectee.unselecting=false;selectee.startselected=false;$(self.element).triggerHandler("selectableunselected",[ev,{selectable:self.element,unselected:selectee.element,options:options}],options.unselected);});$('.ui-selecting',self.element).each(function(){var selectee=$.data(this,"ui-selectee");selectee.$element.removeClass('ui-selecting').addClass('ui-selected');selectee.selecting=false;selectee.selected=true;selectee.startselected=true;$(self.element).triggerHandler("selectableselected",[ev,{selectable:self.element,selected:selectee.element,options:options}],options.selected);});$(self.element).triggerHandler("selectablestop",[ev,{selectable:self.element,options:this.options}],this.options.stop);}});})(jQuery);
(function($){$.extend($.expr[':'],{resizable:"(' '+a.className+' ').indexOf(' ui-resizable ')"});$.fn.resizable=function(o){return this.each(function(){if(!$(this).is(".ui-resizable"))new $.ui.resizable(this,o);});}
$.ui.resizable=function(element,options){var self=this;this.element=$(element);$.data(element,"ui-resizable",this);this.element.addClass("ui-resizable");this.options=$.extend({preventDefault:true,transparent:false,minWidth:10,minHeight:10,aspectRatio:false,disableSelection:true,preserveCursor:true,animate:false,duration:'fast',easing:'swing',autohide:false},options);this.options.proxy=this.options.animate?"proxy":this.options.proxy;var o=this.options;var aBorder='1px solid #DEDEDE';o.defaultTheme={'ui-resizable':{display:'block'},'ui-resizable-handle':{position:'absolute',background:'#F5F5F5'},'ui-resizable-n':{cursor:'n-resize',height:'4px',left:'0px',right:'0px',borderTop:aBorder},'ui-resizable-s':{cursor:'s-resize',height:'4px',left:'0px',right:'0px',borderBottom:aBorder},'ui-resizable-e':{cursor:'e-resize',width:'4px',top:'0px',bottom:'0px',borderRight:aBorder},'ui-resizable-w':{cursor:'w-resize',width:'4px',top:'0px',bottom:'0px',borderLeft:aBorder},'ui-resizable-se':{cursor:'se-resize',width:'4px',height:'4px',borderRight:aBorder,borderBottom:aBorder},'ui-resizable-sw':{cursor:'sw-resize',width:'4px',height:'4px',borderBottom:aBorder,borderLeft:aBorder},'ui-resizable-ne':{cursor:'ne-resize',width:'4px',height:'4px',borderRight:aBorder,borderTop:aBorder},'ui-resizable-nw':{cursor:'nw-resize',width:'4px',height:'4px',borderLeft:aBorder,borderTop:aBorder}};if(!o.proxy&&(this.element.css('position')=='static'||this.element.css('position')==''))
this.element.css('position','relative');var nodeName=element.nodeName;if(nodeName.match(/textarea|input|select|button|img/i)){this.element.wrap('<div class="ui-wrapper"  style="position: relative; width: '+this.element.outerWidth()+'px; height: '+this.element.outerHeight()+';"></div>');var oel=this.element;element=element.parentNode;this.element=$(element);this.element.css({marginLeft:oel.css("marginLeft"),marginTop:oel.css("marginTop"),marginRight:oel.css("marginRight"),marginBottom:oel.css("marginBottom")});oel.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if($.browser.safari&&o.preventDefault)oel.css('resize','none');o.proportionallyResize=o.proportionallyResize||[];o.proportionallyResize.push(oel);}
if(!o.handles)o.handles=!$('.ui-resizable-handle',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(o.handles.constructor==String){if(o.handles=='all')
o.handles='n,e,s,w,se,sw,ne,nw';var n=o.handles.split(",");o.handles={};o.zIndex=o.zIndex||1000;var insertions={n:'top: 0px;',e:'right: 0px;',s:'bottom: 0px;',w:'left: 0px;',se:'bottom: 0px; right: 0px;',sw:'bottom: 0px; left: 0px;',ne:'top: 0px; right: 0px;',nw:'top: 0px; left: 0px;'};for(var i=0;i<n.length;i++){var d=jQuery.trim(n[i]),t=o.defaultTheme,hname='ui-resizable-'+d;var rcss=$.extend(t[hname],t['ui-resizable-handle']),axis=$(["<div class='",hname," ui-resizable-handle' style='",insertions[d],"'></div>"].join("")).css(/sw|se|ne|nw/.test(d)?{zIndex:++o.zIndex}:{});o.handles[d]='.ui-resizable-'+d;this.element.append(axis.css(!$.ui.css(hname)?rcss:{}));}}
this._renderAxis=function(target){target=target||this.element;for(var i in o.handles){if(o.handles[i].constructor==String)
o.handles[i]=$(o.handles[i],element).show();if(o.transparent)
o.handles[i].css({opacity:0})
if(this.element.is('.ui-wrapper')&&nodeName.match(/textarea|input|select|button/i)){var axis=$(o.handles[i],element),padWrapper=0;padWrapper=/sw|ne|nw|se|n|s/.test(i)?axis.outerHeight():axis.outerWidth();var padPos=['padding',/ne|nw|n/.test(i)?'Top':/se|sw|s/.test(i)?'Bottom':/^e$/.test(i)?'Right':'Left'].join("");if(!o.transparent)
target.css(padPos,padWrapper);}
if(!$(o.handles[i]).length)continue;}};this._renderAxis(this.element);var handlers=$('.ui-resizable-handle',self.element);if(o.disableSelection)
handlers.each(function(i,e){$.ui.disableSelection(e);});handlers.mouseover(function(){if(!o.resizing){if(this.className)
var axis=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);o.axis=axis&&axis[1]?axis[1]:'se';}});if(o.autohide){var tLoaded=$.ui.css('ui-resizable-s')||$.ui.css('ui-resizable-e');if(!tLoaded)handlers.hide();$(self.element).addClass("ui-resizable-autohide").hover(function(){if(!tLoaded)handlers.show();$(this).removeClass("ui-resizable-autohide");},function(){if(!o.resizing){if(!tLoaded)handlers.hide();$(this).addClass("ui-resizable-autohide");}});}
this.element.mouseInteraction({executor:this,delay:0,distance:0,dragPrevention:['input','textarea','button','select','option'],start:this.start,stop:this.stop,drag:this.drag,condition:function(e){if(this.disabled)return false;for(var i in this.options.handles){if($(this.options.handles[i])[0]==e.target)return true;}
return false;}});}
$.extend($.ui.resizable.prototype,{plugins:{},ui:function(){return{instance:this,axis:this.options.axis,options:this.options};},_stripUnit:function(s){return parseInt([s].join("").replace(/(in|cm|mm|pt|pc|px|em|ex|%)$/,""))||0;},_proportionallyResize:function(){var o=this.options,self=this;if(o.proportionallyResize&&o.proportionallyResize.length){$.each(o.proportionallyResize,function(x,prel){var b=[prel.css('borderTopWidth'),prel.css('borderRightWidth'),prel.css('borderBottomWidth'),prel.css('borderLeftWidth')];var p=[prel.css('paddingTop'),prel.css('paddingRight'),prel.css('paddingBottom'),prel.css('paddingLeft')];o.borderDif=o.borderDif||$.map(b,function(v,i){var border=self._stripUnit(v),padding=self._stripUnit(p[i]);return border+padding;});prel.css({display:'block',height:(self.element.height()-o.borderDif[0]-o.borderDif[2])+"px",width:(self.element.width()-o.borderDif[1]-o.borderDif[3])+"px"});});}},_renderProxy:function(){var el=this.element,o=this.options;this.offset=el.offset();if(o.proxy){this.helper=this.helper||$('<div></div>');this.helper.addClass(o.proxy).css({width:el.outerWidth(),height:el.outerHeight(),position:'absolute',left:this.offset.left+'px',top:this.offset.top+'px',zIndex:++o.zIndex});this.helper.appendTo("body");if(o.disableSelection)
$.ui.disableSelection(this.helper.get(0));}else{this.helper=el;}},propagate:function(n,e){$.ui.plugin.call(this,n,[e,this.ui()]);this.element.triggerHandler(n=="resize"?n:"resize"+n,[e,this.ui()],this.options[n]);},destroy:function(){this.element.removeClass("ui-resizable ui-resizable-disabled").removeMouseInteraction();},enable:function(){this.element.removeClass("ui-resizable-disabled");this.disabled=false;},disable:function(){this.element.addClass("ui-resizable-disabled");this.disabled=true;},start:function(e){var o=this.options,iniPos=this.element.position(),el=this.element;o.resizing=true;if(el.is('.ui-draggable')||/absolute/.test(el.css('position')))
el.css({position:'absolute',top:iniPos['top'],left:iniPos['left']});if(/relative/.test(el.css('position'))&&$.browser.opera)
el.css({position:'relative',top:'auto',left:'auto'});this._renderProxy();$.extend(o,{currentSize:{width:el.outerWidth(),height:el.outerHeight()},currentSizeDiff:{width:el.outerWidth()-el.width(),height:el.outerHeight()-el.height()},startPosition:{left:e.pageX,top:e.pageY},currentPosition:{left:parseInt(this.helper.css('left'))||0,top:parseInt(this.helper.css('top'))||0}});if(o.preserveCursor)
$('body').css('cursor',o.axis+'-resize');if(o.containment){var oc=o.containment,ce=(oc instanceof jQuery)?oc.get(0):(/parent/.test(oc))?el.parent().get(0):null;if(ce){var scroll=function(e,a){var scroll=/top/.test(a||"top")?'scrollTop':'scrollLeft',has=false;if(e[scroll]>0)return true;e[scroll]=1;has=e[scroll]>0?true:false;return has;};var co=$(ce).offset(),ch=$(ce).innerHeight(),cw=$(ce).innerWidth();o.cdata={e:ce,l:co.left,t:co.top,w:(scroll(ce,"left")?ce.scrollWidth:cw),h:(scroll(ce)?ce.scrollHeight:ch)};}
if(/document/.test(oc)||oc==document)o.cdata={e:document,l:0,t:0,w:$(document).width(),h:$(document).height()};}
this.propagate("start",e);return false;},stop:function(e){this.options.resizing=false;var o=this.options;if(o.proxy){var style={width:(this.helper.width()-o.currentSizeDiff.width)+"px",height:(this.helper.height()-o.currentSizeDiff.height)+"px",top:((parseInt(this.element.css('top'))||0)+((parseInt(this.helper.css('top'))-this.offset.top)||0)),left:((parseInt(this.element.css('left'))||0)+((parseInt(this.helper.css('left'))-this.offset.left)||0))};if(o.animate){$.extend(style,(typeof o.animate=='object')?o.animate:{});this.element.animate(style,{duration:o.duration,easing:o.easing});}else{this.element.css(style);}
if(o.proxy)this._proportionallyResize();this.helper.remove();}
if(o.preserveCursor)
$('body').css('cursor','auto');this.propagate("stop",e);return false;},drag:function(e){var el=this.helper,o=this.options,props={},self=this;if(o.aspectRatio||e.shiftKey)o.ratio=o.ratio||o.currentSize.width/o.currentSize.height;var change=function(a,b){var isTopHeight=(a=="top"||a=="height"),isHeightWidth=(a=="width"||a=="height"),defAxis=(o.axis=="se"||o.axis=="s"||o.axis=="e");var mod=(e[isTopHeight?'pageY':'pageX']-o.startPosition[isTopHeight?'top':'left'])*(b?-1:1);var val=o[isHeightWidth?'currentSize':'currentPosition'][a]-mod-(!o.proxy&&defAxis?o.currentSizeDiff.width:0);el.css(a,val);if(isHeightWidth&&(o.aspectRatio||e.shiftKey))
el.css(!isTopHeight?"height":"width",val*Math.pow(o.ratio,!isTopHeight?-1:1));};if(/(n|ne|nw)/.test(o.axis))change("height");if(/(s|se|sw)/.test(o.axis))change("height",1);var curheight=parseInt(el.css('height'))||0;if(o.minHeight&&curheight<=o.minHeight)el.css('height',o.minHeight);if(o.maxHeight&&curheight>=o.maxHeight)el.css('height',o.maxHeight);if(/n|ne|nw/.test(o.axis))change("top",1);var curtop=parseInt(el.css('top'))||0;if(o.minHeight&&curtop>=(o.currentPosition.top+(o.currentSize.height-o.minHeight)))el.css('top',(o.currentPosition.top+(o.currentSize.height-o.minHeight)));if(o.maxHeight&&curtop<=(o.currentPosition.top+(o.currentSize.height-o.maxHeight)))el.css('top',(o.currentPosition.top+(o.currentSize.height-o.maxHeight)));if(/(e|se|ne)/.test(o.axis))change("width",1);if(/(sw|w|nw)/.test(o.axis))change("width");var curwidth=parseInt(el.css('width'))||0;if(o.minWidth&&curwidth<=o.minWidth)el.css('width',o.minWidth);if(o.maxWidth&&curwidth>=o.maxWidth)el.css('width',o.maxWidth);if(/(sw|w|nw)/.test(o.axis))change("left",1);var curleft=parseInt(el.css('left'))||0;if(o.minWidth&&curleft>=(o.currentPosition.left+(o.currentSize.width-o.minWidth)))el.css('left',(o.currentPosition.left+(o.currentSize.width-o.minWidth)));if(o.maxWidth&&curleft<=(o.currentPosition.left+(o.currentSize.width-o.maxWidth)))el.css('left',(o.currentPosition.left+(o.currentSize.width-o.maxWidth)));if(o.containment&&o.cdata.e){if(curleft<0){el.css('left',0);el.css('width',curwidth+curleft);}
if(curtop<0){el.css('top',0);el.css('height',curheight+curtop);}
if(curwidth+o.currentSizeDiff.width+curleft>=o.cdata.w)el.css('width',o.cdata.w-o.currentSizeDiff.width-(curleft<0?0:curleft));if(curheight+o.currentSizeDiff.height+curtop>=o.cdata.h)el.css('height',o.cdata.h-o.currentSizeDiff.height-(curtop<0?0:curtop));}
if(!o.proxy)this._proportionallyResize();this.propagate("resize",e);return false;}});})(jQuery);;(function($){$.fn.extend({makeAccordion:function(settings){return this.each(function(){$.data(this,"ui-accordion")||$.data(this,"ui-accordion",new $.ui.accordion(this,settings));});},changeAccordion:function(key,value){return this.trigger(key+".ui-accordion",[value]);},enableAccordion:function(){return this.trigger("enable.ui-accordion");},disableAccordion:function(){return this.trigger("disable.ui-accordion");},removeAccordion:function(){return this.trigger("remove.ui-accordion");},accordion:function(){return this.makeAccordion.apply(this,arguments);},activate:function(index){return this.changeAccordion("activate",index);},unaccordion:function(){return this.removeAccordion.apply(this,arguments);}});$.ui=$.ui||{};$.ui.accordion=function(container,settings){this.settings=settings=$.extend({},$.ui.accordion.defaults,settings);if(settings.navigation){var current=$(container).find("a").filter(settings.navigationFilter);if(current.length){if(current.filter(settings.header).length){settings.active=current;}else{settings.active=current.parent().parent().prev();current.addClass("current");}}}
settings.headers=$(container).find(settings.header);settings.active=findActive(settings.headers,settings.active);if(settings.fillSpace){var maxHeight=$(container).parent().height();settings.headers.each(function(){maxHeight-=$(this).outerHeight();});var maxPadding=0;settings.headers.next().each(function(){maxPadding=Math.max(maxPadding,$(this).innerHeight()-$(this).height());}).height(maxHeight-maxPadding);}else if(settings.autoheight){var maxHeight=0;settings.headers.next().each(function(){maxHeight=Math.max(maxHeight,$(this).outerHeight());}).height(maxHeight);}
settings.headers.not(settings.active||"").next().hide();settings.active.parent().andSelf().addClass(settings.selectedClass);$(container).bind((settings.event||"")+".ui-accordion",clickHandler).bind("activate.ui-accordion",activateHandler).bind("enable.ui-accordion",function(){$.data(this,"ui-accordion").settings.disabled=false;}).bind("disable.ui-accordion",function(){$.data(this,"ui-accordion").settings.disabled=true;}).one("remove.ui-accordion",function(){var settings=$.data(this,"ui-accordion").settings;$(this).unbind(settings.event+".ui-accordion").unbind("activate.ui-accordion").unbind("enable.ui-accordion").unbind("disable.ui-accordion");settings.headers.next().css("display","");if(settings.fillSpace||settings.autoheight){settings.headers.next().css("height","");}
$.removeData(this,"ui-accordion");});};function scopeCallback(callback,scope){return function(){return callback.apply(scope,arguments);};}
function completed(cancel){if(!$.data(this,"ui-accordion"))
return;var settings=$.data(this,"ui-accordion").settings;settings.running=cancel?0:--settings.running;if(settings.running)
return;if(settings.clearStyle){settings.toShow.add(settings.toHide).css({height:"",overflow:""});}
$(this).trigger("changed.ui-accordion",settings.data);}
function toggle(toShow,toHide,data,clickedActive,down){var settings=$.data(this,"ui-accordion").settings;settings.toShow=toShow;settings.toHide=toHide;settings.data=data;var complete=scopeCallback(completed,this);settings.running=toHide.size()==0?toShow.size():toHide.size();if(settings.animated){if(!settings.alwaysOpen&&clickedActive){$.ui.accordion.animations[settings.animated]({toShow:jQuery([]),toHide:toHide,complete:complete,down:down,autoheight:settings.autoheight});}else{$.ui.accordion.animations[settings.animated]({toShow:toShow,toHide:toHide,complete:complete,down:down,autoheight:settings.autoheight});}}else{if(!settings.alwaysOpen&&clickedActive){toShow.toggle();}else{toHide.hide();toShow.show();}
complete(true);}}
function clickHandler(event){var settings=$.data(this,"ui-accordion").settings;if(settings.disabled)
return false;if(!event.target&&!settings.alwaysOpen){settings.active.parent().andSelf().toggleClass(settings.selectedClass);var toHide=settings.active.next();var toShow=settings.active=$([]);toggle.call(this,toShow,toHide);return false;}
var clicked=$(event.target);if(clicked.parents(settings.header).length)
while(!clicked.is(settings.header))
clicked=clicked.parent();var clickedActive=clicked[0]==settings.active[0];if(settings.running||(settings.alwaysOpen&&clickedActive))
return false;if(!clicked.is(settings.header))
return;settings.active.parent().andSelf().toggleClass(settings.selectedClass);if(!clickedActive){clicked.parent().andSelf().addClass(settings.selectedClass);}
var toShow=clicked.next(),toHide=settings.active.next(),data=[clicked,settings.active,toShow,toHide],down=settings.headers.index(settings.active[0])>settings.headers.index(clicked[0]);settings.active=clickedActive?$([]):clicked;toggle.call(this,toShow,toHide,data,clickedActive,down);return false;};function activateHandler(event,index){if(arguments.length==1)
return;clickHandler.call(this,{target:findActive($.data(this,"ui-accordion").settings.headers,index)[0]});};function findActive(headers,selector){return selector!=undefined?typeof selector=="number"?headers.filter(":eq("+selector+")"):headers.not(headers.not(selector)):selector===false?$([]):headers.filter(":eq(0)");}
$.extend($.ui.accordion,{defaults:{selectedClass:"selected",alwaysOpen:true,animated:'slide',event:"click",header:"a",autoheight:true,running:0,navigationFilter:function(){return this.href.toLowerCase()==location.href.toLowerCase();}},animations:{slide:function(settings,additions){settings=$.extend({easing:"swing",duration:300},settings,additions);if(!settings.toHide.size()){settings.toShow.animate({height:"show"},settings);return;}
var hideHeight=settings.toHide.height(),showHeight=settings.toShow.height(),difference=showHeight/hideHeight;settings.toShow.css({height:0,overflow:'hidden'}).show();settings.toHide.filter(":hidden").each(settings.complete).end().filter(":visible").animate({height:"hide"},{step:function(now){var current=(hideHeight-now)*difference;if($.browser.msie||$.browser.opera){current=Math.ceil(current);}
settings.toShow.height(current);},duration:settings.duration,easing:settings.easing,complete:function(){if(!settings.autoheight){settings.toShow.css("height","auto");}
settings.complete();}});},bounceslide:function(settings){this.slide(settings,{easing:settings.down?"bounceout":"swing",duration:settings.down?1000:200});},easeslide:function(settings){this.slide(settings,{easing:"easeinout",duration:700})}}});})(jQuery);
// Start
/*
(function($)
{$.ui=$.ui||{};$.fn.dialog=function(o){return this.dialogInit(o).dialogOpen();}
$.fn.dialogInit=function(o){return this.each(function(){if(!$(this).is(".ui-dialog-content")){new $.ui.dialogInit(this,o);}});}
$.fn.dialogOpen=function(){return this.each(function(){var contentEl;if($(this).parents(".ui-dialog").length)contentEl=this;if(!contentEl&&$(this).is(".ui-dialog"))contentEl=$('.ui-dialog-content',this)[0];$.ui.dialogOpen(contentEl)});}
$.fn.dialogClose=function(){return this.each(function(){var contentEl;var closeEl=$(this);if(closeEl.is('.ui-dialog-content')){var contentEl=closeEl;}else if(closeEl.hasClass('ui-dialog')){contentEl=closeEl.find('.ui-dialog-content');}else{contentEl=closeEl.parents('.ui-dialog:first').find('.ui-dialog-content');}
$.ui.dialogClose(contentEl[0]);});}
$.ui.dialogInit=function(el,o){var options={width:300,height:200,minWidth:150,minHeight:100,position:'center',buttons:[],draggable:true,resizable:true};var o=o||{};$.extend(options,o);this.element=el;var self=this;$.data(this.element,"ui-dialog",this);var uiDialogContent=$(el).addClass('ui-dialog-content');if(!uiDialogContent.parent().length){uiDialogContent.appendTo('body');}
uiDialogContent.wrap(document.createElement('div')).wrap(document.createElement('div'));var uiDialogContainer=uiDialogContent.parent().addClass('ui-dialog-container').css({position:'relative'});var uiDialog=uiDialogContainer.parent().hide().addClass('ui-dialog').css({position:'absolute',width:options.width,height:options.height,overflow:'hidden'});var classNames=uiDialogContent.attr('className').split(' ');$.each(classNames,function(i,className){if(className!='ui-dialog-content')
uiDialog.addClass(className);});if(options.resizable){uiDialog.append("<div class='ui-resizable-n ui-resizable-handle'></div>").append("<div class='ui-resizable-s ui-resizable-handle'></div>").append("<div class='ui-resizable-e ui-resizable-handle'></div>").append("<div class='ui-resizable-w ui-resizable-handle'></div>").append("<div class='ui-resizable-ne ui-resizable-handle'></div>").append("<div class='ui-resizable-se ui-resizable-handle'></div>").append("<div class='ui-resizable-sw ui-resizable-handle'></div>").append("<div class='ui-resizable-nw ui-resizable-handle'></div>");uiDialog.resizable({maxWidth:options.maxWidth,maxHeight:options.maxHeight,minWidth:options.minWidth,minHeight:options.minHeight});}
uiDialogContainer.prepend('<div class="ui-dialog-titlebar"></div>');var uiDialogTitlebar=$('.ui-dialog-titlebar',uiDialogContainer);var title=(options.title)?options.title:(uiDialogContent.attr('title'))?uiDialogContent.attr('title'):'';uiDialogTitlebar.append('<span class="ui-dialog-title">'+title+'</span>');uiDialogTitlebar.append('<div class="ui-dialog-titlebar-close"></div>');$('.ui-dialog-titlebar-close',uiDialogTitlebar).hover(function(){$(this).addClass('ui-dialog-titlebar-close-hover');},function(){$(this).removeClass('ui-dialog-titlebar-close-hover');}).mousedown(function(ev){ev.stopPropagation();}).click(function(){self.close();});var l=0;$.each(options.buttons,function(){l=1;return false;});if(l==1){uiDialog.append('<div class="ui-dialog-buttonpane"></div>');var uiDialogButtonPane=$('.ui-dialog-buttonpane',uiDialog);$.each(options.buttons,function(name,value){var btn=$(document.createElement('button')).text(name).click(value);uiDialogButtonPane.append(btn);});}
if(options.draggable){uiDialog.makeDraggable({handle:'.ui-dialog-titlebar'});}
this.open=function(){uiDialog.appendTo('body');var wnd=$(window),doc=$(document),top=doc.scrollTop(),left=doc.scrollLeft();if(options.position.constructor==Array){top+=options.position[1];left+=options.position[0];}else{switch(options.position){case'center':top+=(wnd.height()/2)-(uiDialog.height()/2);left+=(wnd.width()/2)-(uiDialog.width()/2);break;case'top':top+=0;left+=(wnd.width()/2)-(uiDialog.width()/2);break;case'right':top+=(wnd.height()/2)-(uiDialog.height()/2);left+=(wnd.width())-(uiDialog.width());break;case'bottom':top+=(wnd.height())-(uiDialog.height());left+=(wnd.width()/2)-(uiDialog.width()/2);break;case'left':top+=(wnd.height()/2)-(uiDialog.height()/2);left+=0;break;default:top+=(wnd.height()/2)-(uiDialog.height()/2);left+=(wnd.width()/2)-(uiDialog.width()/2);}}
top=top<doc.scrollTop()?doc.scrollTop():top;uiDialog.css({top:top,left:left});uiDialog.show();var openEV=null;var openUI={options:options};$(this.element).triggerHandler("dialogopen",[openEV,openUI],options.open);};this.close=function(){uiDialog.hide();var closeEV=null;var closeUI={options:options};$(this.element).triggerHandler("dialogclose",[closeEV,closeUI],options.close);};}
$.ui.dialogOpen=function(el){$.data(el,"ui-dialog").open();}
$.ui.dialogClose=function(el){$.data(el,"ui-dialog").close();}})(jQuery);
*/
// End

(function($)
{
	//If the UI scope is not available, add it
	$.ui = $.ui || {};

	$.fn.dialog = function(o) {
		return this.dialogInit(o).dialogOpen();
	}
	$.fn.dialogInit = function(o) {
		return this.each(function() {
			if (!$(this).is(".ui-dialog-content")) {
				new $.ui.dialogInit(this, o);
			}			
		});
	}
	$.fn.dialogOpen = function() {
		return this.each(function() {
			var contentEl;
			if ($(this).parents(".ui-dialog").length) contentEl = this;
			if (!contentEl && $(this).is(".ui-dialog")) contentEl = $('.ui-dialog-content', this)[0];
			$.ui.dialogOpen(contentEl)
		});
	}
	$.fn.dialogClose = function() {
		return this.each(function() {
			var contentEl;
			var closeEl = $(this);
			if (closeEl.is('.ui-dialog-content')) {
				var contentEl = closeEl;
			} else if (closeEl.hasClass('ui-dialog')) {
				contentEl = closeEl.find('.ui-dialog-content');
			} else {
				contentEl = closeEl.parents('.ui-dialog:first').find('.ui-dialog-content');
			}
			$.ui.dialogClose(contentEl[0]);
		});
	}

	$.ui.dialogInit = function(el, o) {
		
		var options = {
			width: 300,
			height: 200,
			minWidth: 150,
			minHeight: 100,
			position: 'center',
			buttons: [],
			draggable: true,
			resizable: true
		};
		var o = o || {}; $.extend(options, o); //Extend and copy options
		this.element = el; var self = this; //Do bindings
		$.data(this.element, "ui-dialog", this);

		var uiDialogContent = $(el).addClass('ui-dialog-content');

		if (!uiDialogContent.parent().length) {
			uiDialogContent.appendTo('body');
		}
		uiDialogContent
			.wrap(document.createElement('div'))
			.wrap(document.createElement('div'));
		var uiDialogContainer = uiDialogContent.parent().addClass('ui-dialog-container').css({position: 'relative'});
		var uiDialog = uiDialogContainer.parent().hide()
			.addClass('ui-dialog')
			.css({position: 'absolute', width: options.width, height: options.height, overflow: 'hidden'});

		var classNames = uiDialogContent.attr('className').split(' ');

		// Add content classes to dialog, to inherit theme at top level of element
		$.each(classNames, function(i, className) {
			if (className != 'ui-dialog-content')
				uiDialog.addClass(className);
		});
		
		if (options.resizable) {
			uiDialog.append("<div class='ui-resizable-n ui-resizable-handle'></div>")
				.append("<div class='ui-resizable-s ui-resizable-handle'></div>")
				.append("<div class='ui-resizable-e ui-resizable-handle'></div>")
				.append("<div class='ui-resizable-w ui-resizable-handle'></div>")
				.append("<div class='ui-resizable-ne ui-resizable-handle'></div>")
				.append("<div class='ui-resizable-se ui-resizable-handle'></div>")
				.append("<div class='ui-resizable-sw ui-resizable-handle'></div>")
				.append("<div class='ui-resizable-nw ui-resizable-handle'></div>");
			uiDialog.resizable({ maxWidth: options.maxWidth, maxHeight: options.maxHeight, minWidth: options.minWidth, minHeight: options.minHeight });
		}

		uiDialogContainer.prepend('<div class="ui-dialog-titlebar"></div>');
		var uiDialogTitlebar = $('.ui-dialog-titlebar', uiDialogContainer);
		var title = (options.title) ? options.title : (uiDialogContent.attr('title')) ? uiDialogContent.attr('title') : '';
		uiDialogTitlebar.append('<span class="ui-dialog-title">' + title + '</span>');
		uiDialogTitlebar.append('<div class="ui-dialog-titlebar-close"></div>');
		$('.ui-dialog-titlebar-close', uiDialogTitlebar)
			.hover(function() { $(this).addClass('ui-dialog-titlebar-close-hover'); }, 
			       function() { $(this).removeClass('ui-dialog-titlebar-close-hover'); })
			.mousedown(function(ev) {
				ev.stopPropagation();
			})
			.click(function() {
				self.close();
			});

		var l = 0;
		$.each(options.buttons, function() { l = 1; return false; });
		if (l == 1) {
			uiDialog.append('<div class="ui-dialog-buttonpane"></div>');
			var uiDialogButtonPane = $('.ui-dialog-buttonpane', uiDialog);
			$.each(options.buttons, function(name, value) {
				var btn = $(document.createElement('button')).text(name).click(value);
				uiDialogButtonPane.append(btn);
			});
		}
	
		if (options.draggable) {
			uiDialog.makeDraggable({ handle: '.ui-dialog-titlebar' });
		}
	
		this.open = function() {
			uiDialog.appendTo('body');
			var wnd = $(window), doc = $(document), top = doc.scrollTop, left = doc.scrollLeft;
			if (options.position.constructor == Array) {
				// [x, y]
				top += options.position[1];
				left += options.position[0];
			} else {
				switch (options.position) {
					case 'center':
						top += (wnd.height() / 2) - (uiDialog.height() / 2);
						left += (wnd.width() / 2) - (uiDialog.width() / 2);
						break;
					case 'top':
						top += 0;
						left += (wnd.width() / 2) - (uiDialog.width() / 2);
						break;
					case 'right':
						top += (wnd.height() / 2) - (uiDialog.height() / 2);
						left += (wnd.width()) - (uiDialog.width());
						break;
					case 'bottom':
						top += (wnd.height()) - (uiDialog.height());
						left += (wnd.width() / 2) - (uiDialog.width() / 2);
						break;
					case 'left':
						top += (wnd.height() / 2) - (uiDialog.height() / 2);
						left += 0;
						break;
					default:
						//center
						top += (wnd.height() / 2) - (uiDialog.height() / 2);
						left += (wnd.width() / 2) - (uiDialog.width() / 2);
				}
			}
			top = top < doc.scrollTop ? doc.scrollTop : top;
			uiDialog.css({top: top, left: left});
			uiDialog.show();

			// CALLBACK: open
			var openEV = null;
			var openUI = {
				options: options
			};
			$(this.element).triggerHandler("dialogopen", [openEV, openUI], options.open);
		};

		this.close = function() {
			uiDialog.hide();

			// CALLBACK: close
			var closeEV = null;
			var closeUI = {
				options: options
			};
			$(this.element).triggerHandler("dialogclose", [closeEV, closeUI], options.close);
		};

	}

	$.ui.dialogOpen = function(el) {
		$.data(el, "ui-dialog").open();
	}

	$.ui.dialogClose = function(el) {
		$.data(el, "ui-dialog").close();
	}

})(jQuery);


(function($){$.extend($.expr[':'],{slider:"(' '+a.className+' ').indexOf(' ui-slider ') != -1"});$.fn.extend({becomesSlider:function(o){return this.each(function(){if(!$.data(this,"ui-slider"))new $.ui.slider(this,o);});},removeSlider:function(){return this.each(function(){if($.data(this,"ui-slider"))$.data(this,"ui-slider").destroy();});},changeSlider:function(key,value){var ret=null;this.each(function(){if($.data(this,"ui-slider"))ret=$.data(this,"ui-slider")[key](value);});return ret||this;},enableSlider:function(){return this.each(function(){if($.data(this,"ui-slider"))$.data(this,"ui-slider").enable();});},disableSlider:function(){return this.each(function(){if($.data(this,"ui-slider"))$.data(this,"ui-slider").disable();});}});$.ui.slider=function(element,options){var self=this;this.element=$(element);$.data(element,"ui-slider",this);this.element.addClass("ui-slider");this.options=$.extend({},options);var o=this.options;$.extend(o,{axis:o.axis||(element.offsetWidth<element.offsetHeight?'vertical':'horizontal'),maxValue:parseInt(o.maxValue)||100,minValue:parseInt(o.minValue)||0,startValue:parseInt(o.startValue)||0});o.stepping=parseInt(o.stepping)||(o.steps?o.maxValue/o.steps:0);this.handle=o.handle?$(o.handle,element):$('.ui-slider-handle',element);$(this.handle).mouseInteraction({executor:this,delay:o.delay,distance:o.distance||0,dragPrevention:o.prevention?o.prevention.toLowerCase().split(','):['input','textarea','button','select','option'],start:this.start,stop:this.stop,drag:this.drag,condition:function(e){return!this.disabled;}});if(o.helper=='original'&&(this.element.css('position')=='static'||this.element.css('position')==''))
this.element.css('position','relative');if(o.axis=='horizontal'){this.size=this.element.outerWidth();this.properties=['left','width'];}else{this.size=this.element.outerHeight();this.properties=['top','height'];}
this.element.bind('click',function(e){self.click.apply(self,[e]);});if(!isNaN(o.startValue))this.moveTo(o.startValue,0);};$.extend($.ui.slider.prototype,{plugins:{},ui:function(e){return{instance:this,options:this.options};},propagate:function(n,e){$.ui.plugin.call(this,n,[e,this.ui()]);this.element.triggerHandler(n=="slide"?n:"slide"+n,[e,this.ui()],this.options[n]);},destroy:function(){this.element.removeClass("ui-slider ui-slider-disabled");this.handles.removeMouseInteraction();},enable:function(){this.element.removeClass("ui-slider-disabled");this.disabled=false;},disable:function(){this.element.addClass("ui-slider-disabled");this.disabled=true;},click:function(e){var pointer=[e.pageX,e.pageY];var clickedHandle=false;this.handle.each(function(){if(this==e.target)clickedHandle=true;});if(clickedHandle||this.disabled)return;},start:function(e,handle){var o=this.options;this.$handle=$(handle);this.offset=this.element.offset();this.handleOffset=this.$handle.offset();this.clickOffset={top:e.pageY-this.handleOffset.top,left:e.pageX-this.handleOffset.left};this.handleSize=this.$handle['outer'+this.properties[1].substr(0,1).toUpperCase()+this.properties[1].substr(1)]();return false;},stop:function(e){var o=this.options;return false;},drag:function(e,handle){var o=this.options;var position={top:e.pageY-this.offset.top-this.clickOffset.top,left:e.pageX-this.offset.left-this.clickOffset.left};var modifier=position[this.properties[0]];if(modifier>=this.size-this.handleSize)modifier=this.size-this.handleSize;if(modifier<=0)modifier=0;this.$handle.css(this.properties[0],modifier);return false;},moveTo:function(value,handle){}});})(jQuery);
(function($){$.ui=$.ui||{};$.fn.tabs=function(initial,options){if(initial&&initial.constructor==Object){options=initial;initial=null;}
options=options||{};initial=initial&&initial.constructor==Number&&--initial||0;return this.each(function(){new $.ui.tabs(this,$.extend(options,{initial:initial}));});};$.each(['Add','Remove','Enable','Disable','Click','Load','Href'],function(i,method){$.fn['tabs'+method]=function(){var args=arguments;return this.each(function(){var instance=$.ui.tabs.getInstance(this);instance[method.toLowerCase()].apply(instance,args);});};});$.fn.tabsSelected=function(){var selected=-1;if(this[0]){var instance=$.ui.tabs.getInstance(this[0]),$lis=$('li',this);selected=$lis.index($lis.filter('.'+instance.options.selectedClass)[0]);}
return selected>=0?++selected:-1;};$.ui.tabs=function(el,options){this.source=el;this.options=$.extend({initial:0,event:'click',disabled:[],cookie:null,unselected:false,unselect:options.unselected?true:false,spinner:'Loading&#8230;',cache:false,idPrefix:'ui-tabs-',ajaxOptions:{},fxSpeed:'normal',add:function(){},remove:function(){},enable:function(){},disable:function(){},click:function(){},hide:function(){},show:function(){},load:function(){},tabTemplate:'<li><a href="#{href}"><span>#{text}</span></a></li>',panelTemplate:'<div></div>',navClass:'ui-tabs-nav',selectedClass:'ui-tabs-selected',unselectClass:'ui-tabs-unselect',disabledClass:'ui-tabs-disabled',panelClass:'ui-tabs-panel',hideClass:'ui-tabs-hide',loadingClass:'ui-tabs-loading'},options);this.options.event+='.ui-tabs';this.options.cookie=$.cookie&&$.cookie.constructor==Function&&this.options.cookie;$.data(el,$.ui.tabs.INSTANCE_KEY,this);this.tabify(true);};$.ui.tabs.INSTANCE_KEY='ui_tabs_instance';$.ui.tabs.getInstance=function(el){return $.data(el,$.ui.tabs.INSTANCE_KEY);};$.extend($.ui.tabs.prototype,{tabId:function(a){return a.title&&a.title.replace(/\s/g,'_').replace(/[^A-Za-z0-9\-_:\.]/g,'')||this.options.idPrefix+$.data(a);},tabify:function(init){this.$lis=$('li:has(a[href])',this.source);this.$tabs=this.$lis.map(function(){return $('a',this)[0]});this.$panels=$([]);var self=this,o=this.options;this.$tabs.each(function(i,a){if(a.hash&&a.hash.replace('#','')){self.$panels=self.$panels.add(a.hash);}
else if($(a).attr('href')!='#'){$.data(a,'href',a.href);var id=self.tabId(a);a.href='#'+id;self.$panels=self.$panels.add($('#'+id)[0]||$(o.panelTemplate).attr('id',id).addClass(o.panelClass).insertAfter(self.$panels[i-1]||self.source));}
else{o.disabled.push(i+1);}});if(init){$(this.source).hasClass(o.navClass)||$(this.source).addClass(o.navClass);this.$panels.each(function(){var $this=$(this);$this.hasClass(o.panelClass)||$this.addClass(o.panelClass);});for(var i=0,position;position=o.disabled[i];i++){this.disable(position);}
this.$tabs.each(function(i,a){if(location.hash){if(a.hash==location.hash){o.initial=i;if($.browser.msie||$.browser.opera){var $toShow=$(location.hash),toShowId=$toShow.attr('id');$toShow.attr('id','');setTimeout(function(){$toShow.attr('id',toShowId);},500);}
scrollTo(0,0);return false;}}else if(o.cookie){var p=parseInt($.cookie($.ui.tabs.INSTANCE_KEY+$.data(self.source)));if(p&&self.$tabs[p]){o.initial=p;return false;}}else if(self.$lis.eq(i).hasClass(o.selectedClass)){o.initial=i;return false;}});var n=this.$lis.length;while(this.$lis.eq(o.initial).hasClass(o.disabledClass)&&n){o.initial=++o.initial<this.$lis.length?o.initial:0;n--;}
if(!n){o.unselected=o.unselect=true;}
this.$panels.addClass(o.hideClass);this.$lis.removeClass(o.selectedClass);if(!o.unselected){this.$panels.eq(o.initial).show().removeClass(o.hideClass);this.$lis.eq(o.initial).addClass(o.selectedClass);}
var href=!o.unselected&&$.data(this.$tabs[o.initial],'href');if(href){this.load(o.initial+1,href);}
if(!/^click/.test(o.event)){this.$tabs.bind('click',function(e){e.preventDefault();});}}
var showAnim={},showSpeed=o.fxShowSpeed||o.fxSpeed,hideAnim={},hideSpeed=o.fxHideSpeed||o.fxSpeed;if(o.fxSlide||o.fxFade){if(o.fxSlide){showAnim['height']='show';hideAnim['height']='hide';}
if(o.fxFade){showAnim['opacity']='show';hideAnim['opacity']='hide';}}else{if(o.fxShow){showAnim=o.fxShow;}else{showAnim['min-width']=0;showSpeed=1;}
if(o.fxHide){hideAnim=o.fxHide;}else{hideAnim['min-width']=0;hideSpeed=1;}}
var resetCSS={display:'',overflow:'',height:''};if(!$.browser.msie){resetCSS['opacity']='';}
function hideTab(clicked,$hide,$show){$hide.animate(hideAnim,hideSpeed,function(){$hide.addClass(o.hideClass).css(resetCSS);if($.browser.msie&&hideAnim['opacity']){$hide[0].style.filter='';}
o.hide(clicked,$hide[0],$show&&$show[0]||null);if($show){showTab(clicked,$show,$hide);}});}
function showTab(clicked,$show,$hide){if(!(o.fxSlide||o.fxFade||o.fxShow)){$show.css('display','block');}
$show.animate(showAnim,showSpeed,function(){$show.removeClass(o.hideClass).css(resetCSS);if($.browser.msie&&showAnim['opacity']){$show[0].style.filter='';}
o.show(clicked,$show[0],$hide&&$hide[0]||null);});}
function switchTab(clicked,$li,$hide,$show){$li.addClass(o.selectedClass).siblings().removeClass(o.selectedClass);hideTab(clicked,$hide,$show);}
this.$tabs.unbind(o.event).bind(o.event,function(){var $li=$(this).parents('li:eq(0)'),$hide=self.$panels.filter(':visible'),$show=$(this.hash);if(($li.hasClass(o.selectedClass)&&!o.unselect)||$li.hasClass(o.disabledClass)||o.click(this,$show[0],$hide[0])===false){this.blur();return false;}
if(o.cookie){$.cookie($.ui.tabs.INSTANCE_KEY+$.data(self.source),self.$tabs.index(this),o.cookie);}
if(o.unselect){if($li.hasClass(o.selectedClass)){$li.removeClass(o.selectedClass);self.$panels.stop();hideTab(this,$hide);this.blur();return false;}else if(!$hide.length){self.$panels.stop();if($.data(this,'href')){var a=this;self.load(self.$tabs.index(this)+1,$.data(this,'href'),function(){$li.addClass(o.selectedClass).addClass(o.unselectClass);showTab(a,$show);});}else{$li.addClass(o.selectedClass).addClass(o.unselectClass);showTab(this,$show);}
this.blur();return false;}}
self.$panels.stop();if($show.length){if($.data(this,'href')){var a=this;self.load(self.$tabs.index(this)+1,$.data(this,'href'),function(){switchTab(a,$li,$hide,$show);});}else{switchTab(this,$li,$hide,$show);}}else{throw'jQuery UI Tabs: Mismatching fragment identifier.';}
if($.browser.msie){this.blur();}
return false;});},add:function(url,text,position){if(url&&text){position=position||this.$tabs.length;var o=this.options,$li=$(o.tabTemplate.replace(/#\{href\}/,url).replace(/#\{text\}/,text));var id=url.indexOf('#')==0?url.replace('#',''):this.tabId($('a:first-child',$li)[0]);var $panel=$('#'+id);$panel=$panel.length&&$panel||$(o.panelTemplate).attr('id',id).addClass(o.panelClass).addClass(o.hideClass);if(position>=this.$lis.length){$li.appendTo(this.source);$panel.appendTo(this.source.parentNode);}else{$li.insertBefore(this.$lis[position-1]);$panel.insertBefore(this.$panels[position-1]);}
this.tabify();if(this.$tabs.length==1){$li.addClass(o.selectedClass);$panel.removeClass(o.hideClass);var href=$.data(this.$tabs[0],'href');if(href){this.load(position+1,href);}}
o.add(this.$tabs[position],this.$panels[position]);}else{throw'jQuery UI Tabs: Not enough arguments to add tab.';}},remove:function(position){if(position&&position.constructor==Number){var o=this.options,$li=this.$lis.eq(position-1).remove(),$panel=this.$panels.eq(position-1).remove();if($li.hasClass(o.selectedClass)&&this.$tabs.length>1){this.click(position+(position<this.$tabs.length?1:-1));}
this.tabify();o.remove($li.end()[0],$panel[0]);}},enable:function(position){var o=this.options,$li=this.$lis.eq(position-1);$li.removeClass(o.disabledClass);if($.browser.safari){$li.css('display','inline-block');setTimeout(function(){$li.css('display','block')},0)}
o.enable(this.$tabs[position-1],this.$panels[position-1]);},disable:function(position){var o=this.options;this.$lis.eq(position-1).addClass(o.disabledClass);o.disable(this.$tabs[position-1],this.$panels[position-1]);},click:function(position){this.$tabs.eq(position-1).trigger(this.options.event);},load:function(position,url,callback){var self=this,o=this.options,$a=this.$tabs.eq(position-1),a=$a[0],$span=$('span',a);if(url&&url.constructor==Function){callback=url;url=null;}
if(url){$.data(a,'href',url);}else{url=$.data(a,'href');}
if(o.spinner){$.data(a,'title',$span.html());$span.html('<em>'+o.spinner+'</em>');}
var finish=function(){self.$tabs.filter('.'+o.loadingClass).each(function(){$(this).removeClass(o.loadingClass);if(o.spinner){$('span',this).html($.data(this,'title'));}});self.xhr=null;};var ajaxOptions=$.extend({},o.ajaxOptions,{url:url,success:function(r,s){$(a.hash).html(r);finish();if(callback&&callback.constructor==Function){callback();}
if(o.cache){$.removeData(a,'href');}
o.load(self.$tabs[position-1],self.$panels[position-1]);o.ajaxOptions.success&&o.ajaxOptions.success(r,s);}});if(this.xhr){this.xhr.abort();finish();}
$a.addClass(o.loadingClass);setTimeout(function(){self.xhr=$.ajax(ajaxOptions);},0);},href:function(position,href){$.data(this.$tabs.eq(position-1)[0],'href',href);}});})(jQuery);