jQuery - two times click to start function
<p>I created a link which is responsible for showing up modal window. The modal window shows up fine, but i must click two times... How to fix?</p>

<p>html code with links:</p>

<pre><code>&lt;body&gt;
&lt;a href="?id=1#" class="runpl"&gt;Buy product #1&lt;/a&gt;
&lt;br/&gt;&lt;a href="?id=2#" class="runpl"&gt;Buy product #2&lt;/a&gt;
&lt;/body&gt;
</code></pre>

<p>jQuery start functions:</p>

<pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="plPopup.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;

$(this).ready(function(){

        $('.runpl').plPopup("..popup html code..");

});

&lt;/script&gt;
</code></pre>

<p>plPopup.min.js:</p>

<pre><code>(function($)
{
    var f = {width:'650',height:'150',background:false,html:'',url:'',close:'close'};
    var g;

    $.fn.plPopup=function(d)
    {
        g=$.extend({},f,g,d);
        var e=1+Math.floor(Math.random()*1024);
        if(g.background)
    {
        if(!$("div").is("#plup_fade"))
        {
            $("body").append('&lt;div id="plup_fade'+e+'" class="plup_fade"&gt;&lt;/div&gt;');
            $("#plup_fade"+e).hide()
            }
    }

    $("body").append('&lt;div id="plup_msg'+e+'" class="plup_msg" style="width:'+parseInt(g.width)+'px; min-height:'+parseInt(g.height)+'px; height:'+parseInt(g.height)+'px; margin-top: -'+(parseInt(g.height)/2)+'px; margin-left: -'+(parseInt(g.width)/2)+'px;"&gt;&lt;/div&gt;');


    $("#plup_msg"+e).html('&lt;div class="plup_close" style="text-align:right;"&gt;&lt;a href="#" title="'+g.close+'"&gt;&lt;img src="img/popup/close.png"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="plup_data"&gt;&lt;/div&gt;');

    if(g.html)
    {
        $("#plup_msg"+e+" .plup_data").html(g.html)
    }else
    {
        if(g.url)
        {
            $("#plup_msg"+e+" .plup_data").load(g.url,function(a,b,c)
            {
                if(b=="error")
                {$("#plup_msg"+e+" .plup_data").html('&lt;b&gt;plPopup:&lt;/b&gt; Error loading data =(&lt;/div&gt;')}
                })
                }else{$("#plup_msg"+e+" .plup_data").html('&lt;b&gt;plPopup:&lt;/b&gt; Nothing to render! =(')
                }
                }
                $("#plup_msg"+e).hide();$(this).click(function(){$("#plup_fade"+e).show();$("#plup_msg"+e).fadeIn('slow')});
                $("#plup_msg"+e+" .plup_close a, #plup_fade"+e).click(function()
                {
                    $("#plup_msg"+e).fadeOut('slow');$("#plup_fade"+e).delay(8000).hide()
                });


    return this
    }

})(jQuery);
</code></pre>

<p>but he is fine maybe</p>
