jQuery UI dialog - multiple IF problems

jQuery UI dialog - multiple IF problems

I definitely don't think of myself as a jQuery/javascript expert, but I know enough programming to get by - but on this project I ran into a problem where jQuery UI fails to initialize the 2nd dialog. I have 2 if statements to test before initializing each of them, but only the 1st if statement seems to be kicking in.

Here's my code:
  1. $(document).ready(function(){ 
    // regular dialog box
    $("#dialog").dialog({autoOpen: false, modal: true});
    return false;

    // confirm box
    if($.cookie("modal_confirm").length > 0 && $.cookie("modal_confirm")!="") {
    var g = $("#confirm");
    g.html( g.html().replace(/\+/g," ") );
    modal: true,
    stack: true,
    buttons: {
    'OK': function() { window.location.replace(decodeURIComponent($.cookie("confirmGo"))); (this).dialog('close'); },
    Cancel: function() { $(this).dialog('close'); }
    close: function(){ $.cookie("modal_confirm",null); $.cookie("confirmGo",null);}

    // alert box
    if($.cookie("alert").length > 0 && $.cookie("alert")!="") {
    var f = $("#alert");
    f.html( f.html().replace(/\+/g," ") );
    $("#alert").dialog({modal: true, stack: true, buttons: {'OK': function() {$(this).dialog('close');}}, close: function(){ $.cookie("alert",null); }});

In this case, the alert modal wouldn't open while the confirm opens. If I move it in front of the confirm, then the alert would open but the confirm wouldn't open. Is this a jQuery UI problem? If so, is there a workaround?

Please help and thanks in advance.