Problems on dialog

Problems on dialog


Hello
I have a problem about dialog.
I wrote a function which runs onClick event.
    function Delete(idd) {
        $("#dialog").dialog({
            bgiframe: true,
            resizable: false,
            draggable: false,
            autoOpen: true,
            height:140,
            modal: true,
            overlay: {
                backgroundColor: '#000',
                opacity: 0.5
            },
            buttons: {
                'Delete': function() {
$.ajax({
type: "POST",
url: "process.php",
data: "action=del&id="+ idd,
success: function(){
top.location.href="index.php";
}
    });
                },
                Cancel: function() {
                    $(this).dialog('close');
                }
            }
        });
    };
Its strange that, this dialog works well when i opened the page first
time.
I clicked the button, dialog came on thats ok. But when i click X or
Cancel. I cannot use this function again.
I dont know why. Its like disabled.
Lastly, I have also
     $(document).ready(function(){
        $("#dialog").css("display","none");
    });
To hide the dix which contains the dialog content.
I hope someone gives me an idea to achieve that problem.
Cheers
J