JQUERY OVERLAY WINDOW NOT OPENING FOR THE FIRST TIME

JQUERY OVERLAY WINDOW NOT OPENING FOR THE FIRST TIME

Hello all,

    In my application I am opening a jquery overlay window through the onclick event of a g link tag.What happens is,for the very first time I click the link only the background changes but no other actions take place .If I press Escape and click the link again the window opens.

   I want the window to be opened for the first click event.

   The code I am using to open the window is:

$(function() {
     
        $("a[rel]").overlay({
            mask: 'black',
            effect:'apple',
            closeOnClick: false,
            onBeforeLoad: function() 
            {
               var wrap = this.getOverlay().find(".contentWrap");
                wrap.load(this.getTrigger().attr("href"));
              }
     
        });
    });

The code for the link is:

<li><g:link url="[action:'settings',controller:'settings']"   rel="#overlay">Settings</g:link></li>

I got the plugin from the following site:
http://jquerytools.org/demos/overlay/apple.html