Your problem is on the call for the dialog
If you dont initialize the dialog, you don't have to pass "open" for it to show:
$("#dialog").dialog();
Also, this code needs to be on a $(document).ready();
function or be below the elements for it to work.