How can you check if a dialog has been initialised?

How can you check if a dialog has been initialised?


Is there a way to check if a dialog has been initialised or not? i
just want to check if it exists and if it does then open it, otherwise
create one etc.
eg something like this (which dosent work);
if ($('#mydialog').is('dialog') {
$('#mydialog').dialog('open');
}else {
$('#mydialog').dialog({
autoOpen: false,
modal: true,
draggable: true,
width: 470,
height: 'auto',
resizable: false,
draggable: false,
bgiframe: true
});
}