Problem set dynamic dialog option

Problem set dynamic dialog option


I have an empty div for the dialog with dynamic multimedia content.
Based on video information, i.e. dimension, dialog will load with
correct width & height.
Title option can be reset correctly, but NOT the width and height.
Also, even i enabled the modal option, strangely, I don't see the
overlay. This is Firefox environment.
Thank you for your help in advance!!
Here is the code:
$(function(){
    $("#mydiv").dialog({
        autoOpen: false,
        resizable:false,
        modal: true,
        open: function(){
            // some action here
        },
        close: function(){
            $(this).empty();
        }
    });
    var $w, $h, $title;
    $("#wrapper").find("a.mymodal").each(function(){
        $(this).click(function() {
            $h = height;
            $w = width;
            $title = title;
            $("#mydiv")
                .append("some text")
                .dialog('option', 'title', $title)
                .dialog('option', 'width', $w)
                .dialog('option', 'height', $h)
                .dialog('open');
            return false;
        });
    });
});