
var _iDialogID = null, _iDialogRefrsh = null;

function _destroyDialogOnly()
{
		//console.log("Dialog destroy");
		if (_iDialogID != null) {
			_iDialogID.destroyRecursive();
			_iDialogID = null;
		}
}

function destroyDialog()
{
		_destroyDialogOnly();
		if (_iDialogRefrsh != null) {
			var obj = dijit.byId(_iDialogRefrsh);
			if (obj) obj.refresh();
			_iDialogRefrsh = null;
		}
}
		
function iDialog(dialogID, refreshID, Title, width, height, URL, closeButton)
{
	destroyDialog();
	
	var Content ="";
	
	if (closeButton)
		Content = "<div style='text-align:right;'><img src='/images/close_window.gif' style='cursor:pointer' border='0' onClick='destroyDialog()'></div>" + Content;
	_iDialogID = new dijit.Dialog({id:dialogID, title: Title, preventCache:true, onExecute:destroyDialog, onCancel:destroyDialog, onHide:destroyDialog});
	Content += "<iframe width='"+width+"' height='"+height+"' src='"+URL+"'></frame>";
	_iDialogID.setContent(Content);
	_iDialogID.show();
	_iDialogRefrsh = refreshID;
	dojo.addOnUnload(_destroyDialogOnly);
}
