function CMDialog()
{
	this.dialog = new $('<div></div>').dialog({
		autoOpen: false,
		closeOnEscape: false,
		position: ['center','center'],
		draggable: false,
		resizable: false,
		modal: true
	});	
	this.buttons = {};
}

CMDialog.prototype = {
	SetWidth: function(size)
	{
		$(this.dialog).dialog('option', 'width', parseInt(size));	
	},
	SetHeight: function(size)
	{
		$(this.dialog).dialog('option', 'height', parseInt(size));
	},
	SetMsg: function(msg)
	{
		$(this.dialog).html(msg);		
	},
	SetTitle: function(title)
	{
		$(this.dialog).dialog('option', 'title', title);
	},
	SetLoadingTitle: function()
	{
		$(this.dialog).dialog('option', 'title', '<img src="/images/ajax_loader_s.gif" />&nbsp;&nbsp;&nbsp;Loading...');
	},
	SetCloseButton: function(isButton)
	{
		if(isButton)
		{
			this.buttons['Close'] = function() { $(this).dialog("close"); };
		}
		else
		{
			delete this.buttons['Close'];
			$(this.dialog).dialog('option', 'open', function(event, ui) {jQuery('.ui-dialog-titlebar-close').hide();});
		}
		this.SetButtons();
	},
	SetInviteButton: function(isButton)
	{
		if(isButton)
		{
			this.buttons['Invite a friend'] = function() { InvManager.ShowInvScreen(); $(this).dialog("close");};	
		}
		else
		{
			delete this.buttons['Invite a friend'];
		}			
		this.SetButtons();
	},
	SetButtons: function()
	{
		$(this.dialog).dialog('option', 'buttons', this.buttons);
	},
	Show: function(show)
	{
		if(show)
		{
			if(!$(this.dialog).dialog( 'isOpen' )) $(this.dialog).dialog('open');
		}
		else
		{
			if($(this.dialog).dialog( 'isOpen' )) $(this.dialog).dialog('close');
		}
	}
};