I am having troubles getting this dialog to work with a cookie, help PLEASE!

I am having troubles getting this dialog to work with a cookie, help PLEASE!

Hey guys, just pasting my code here; i'm trying ot make it so the
dialog comes up and then when 'x' or close is clicked it creates a
cookie which expires in say 2 days and so the dialog wont launch once
the cookie is created.
I am using the cookie.jquery.js plugin, so heres the code!
    <script type="text/javascript">
    $(function() {
        $("#dialog")
        .dialog({
            bgiframe: true,
            modal: true,
            resizable: false,
            autoOpen: true,
            width:200,
            close: function() {
                $.cookie('doneDi', 'closed', { expires: 2 })
                },
            buttons: {
                Ok: function() {
                    $(this).dialog('close')
                    $.cookie('doneDi', 'closed', { expires: 2 });
                }
            }
            });
        var doneDi = $.cookie('doneDi');
     if (doneDi == 'closed') {
$("#dialog").dialog( 'disable') ;
     };
    });
    </script>
Cheers in advance, it's been driving me nuts!!
Stefpretty
--