Two thickbox windows are displayed when the link is clicked more than once

Hi, I am using Thickbox for overlaying a view file. I get all the functionalities working well and good except for one problem. When I click the link for bringing up the thickbox window more than once without a page refresh, two thickbox windows are displayed. The top thickbox window has the html content and the bottom window is empty.

This is my code:



Export

I add the url to the href attribute dynamically after clicking the 'export' link, so I have added the line tb_open_new($(this).attr("href")); as suggested in this site

When I click the 'export' link for the first time, only one window is displayed(but the title is not displayed in the tb window). Then if I close the tb window and click the 'export' link again, two tb windows are displayed. Now the top window has the title along with the html content and the close button in it works. the bottom tb window is empty and even if I click close,it does not close.

Can some one help me with this?

EDIT

Now, I have added another button called 'Close' with an onclick event in the export file, so that On clicking the button, the TB window closes. The onclick event calls the tb_remove method,so that the TB window closes.

After adding this button, I do not get the default close button in the title of the TB window. That is, I do not get the title of the TB window, only its content is displayed(checked the code generated through firebug). Now If I click the 'Export' link for the second time, since the title is not there, empty space is added below the first TB window. I have given the code viewed through firebug below:

 

Export Options


Text(.txt) CSV(.csv) Close


//this is the extra one.