(function($) {

$.Dialog = {	

	// These properties can be read/written by accessing $.Dialog.options.propertyName from your scripts at any time
	options: {
		autoOpen: false,
		open: function() { },
		close: function() { $.Dialog._hide(); },
		buttons: {},
		closeOnEscape: true,
		closeText: 'close',
		dialogClass: '',
		draggable: true,
		hide: null,
		height: 'auto',
		maxHeight: false,
		maxWidth: false,
		minHeight: 150,
		minWidth: 150,
		modal: true,
		position: {
			my: 'center',
			at: 'center',
			of: window,
			collision: 'fit',
			// ensure that the titlebar is never outside the document
			using: function(pos) {
				var topOffset = $(this).css(pos).offset().top;
				if (topOffset < 0) {
					$(this).css('top', pos.top - topOffset);
				}
			}
		},
		resizable: false,
		show: null,
		stack: true,
		title: '',
		width: 300,
		zIndex: 1000
	},
	
	_show: function(message, title, iframe, iframeW, iframeH) {		
		
		$.Dialog._hide();
		
		if(iframe === true){
			$.Dialog.options.width = iframeW;
			$.Dialog.options.height = iframeH;
			$.Dialog.options.open = function(){ $('#dialog').css('overflow','hidden'); }
			var html = '<div id="dialog" title="' + title + '"><iframe scrolling="no" width="' + iframeW + '" height="' + iframeH + '" frameborder="0" src="' + message + '"></iframe></div>';
		}else{						
			var html = '<div id="dialog" title="' + title + '">' + message + '</div>';
		}
		
		$("body").append(html);
	},
		
	_hide: function() {		
		$("#dialog").remove();					
	},
	
	open: function(message, title, iframe, iframeW, iframeH) {		
		$.Dialog._show(message, title, iframe, iframeW, iframeH);		
		$("#dialog").dialog($.Dialog.options);		
		$('#dialog').dialog( "open" );		
	}
	
}

jDialog = function(message, title, iframe, iframeW, iframeH) {	
	$.Dialog.open(message, title, iframe, iframeW, iframeH);	
}
	
})(jQuery);
