All div's are activated instead of one
<p>I have this code and it starts running when I load the page and when I click the link it opens an popup.
My popups are filled with an mail script. When the page is loaded all mails are send before I click on the link to show the popup.</p>

<pre><code>$(document).ready(function() {
//When you click on a link with class of poplight and the href starts with a # 
$('a.poplight[href^=#]').live('click', function() {
    var popID = $(this).attr('rel'); //Get Popup Name
    var popURL = $(this).attr('href'); //Get Popup href to define size

    //Pull Query &amp; Variables from href URL
    var query= popURL.split('?');
    var dim= query[1].split('&amp;');
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value

    //Fade in the Popup and add close button
    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('&lt;a href="#" class="close"&gt;&lt;img src="images/icon/delete.png" class="btn_close" title="&lt;?php echo $lang['sluit'] ?&gt;" /&gt;&lt;/a&gt;');

    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    //Apply Margin to Popup
    $('#' + popID).css({
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    //Fade in Background
    $('body').append('&lt;div id="fade"&gt;&lt;/div&gt;'); //Add the fade layer to bottom of the body tag.
    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

    return false;
});

//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  //fade them both out
    });
    return false;
});
});
</code></pre>

<p>This is the target div:</p>

<pre><code>echo '&lt;a href="#?w=100" rel="popup_bestelling_mail'.$row['best_id'].'" class="poplight" title="'.$lang['send'].'"&gt;&lt;img align="center" src="images/icon/pdf_mail.png" /&gt;&lt;/a&gt;';

&lt;div id="popup_edit_bestelling&lt;?php echo $row['best_id']; ?&gt;" class="popup_block"&gt;
&lt;iframe src="edit_bestelling.php?id=&lt;?php echo $row['best_id']; ?&gt;" frameborder="0" width="1000" height="575"&gt;
&lt;/iframe&gt;
&lt;/div&gt;
</code></pre>
