/*
 * jQuery UI Dialog 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Dialog
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *  jquery.ui.button.js
 *	jquery.ui.draggable.js
 *	jquery.ui.mouse.js
 *	jquery.ui.position.js
 *	jquery.ui.resizable.js
 */

(function(c,i){var j={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},k={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0},l=c.attrFn||{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0,click:!0};c.widget("ui.dialog",{options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",collision:"fit",using:function(a){var b=
c(this).css(a).offset().top;b<0&&c(this).css("top",a.top-b)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var a=this,b=a.options,d=b.title||"&#160;",e=c.ui.dialog.getTitleId(a.element),f=(a.uiDialog=c("<div></div>")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+
b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(d){b.closeOnEscape&&!d.isDefaultPrevented()&&d.keyCode&&d.keyCode===c.ui.keyCode.ESCAPE&&(a.close(d),d.preventDefault())}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(b){a.moveToTop(!1,b)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(f);var h=(a.uiDialogTitlebar=c("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(f),
g=c('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){g.addClass("ui-state-hover")},function(){g.removeClass("ui-state-hover")}).focus(function(){g.addClass("ui-state-focus")}).blur(function(){g.removeClass("ui-state-focus")}).click(function(b){a.close(b);return!1}).appendTo(h);(a.uiDialogTitlebarCloseText=c("<span></span>")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(g);c("<span></span>").addClass("ui-dialog-title").attr("id",
e).html(d).prependTo(h);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose=b.beforeclose;h.find("*").add(h).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=!1;c.fn.bgiframe&&f.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){this.overlay&&this.overlay.destroy();this.uiDialog.hide();this.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");
this.uiDialog.remove();this.originalTitle&&this.element.attr("title",this.originalTitle);return this},widget:function(){return this.uiDialog},close:function(a){var b=this,d,e;if(!1!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=!1;b.options.hide?b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)}):(b.uiDialog.hide(),b._trigger("close",a));c.ui.dialog.overlay.resize();if(b.options.modal)d=0,c(".ui-dialog").each(function(){this!==
b.uiDialog[0]&&(e=c(this).css("z-index"),isNaN(e)||(d=Math.max(d,e)))}),c.ui.dialog.maxZ=d;return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this.options;if(d.modal&&!a||!d.stack&&!d.modal)return this._trigger("focus",b);if(d.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=d.zIndex;if(this.overlay)c.ui.dialog.maxZ+=1,this.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ);d={scrollTop:this.element.scrollTop(),scrollLeft:this.element.scrollLeft()};c.ui.dialog.maxZ+=
1;this.uiDialog.css("z-index",c.ui.dialog.maxZ);this.element.attr(d);this._trigger("focus",b);return this},open:function(){if(!this._isOpen){var a=this.options,b=this.uiDialog;this.overlay=a.modal?new c.ui.dialog.overlay(this):null;this._size();this._position(a.position);b.show(a.show);this.moveToTop(!0);a.modal&&b.bind("keypress.ui-dialog",function(a){if(a.keyCode===c.ui.keyCode.TAB){var b=c(":tabbable",this),f=b.filter(":first"),b=b.filter(":last");if(a.target===b[0]&&!a.shiftKey)return f.focus(1),
!1;else if(a.target===f[0]&&a.shiftKey)return b.focus(1),!1}});c(this.element.find(":tabbable").get().concat(b.find(".ui-dialog-buttonpane :tabbable").get().concat(b.get()))).eq(0).focus();this._isOpen=!0;this._trigger("open");return this}},_createButtons:function(a){var b=this,d=!1,e=c("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),f=c("<div></div>").addClass("ui-dialog-buttonset").appendTo(e);b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&
a!==null&&c.each(a,function(){return!(d=!0)});d&&(c.each(a,function(a,d){var d=c.isFunction(d)?{click:d,text:a}:d,e=c('<button type="button"></button>').click(function(){d.click.apply(b.element[0],arguments)}).appendTo(f);c.each(d,function(a,b){if(a!=="click")if(a in l)e[a](b);else e.attr(a,b)});c.fn.button&&e.button()}),e.appendTo(b.uiDialog))},_makeDraggable:function(){function a(a){return{position:a.position,offset:a.offset}}var b=this,d=b.options,e=c(document),f;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",
handle:".ui-dialog-titlebar",containment:"document",start:function(e,g){f=d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging");b._trigger("dragStart",e,a(g))},drag:function(c,d){b._trigger("drag",c,a(d))},stop:function(h,g){d.position=[g.position.left-e.scrollLeft(),g.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(f);b._trigger("dragStop",h,a(g));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(a){return{originalPosition:a.originalPosition,
originalSize:a.originalSize,position:a.position,size:a.size}}var a=a===i?this.options.resizable:a,d=this,e=d.options,f=d.uiDialog.css("position"),a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(a,e){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",a,b(e))},resize:function(a,c){d._trigger("resize",
a,b(c))},stop:function(a,f){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop",a,b(f));c.ui.dialog.overlay.resize()}}).css("position",f).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0],e;if(a){if(typeof a==="string"||typeof a==="object"&&"0"in a)b=a.split?a.split(" "):
[a[0],a[1]],b.length===1&&(b[1]=b[0]),c.each(["left","top"],function(a,c){+b[a]===b[a]&&(d[a]=b[a],b[a]=c)}),a={my:b.join(" "),at:b.join(" "),offset:d.join(" ")};a=c.extend({},c.ui.dialog.prototype.options.position,a)}else a=c.ui.dialog.prototype.options.position;(e=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(c.extend({of:window},a));e||this.uiDialog.hide()},_setOptions:function(a){var b=this,d={},e=!1;c.each(a,function(a,c){b._setOption(a,c);a in
j&&(e=!0);a in k&&(d[a]=c)});e&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(a,b){var d=this.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":this._createButtons(b);break;case "closeText":this.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":d.removeClass(this.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?d.addClass("ui-dialog-disabled"):
d.removeClass("ui-dialog-disabled");break;case "draggable":var e=d.is(":data(draggable)");e&&!b&&d.draggable("destroy");!e&&b&&this._makeDraggable();break;case "position":this._position(b);break;case "resizable":(e=d.is(":data(resizable)"))&&!b&&d.resizable("destroy");e&&typeof b==="string"&&d.resizable("option","handles",b);!e&&b!==!1&&this._makeResizable(b);break;case "title":c(".ui-dialog-title",this.uiDialogTitlebar).html(""+(b||"&#160;"))}c.Widget.prototype._setOption.apply(this,arguments)},
_size:function(){var a=this.options,b,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(a.minWidth>a.width)a.width=a.minWidth;b=this.uiDialog.css({height:"auto",width:a.width}).height();d=Math.max(0,a.minHeight-b);a.height==="auto"?c.support.minHeight?this.element.css({minHeight:d,height:"auto"}):(this.uiDialog.show(),a=this.element.css("height","auto").height(),e||this.uiDialog.hide(),this.element.height(Math.max(a,d))):this.element.height(Math.max(a.height-
b,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.16",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a)this.uuid+=1,a=this.uuid;return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),
create:function(a){this.instances.length===0&&(setTimeout(function(){c.ui.dialog.overlay.instances.length&&c(document).bind(c.ui.dialog.overlay.events,function(a){if(c(a.target).zIndex()<c.ui.dialog.overlay.maxZ)return!1})},1),c(document).bind("keydown.dialog-overlay",function(b){a.options.closeOnEscape&&!b.isDefaultPrevented()&&b.keyCode&&b.keyCode===c.ui.keyCode.ESCAPE&&(a.close(b),b.preventDefault())}),c(window).bind("resize.dialog-overlay",c.ui.dialog.overlay.resize));var b=(this.oldInstances.pop()||
c("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});c.fn.bgiframe&&b.bgiframe();this.instances.push(b);return b},destroy:function(a){var b=c.inArray(a,this.instances);b!=-1&&this.oldInstances.push(this.instances.splice(b,1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var d=0;c.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){var a,b;return c.browser.msie&&
c.browser.version<7?(a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),b=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),a<b?c(window).height()+"px":a+"px"):c(document).height()+"px"},width:function(){var a,b;return c.browser.msie?(a=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),b=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),a<b?c(window).width()+"px":a+"px"):c(document).width()+"px"},resize:function(){var a=
c([]);c.each(c.ui.dialog.overlay.instances,function(){a=a.add(this)});a.css({width:0,height:0}).css({width:c.ui.dialog.overlay.width(),height:c.ui.dialog.overlay.height()})}});c.extend(c.ui.dialog.overlay.prototype,{destroy:function(){c.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);
