//eval(function(p, a, c, k, e, r) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('(8($){g 1L={1M:"1p.D",14:"14.D",1N:"1q.D",1c:"1c.k",J:"J.k",1d:"1d.k",1e:"1e.k",1O:"1p.k",A:"14.k",1P:"1q.k"},1Q=\'4-6 \'+\'4-E \'+\'4-E-F \'+\'4-1r-1s \';$.E("4.6",{3c:8(){3.1t=3.h.B(\'y\');g d=3,5=3.5,y=5.y||3.1t||\'&2y;\',1R=$.4.6.2z(3.h),9=(3.9=$(\'<W/>\')).G(l.K).L().m(1Q+5.1u).u({1v:\'3d\',3e:\'3f\',15:5.15}).B(\'3g\',-1).u(\'3h\',0).1S(8(b){(5.1T&&b.M&&b.M==$.4.M.2A&&d.N(b))}).B({2B:\'6\',\'3i-3j\':1R}).1U(8(b){d.1V(C,b)}),3k=3.h.1w().3l(\'y\').m(\'4-6-F \'+\'4-E-F\').G(9),X=(3.X=$(\'<W></W>\')).m(\'4-6-1W \'+\'4-E-3m \'+\'4-1r-1s \'+\'4-2C-2D\').2E(9),16=$(\'<a 3n="#"/>\').m(\'4-6-1W-N \'+\'4-1r-1s\').B(\'2B\',\'1x\').17(8(){16.m(\'4-H-17\')},8(){16.O(\'4-H-17\')}).v(8(){16.m(\'4-H-v\')}).2F(8(){16.O(\'4-H-v\')}).1U(8(2G){2G.3o()}).1X(8(b){d.N(b);o C}).G(X),1Y=(3.1Y=$(\'<2H/>\')).m(\'4-1y \'+\'4-1y-3p\').1Z(5.20).G(16),3q=$(\'<2H/>\').m(\'4-6-y\').B(\'2I\',1R).2J(y).2E(X);X.1f("*").1g(X).3r();(5.D&&$.18.D&&3.21());(5.k&&$.18.k&&3.22());3.23(5.P);3.1h=C;(5.Y&&$.18.Y&&9.Y());(5.2K&&3.24())},Q:8(){(3.c&&3.c.Q());3.9.L();3.h.25(\'.6\').3s(\'6\').O(\'4-6-F 4-E-F\').L().G(\'K\');3.9.26();(3.1t&&3.h.B(\'y\',3.1t))},N:8(b){g d=3;i(C===d.19(\'3t\',b)){o}(d.c&&d.c.Q());d.9.25(\'27.4-6\');(d.5.L?d.9.L(d.5.L,8(){d.19(\'N\',b)}):d.9.L()&&d.19(\'N\',b));$.4.6.c.A();d.1h=C},2L:8(){o 3.1h},1V:8(2M,b){i((3.5.1i&&!2M)||(!3.5.2N&&!3.5.1i)){o 3.19(\'v\',b)}i(3.5.15>$.4.6.R){$.4.6.R=3.5.15}(3.c&&3.c.$x.u(\'z-2O\',$.4.6.c.R=++$.4.6.R));g 2P={28:3.h.B(\'28\'),29:3.h.B(\'29\')};3.9.u(\'z-2O\',++$.4.6.R);3.h.B(2P);3.19(\'v\',b)},24:8(){i(3.1h){o}g 5=3.5,9=3.9;3.c=5.1i?3u $.4.6.c(3):1z;(9.3v().2a&&9.G(\'K\'));3.2Q();3.2b(5.1v);9.1w(5.1w);3.1V(S);(5.1i&&9.1A(\'27.4-6\',8(b){i(b.M!=$.4.M.3w){o}g 2c=$(\':2d\',3),Z=2c.2e(\':Z\')[0],1B=2c.2e(\':1B\')[0];i(b.2f==1B&&!b.2R){2g(8(){Z.v()},1)}10 i(b.2f==Z&&b.2R){2g(8(){1B.v()},1)}}));$([]).1g(9.1f(\'.4-6-F :2d:Z\')).1g(9.1f(\'.4-6-2h :2d:Z\')).1g(9).2e(\':Z\').v();3.19(\'24\');3.1h=S},23:8(P){g d=3,2i=C,2j=$(\'<W></W>\').m(\'4-6-2h \'+\'4-E-F \'+\'4-2C-2D\');3.9.1f(\'.4-6-2h\').26();(2k P==\'3x\'&&P!==1z&&$.2l(P,8(){o!(2i=S)}));i(2i){$.2l(P,8(2S,18){$(\'<1x 3y="1x"></1x>\').m(\'4-H-2m \'+\'4-1r-1s\').1Z(2S).1X(8(){18.T(d.h[0],U)}).17(8(){$(3).m(\'4-H-17\')},8(){$(3).O(\'4-H-17\')}).v(8(){$(3).m(\'4-H-v\')}).2F(8(){$(3).O(\'4-H-v\')}).G(2j)});2j.G(3.9)}},21:8(){g d=3,5=3.5,2n;3.9.D({2T:\'.4-6-F\',3z:\'.4-6-1W\',3A:\'l\',1p:8(){2n=5.f;$(3).f($(3).f()).m("4-6-2U");(5.1M&&5.1M.T(d.h[0],U))},14:8(){(5.14&&5.14.T(d.h[0],U))},1q:8(){$(3).O("4-6-2U").f(2n);(5.1N&&5.1N.T(d.h[0],U));$.4.6.c.A()}})},22:8(V){V=(V===3B?3.5.k:V);g d=3,5=3.5,2V=2k V==\'2W\'?V:\'n,e,s,w,2o,3C,3D,3E\';3.9.k({2T:\'.4-6-F\',3F:3.h,1d:5.1d,1c:5.1c,1e:5.1e,J:5.J,1p:8(){$(3).m("4-6-2X");(5.1O&&5.1O.T(d.h[0],U))},A:8(){(5.A&&5.A.T(d.h[0],U))},V:2V,1q:8(){$(3).O("4-6-2X");5.f=$(3).f();5.j=$(3).j();(5.1P&&5.1P.T(d.h[0],U));$.4.6.c.A()}}).1f(\'.4-k-2o\').m(\'4-1y 4-1y-3G-3H-2o\')},2b:8(p){g 1j=$(1k),2p=$(l),I=2p.28(),1a=2p.29(),2Y=I;i($.2Z(p,[\'1l\',\'1C\',\'2q\',\'2r\',\'1D\'])>=0){p=[p==\'2q\'||p==\'1D\'?p:\'1l\',p==\'1C\'||p==\'2r\'?p:\'2s\']}i(p.2t!=3I){p=[\'1l\',\'2s\']}i(p[0].2t==30){1a+=p[0]}10{2u(p[0]){q\'1D\':1a+=0;t;q\'2q\':1a+=1j.j()-3.9.31();t;2m:q\'1l\':1a+=(1j.j()-3.9.31())/2}}i(p[1].2t==30){I+=p[1]}10{2u(p[1]){q\'1C\':I+=0;t;q\'2r\':I+=1j.f()-3.9.32();t;2m:q\'2s\':I+=(1j.f()-3.9.32())/2}}I=11.12(I,2Y);3.9.u({1C:I,1D:1a})},33:8(1E,r){(1L[1E]&&3.9.34(1L[1E],r));2u(1E){q"P":3.23(r);t;q"20":3.1Y.1Z(r);t;q"1u":3.9.O(3.5.1u).m(1Q+r);t;q"D":(r?3.21():3.9.D(\'Q\'));t;q"f":3.9.f(r);t;q"1v":3.2b(r);t;q"k":g 9=3.9,1F=3.9.3J(\':34(k)\');(1F&&!r&&9.k(\'Q\'));(1F&&2k r==\'2W\'&&9.k(\'3K\',\'V\',r));(1F||3.22(r));t;q"y":$(".4-6-y",3.X).2J(r||\'&2y;\');t;q"j":3.9.j(r);t}$.E.35.33.T(3,U)},2Q:8(){g 5=3.5;3.h.u({f:0,J:0,j:\'1m\'});g 2v=3.9.u({f:\'1m\',j:5.j}).f();3.h.u({J:11.12(5.J-2v,0),f:5.f==\'1m\'?\'1m\':11.12(5.f-2v,0)})}});$.2w($.4.6,{2x:"1.7.1",3L:{2K:S,Y:C,P:{},1T:S,20:\'N\',1u:\'\',D:S,L:1z,f:\'1m\',1c:C,1d:C,J:36,1e:36,1i:C,1v:\'1l\',k:S,1w:1z,2N:S,y:\'\',j:3M,15:3N},3O:\'2L\',37:0,R:0,2z:8($x){o\'4-6-y-\'+($x.B(\'2I\')||++3.37)},c:8(6){3.$x=$.4.6.c.38(6)}});$.2w($.4.6.c,{13:[],R:0,39:$.3P(\'v,1U,3Q,1S,27,1X\'.3R(\',\'),8(b){o b+\'.6-c\'}).3S(\' \'),38:8(6){i(3.13.2a===0){2g(8(){$(l).1A($.4.6.c.39,8(b){g 3a=$(b.2f).3T(\'.4-6\').u(\'15\')||0;o(3a>$.4.6.c.R)})},1);$(l).1A(\'1S.6-c\',8(b){(6.5.1T&&b.M&&b.M==$.4.M.2A&&6.N(b))});$(1k).1A(\'A.6-c\',$.4.6.c.A)}g $x=$(\'<W></W>\').G(l.K).m(\'4-E-c\').u({j:3.j(),f:3.f()});(6.5.Y&&$.18.Y&&$x.Y());3.13.3U($x);o $x},Q:8($x){3.13.3V($.2Z(3.13,$x),1);i(3.13.2a===0){$([l,1k]).25(\'.6-c\')}$x.26()},f:8(){i($.1G.3b&&$.1G.2x<7){g 1n=11.12(l.1H.1n,l.K.1n);g 1I=11.12(l.1H.1I,l.K.1I);i(1n<1I){o $(1k).f()+\'1b\'}10{o 1n+\'1b\'}}10{o $(l).f()+\'1b\'}},j:8(){i($.1G.3b&&$.1G.2x<7){g 1o=11.12(l.1H.1o,l.K.1o);g 1J=11.12(l.1H.1J,l.K.1J);i(1o<1J){o $(1k).j()+\'1b\'}10{o 1o+\'1b\'}}10{o $(l).j()+\'1b\'}},A:8(){g $1K=$([]);$.2l($.4.6.c.13,8(){$1K=$1K.1g(3)});$1K.u({j:0,f:0}).u({j:$.4.6.c.j(),f:$.4.6.c.f()})}});$.2w($.4.6.c.35,{Q:8(){$.4.6.c.Q(3.$x)}})})(3W);', 62, 245, '|||this|ui|options|dialog||function|uiDialog||event|overlay|self||height|var|element|if|width|resizable|document|addClass||return|pos|case|value||break|css|focus||el|title||resize|attr|false|draggable|widget|content|appendTo|state|pTop|minHeight|body|hide|keyCode|close|removeClass|buttons|destroy|maxZ|true|apply|arguments|handles|div|uiDialogTitlebar|bgiframe|first|else|Math|max|instances|drag|zIndex|uiDialogTitlebarClose|hover|fn|_trigger|pLeft|px|maxHeight|maxWidth|minWidth|find|add|_isOpen|modal|wnd|window|center|auto|scrollHeight|scrollWidth|start|stop|corner|all|originalTitle|dialogClass|position|show|button|icon|null|bind|last|top|left|key|isResizable|browser|documentElement|offsetHeight|offsetWidth|overlays|setDataSwitch|dragStart|dragStop|resizeStart|resizeStop|uiDialogClasses|titleId|keydown|closeOnEscape|mousedown|moveToTop|titlebar|click|uiDialogTitlebarCloseText|text|closeText|_makeDraggable|_makeResizable|_createButtons|open|unbind|remove|keypress|scrollTop|scrollLeft|length|_position|tabbables|tabbable|filter|target|setTimeout|buttonpane|hasButtons|uiDialogButtonPane|typeof|each|default|heightBeforeDrag|se|doc|right|bottom|middle|constructor|switch|nonContentHeight|extend|version|nbsp|getTitleId|ESCAPE|role|helper|clearfix|prependTo|blur|ev|span|id|html|autoOpen|isOpen|force|stack|index|saveScroll|_size|shiftKey|name|cancel|dragging|resizeHandles|string|resizing|minTop|inArray|Number|outerWidth|outerHeight|_setData|data|prototype|150|uuid|create|events|dialogZ|msie|_init|absolute|overflow|hidden|tabIndex|outline|aria|labelledby|uiDialogContent|removeAttr|header|href|stopPropagation|closethick|uiDialogTitle|disableSelection|removeData|beforeclose|new|next|TAB|object|type|handle|containment|undefined|sw|ne|nw|alsoResize|grip|diagonal|Array|is|option|defaults|300|1000|getter|map|mouseup|split|join|parents|push|splice|jQuery'.split('|'), 0, {}))

/*
 * jQuery UI Dialog 1.7.1
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Dialog
 *
 * Depends:
 *	ui.core.js
 *	ui.draggable.js
 *	ui.resizable.js
 */
(function($) {

var setDataSwitch = {
		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"
	},
	
	uiDialogClasses =
		'ui-dialog ' +
		'ui-widget ' +
		'ui-widget-content ' +
		'ui-corner-all ';

$.widget("ui.dialog", {

	_init: function() {
		this.originalTitle = this.element.attr('title');

		var self = this,
			options = this.options,

			title = options.title || this.originalTitle || '&nbsp;',
			titleId = $.ui.dialog.getTitleId(this.element),

			uiDialog = (this.uiDialog = $('<div/>'))
				.appendTo(document.body)
				.hide()
				.addClass(uiDialogClasses + options.dialogClass)
				.css({
					position: 'absolute',
					overflow: 'hidden',
					zIndex: options.zIndex
				})
				// setting tabIndex makes the div focusable
				// setting outline to 0 prevents a border on focus in Mozilla
				.attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
					(options.closeOnEscape && event.keyCode
						&& event.keyCode == $.ui.keyCode.ESCAPE && self.close(event));
				})
				.attr({
					role: 'dialog',
					'aria-labelledby': titleId
				})
				.mousedown(function(event) {
					self.moveToTop(false, event);
				}),

			uiDialogContent = this.element
				.show()
				.removeAttr('title')
				.addClass(
					'ui-dialog-content ' +
					'ui-widget-content')
				.appendTo(uiDialog),

			uiDialogTitlebar = (this.uiDialogTitlebar = $('<div></div>'))
				.addClass(
					'ui-dialog-titlebar ' +
					'ui-widget-header ' +
					'ui-corner-all ' +
					'ui-helper-clearfix'
				)
				.prependTo(uiDialog),

			uiDialogTitlebarClose = $('<a href="#"/>')
				.addClass(
					'ui-dialog-titlebar-close ' +
					'ui-corner-all'
				)
				.attr('role', 'button')
				.hover(
					function() {
						uiDialogTitlebarClose.addClass('ui-state-hover');
					},
					function() {
						uiDialogTitlebarClose.removeClass('ui-state-hover');
					}
				)
				.focus(function() {
					uiDialogTitlebarClose.addClass('ui-state-focus');
				})
				.blur(function() {
					uiDialogTitlebarClose.removeClass('ui-state-focus');
				})
				.mousedown(function(ev) {
					ev.stopPropagation();
				})
				.click(function(event) {
					self.close(event);
					return false;
				})
				.appendTo(uiDialogTitlebar),

			uiDialogTitlebarCloseText = (this.uiDialogTitlebarCloseText = $('<span/>'))
				.addClass(
					'ui-icon ' +
					'ui-icon-closethick'
				)
				.text(options.closeText)
				.appendTo(uiDialogTitlebarClose),

			uiDialogTitle = $('<span/>')
				.addClass('ui-dialog-title')
				.attr('id', titleId)
				.html(title)
				.prependTo(uiDialogTitlebar);

		uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();

		(options.draggable && $.fn.draggable && this._makeDraggable());
		(options.resizable && $.fn.resizable && this._makeResizable());

		this._createButtons(options.buttons);
		this._isOpen = false;

		(options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
		(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));
	},

	close: function(event) {
		var self = this;
		
		if (false === self._trigger('beforeclose', event)) {
			return;
		}

		(self.overlay && self.overlay.destroy());
		self.uiDialog.unbind('keypress.ui-dialog');

		(self.options.hide
			? self.uiDialog.hide(self.options.hide, function() {
				self._trigger('close', event);
			})
			: self.uiDialog.hide() && self._trigger('close', event));

		$.ui.dialog.overlay.resize();

		self._isOpen = false;
	},

	isOpen: function() {
		return this._isOpen;
	},

	// the force parameter allows us to move modal dialogs to their correct
	// position on open
	moveToTop: function(force, event) {

		if ((this.options.modal && !force)
			|| (!this.options.stack && !this.options.modal)) {
			return this._trigger('focus', event);
		}
		
		if (this.options.zIndex > $.ui.dialog.maxZ) {
			$.ui.dialog.maxZ = this.options.zIndex;
		}
		(this.overlay && this.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = ++$.ui.dialog.maxZ));

		//Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
		//  http://ui.jquery.com/bugs/ticket/3193
		var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') };
		this.uiDialog.css('z-index', ++$.ui.dialog.maxZ);
		this.element.attr(saveScroll);
		this._trigger('focus', event);
	},

	open: function() {
		if (this._isOpen) { return; }

		var options = this.options,
			uiDialog = this.uiDialog;

		this.overlay = options.modal ? new $.ui.dialog.overlay(this) : null;
		(uiDialog.next().length && uiDialog.appendTo('body'));
		this._size();
		this._position(options.position);
		uiDialog.show(options.show);
		this.moveToTop(true);

		// prevent tabbing out of modal dialogs
		(options.modal && uiDialog.bind('keypress.ui-dialog', function(event) {
			if (event.keyCode != $.ui.keyCode.TAB) {
				return;
			}

			var tabbables = $(':tabbable', this),
				first = tabbables.filter(':first')[0],
				last  = tabbables.filter(':last')[0];

			if (event.target == last && !event.shiftKey) {
				setTimeout(function() {
					first.focus();
				}, 1);
			} else if (event.target == first && event.shiftKey) {
				setTimeout(function() {
					last.focus();
				}, 1);
			}
		}));

		// set focus to the first tabbable element in the content area or the first button
		// if there are no tabbable elements, set focus on the dialog itself
		$([])
			.add(uiDialog.find('.ui-dialog-content :tabbable:first'))
			.add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first'))
			.add(uiDialog)
			.filter(':first')
			.focus();

		this._trigger('open');
		this._isOpen = true;
	},

	_createButtons: function(buttons) {
		var self = this,
			hasButtons = false,
			uiDialogButtonPane = $('<div></div>')
				.addClass(
					'ui-dialog-buttonpane ' +
					'ui-widget-content ' +
					'ui-helper-clearfix'
				);

		// if we already have a button pane, remove it
		this.uiDialog.find('.ui-dialog-buttonpane').remove();

		(typeof buttons == 'object' && buttons !== null &&
			$.each(buttons, function() { return !(hasButtons = true); }));
		if (hasButtons) {
			$.each(buttons, function(name, fn) {
				$('<button type="button"></button>')
					.addClass(
						'ui-state-default ' +
						'ui-corner-all'
					)
					.text(name)
					.click(function() { fn.apply(self.element[0], arguments); })
					.hover(
						function() {
							$(this).addClass('ui-state-hover');
						},
						function() {
							$(this).removeClass('ui-state-hover');
						}
					)
					.focus(function() {
						$(this).addClass('ui-state-focus');
					})
					.blur(function() {
						$(this).removeClass('ui-state-focus');
					})
					.appendTo(uiDialogButtonPane);
			});
			uiDialogButtonPane.appendTo(this.uiDialog);
		}
	},

	_makeDraggable: function() {
		var self = this,
			options = this.options,
			heightBeforeDrag;

		this.uiDialog.draggable({
			cancel: '.ui-dialog-content',
			handle: '.ui-dialog-titlebar',
			containment: 'document',
			start: function() {
				heightBeforeDrag = options.height;
				$(this).height($(this).height()).addClass("ui-dialog-dragging");
				(options.dragStart && options.dragStart.apply(self.element[0], arguments));
			},
			drag: function() {
				(options.drag && options.drag.apply(self.element[0], arguments));
			},
			stop: function() {
				$(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
				(options.dragStop && options.dragStop.apply(self.element[0], arguments));
				$.ui.dialog.overlay.resize();
			}
		});
	},

	_makeResizable: function(handles) {
		handles = (handles === undefined ? this.options.resizable : handles);
		var self = this,
			options = this.options,
			resizeHandles = typeof handles == 'string'
				? handles
				: 'n,e,s,w,se,sw,ne,nw';

		this.uiDialog.resizable({
			cancel: '.ui-dialog-content',
			alsoResize: this.element,
			maxWidth: options.maxWidth,
			maxHeight: options.maxHeight,
			minWidth: options.minWidth,
			minHeight: options.minHeight,
			start: function() {
				$(this).addClass("ui-dialog-resizing");
				(options.resizeStart && options.resizeStart.apply(self.element[0], arguments));
			},
			resize: function() {
				(options.resize && options.resize.apply(self.element[0], arguments));
			},
			handles: resizeHandles,
			stop: function() {
				$(this).removeClass("ui-dialog-resizing");
				options.height = $(this).height();
				options.width = $(this).width();
				(options.resizeStop && options.resizeStop.apply(self.element[0], arguments));
				$.ui.dialog.overlay.resize();
			}
		})
		.find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
	},

	_position: function(pos) {
		var wnd = $(window), doc = $(document),
			pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
			minTop = pTop;

		if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {
			pos = [
				pos == 'right' || pos == 'left' ? pos : 'center',
				pos == 'top' || pos == 'bottom' ? pos : 'middle'
			];
		}
		if (pos.constructor != Array) {
			pos = ['center', 'middle'];
		}
		if (pos[0].constructor == Number) {
			pLeft += pos[0];
		} else {
			switch (pos[0]) {
				case 'left':
					pLeft += 0;
					break;
				case 'right':
					pLeft += wnd.width() - this.uiDialog.outerWidth();
					break;
				default:
				case 'center':
					pLeft += (wnd.width() - this.uiDialog.outerWidth()) / 2;
			}
		}
		if (pos[1].constructor == Number) {
			pTop += pos[1];
		} else {
			switch (pos[1]) {
				case 'top':
					pTop += 0;
					break;
				case 'bottom':
					pTop += wnd.height() - this.uiDialog.outerHeight();
					break;
				default:
				case 'middle':
					pTop += (wnd.height() - this.uiDialog.outerHeight()) / 2;
			}
		}

		// prevent the dialog from being too high (make sure the titlebar
		// is accessible)
		pTop = Math.max(pTop, minTop);
		this.uiDialog.css({top: pTop, left: pLeft});
	},

	_setData: function(key, value){
		(setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));
		switch (key) {
			case "buttons":
				this._createButtons(value);
				break;
			case "closeText":
				this.uiDialogTitlebarCloseText.text(value);
				break;
			case "dialogClass":
				this.uiDialog
					.removeClass(this.options.dialogClass)
					.addClass(uiDialogClasses + value);
				break;
			case "draggable":
				(value
					? this._makeDraggable()
					: this.uiDialog.draggable('destroy'));
				break;
			case "height":
				this.uiDialog.height(value);
				break;
			case "position":
				this._position(value);
				break;
			case "resizable":
				var uiDialog = this.uiDialog,
					isResizable = this.uiDialog.is(':data(resizable)');

				// currently resizable, becoming non-resizable
				(isResizable && !value && uiDialog.resizable('destroy'));

				// currently resizable, changing handles
				(isResizable && typeof value == 'string' &&
					uiDialog.resizable('option', 'handles', value));

				// currently non-resizable, becoming resizable
				(isResizable || this._makeResizable(value));
				break;
			case "title":
				$(".ui-dialog-title", this.uiDialogTitlebar).html(value || '&nbsp;');
				break;
			case "width":
				this.uiDialog.width(value);
				break;
		}

		$.widget.prototype._setData.apply(this, arguments);
	},

	_size: function() {
		/* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
		 * divs will both have width and height set, so we need to reset them
		 */
		var options = this.options;

		// reset content sizing
		this.element.css({
			height: 0,
			minHeight: 0,
			width: 'auto'
		});

		// reset wrapper sizing
		// determine the height of all the non-content elements
		var nonContentHeight = this.uiDialog.css({
				height: 'auto',
				width: options.width
			})
			.height();

		this.element
			.css({
				minHeight: Math.max(options.minHeight - nonContentHeight, 0),
				height: options.height == 'auto'
					? 'auto'
					: Math.max(options.height - nonContentHeight, 0)
			});
	}
});

$.extend($.ui.dialog, {
	version: "1.7.1",
	defaults: {
		autoOpen: true,
		bgiframe: false,
		buttons: {},
		closeOnEscape: true,
		closeText: 'close',
		dialogClass: '',
		draggable: true,
		hide: null,
		height: 'auto',
		maxHeight: false,
		maxWidth: false,
		minHeight: 150,
		minWidth: 150,
		modal: false,
		position: 'center',
		resizable: true,
		show: null,
		stack: true,
		title: '',
		width: 300,
		zIndex: 1000
	},

	getter: 'isOpen',

	uuid: 0,
	maxZ: 0,

	getTitleId: function($el) {
		return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid);
	},

	overlay: function(dialog) {
		this.$el = $.ui.dialog.overlay.create(dialog);
	}
});

$.extend($.ui.dialog.overlay, {
	instances: [],
	maxZ: 0,
	events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
		function(event) { return event + '.dialog-overlay'; }).join(' '),
	create: function(dialog) {
		if (this.instances.length === 0) {
			// prevent use of anchors and inputs
			// we use a setTimeout in case the overlay is created from an
			// event that we're going to be cancelling (see #2804)
			setTimeout(function() {
				$(document).bind($.ui.dialog.overlay.events, function(event) {
					var dialogZ = $(event.target).parents('.ui-dialog').css('zIndex') || 0;
					return (dialogZ > $.ui.dialog.overlay.maxZ);
				});
			}, 1);

			// allow closing by pressing the escape key
			$(document).bind('keydown.dialog-overlay', function(event) {
				(dialog.options.closeOnEscape && event.keyCode
						&& event.keyCode == $.ui.keyCode.ESCAPE && dialog.close(event));
			});

			// handle window resize
			$(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
		}

		var $el = $('<div></div>').appendTo(document.body)
			.addClass('ui-widget-overlay').css({
				width: this.width(),
				height: this.height()
			});

		(dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());

		this.instances.push($el);
		return $el;
	},

	destroy: function($el) {
		this.instances.splice($.inArray(this.instances, $el), 1);

		if (this.instances.length === 0) {
			$([document, window]).unbind('.dialog-overlay');
		}

		$el.remove();
	},

	height: function() {
		// handle IE 6
		if ($.browser.msie && $.browser.version < 7) {
			var scrollHeight = Math.max(
				document.documentElement.scrollHeight,
				document.body.scrollHeight
			);
			var offsetHeight = Math.max(
				document.documentElement.offsetHeight,
				document.body.offsetHeight
			);

			if (scrollHeight < offsetHeight) {
				return $(window).height() + 'px';
			} else {
				return scrollHeight + 'px';
			}
		// handle "good" browsers
		} else {
			return $(document).height() + 'px';
		}
	},

	width: function() {
		// handle IE 6
		if ($.browser.msie && $.browser.version < 7) {
			var scrollWidth = Math.max(
				document.documentElement.scrollWidth,
				document.body.scrollWidth
			);
			var offsetWidth = Math.max(
				document.documentElement.offsetWidth,
				document.body.offsetWidth
			);

			if (scrollWidth < offsetWidth) {
				return $(window).width() + 'px';
			} else {
				return scrollWidth + 'px';
			}
		// handle "good" browsers
		} else {
			return $(document).width() + 'px';
		}
	},

	resize: function() {
		/* If the dialog is draggable and the user drags it past the
		 * right edge of the window, the document becomes wider so we
		 * need to stretch the overlay. If the user then drags the
		 * dialog back to the left, the document will become narrower,
		 * so we need to shrink the overlay to the appropriate size.
		 * This is handled by shrinking the overlay before setting it
		 * to the full document size.
		 */
		var $overlays = $([]);
		$.each($.ui.dialog.overlay.instances, function() {
			$overlays = $overlays.add(this);
		});

		$overlays.css({
			width: 0,
			height: 0
		}).css({
			width: $.ui.dialog.overlay.width(),
			height: $.ui.dialog.overlay.height()
		});
	}
});

$.extend($.ui.dialog.overlay.prototype, {
	destroy: function() {
		$.ui.dialog.overlay.destroy(this.$el);
	}
});

})(jQuery);

