ui dialog does not close for the second time ...

ui dialog does not close for the second time ...

 $('.Editcoupon').click(function() {
                var strRef = '';
                var strid = '';
                var strSelectedval = '';
                strRef = $(this).attr('ref');
                strid = $(this).attr('id');
                strqueryvalue = $(this).attr('ref').match(/Defaultcoupon=([0-9]+)/)[1];
                $("#Coupondialog-modal" + strid + strSelectedval).dialog("destroy")
                $("<div id='Coupondialog-modal" + strid + strqueryvalue + "' title='Click here to move' style='display:none;'><iframe src='" + strRef + "' width='740' height='457' frameborder='0' style='border:none;' id='vehicleIframe'></iframe></div>").appendTo('body');
                $("#Coupondialog-modal" + strid + strqueryvalue).dialog({
                    width: 750,
                    height: 502,
                    resizable: false,
                    autoOpen: false,
                    //buttons: { "close": function() { $(this).dialog("close"); } },
                    
                    modal: true
                });
                $("#Coupondialog-modal" + strid + strqueryvalue).load();
                $("#Coupondialog-modal" + strid + strqueryvalue).dialog('open');

            });


the above is code to open a UI dialog of jquery where iframe is dynamically injected to body tag,which on click of a href tag ,for first time iam able to open dialog & close ,again when iam trying to open dialog ,close it using below code 

window.parent.$("#Coupondialog-modalloadcoupons" + offerid+count ).dialog('close');

it is not closing the dialog 

can any one please guide me ?