/**
 * Rits Framework
 *
 * LICENSE
 * 
 * This source file is subject to the Rits Commercial license.
 * 
 * @copyright  2008 Rits Comunicação & Tecnologia. (http://www.rits.com.br)
 * @license    Rits Commercial License 1.0
 * @version    $Id:$
 */

/**
 * Dialog 
 *
 * @category   Rits
 * @package    Rits
 * @copyright  2008 Rits Comunicação & Tecnologia. (http://www.rits.com.br)
 * @license    Rits Commercial License 1.0
 */
 
Rits.Dialog = function(id, width) {
	var config = {fixedcenter : true, visible : false,  constraintoviewport : true, modal: true};		
	if(width) {
		config.width = width;
	}
	this._id = id;
	this._dialog = new YAHOO.widget.Dialog(id, config);
	
	this._dialog.render();	
};

Rits.Dialog.prototype = {
	_id: null,
	_dialog: null,
		
	/**
	 * Open a dialog
	 * 
	 * @param string title
	 * @param string url
	 */
	open: function(title, url) {
		$D.get(this._id+'-title').innerHTML = title;
		this._dialog.show();				
		if(url) {
			Rits.Ajax.loadContent(this._id+'-content', url, {dialog: this});			
		}
	},
	
	/**
	 * Close the dialog
	 */
	close: function() {		
		this._dialog.hide();
	},
	
	/**
	 * Center the dialog
	 */
	center: function() {
		this._dialog.center();
	}
};

