function MessageBox(title, msg)
{
	if ($('body').find('#message_box'))
	{
		$("body").append('<div id="message_box" title=""></div>');
	}
	
	$('#message_box').attr('title',title);
	$('#message_box').text(msg);
	$('#message_box').dialog({modal: true, resizable: false});
}

/**
 * The base class for handling dynamic page objects
 */
function AjaxElement(jpath, url)
{
	/**
	 * A jQuery object for the object we will be dealing with.
	 */
	this.el = $(jpath);
	
	/**
	 * The url of the handler
	 */
	this.url = url;
	
	/**
	 * The callback which gets called when the ajax request completes
	 */
	this.callback = function()
	{
		var me = this;
		
		$.ajax({
			type: 'GET',
			dataType: 'xml',
			success: function(xml,s) {
				if ($('response > success', xml).text() == '1')
				{
					me.success(xml);
				}
				else
				{
					me.fail(xml);
				}
			},
			url: this.url,
			data: this.data()
		});
	}
	
	/**
	 * This function sets up the interface and prepares it to do the callback.
	 */
	this.setup = function() {}
	
	/**
	 * Return the data to be sent back to the ajax server
	 */
	this.data = function() { return "" }
	
	/**
	 * This gets called if the ajax comes back successfully.
	 */
	this.success = function(xml) { }
	
	/**
	 * This gets called if a failure packet comes back
	 */
	this.fail = function(xml)
	{
		MessageBox('There was an error', $('message',xml).text());
	}
}
