this code should use a general approach. I suggest to read up on jQueryUI which is used for the tooltips already. If I remember correctly it already offers popups / alert dialog replacements. Code used for the tooltips could be reused.