What is proper posting of javascript functions?
<p>Are these two below the same?</p>

<pre><code>&lt;script type="text/javascript"&gt; 
var $j = jQuery.noConflict();
$j(document).ready(function () {
    $j('.fancybox').fancybox({
        maxWidth    : 700,
        maxHeight   : 550,
        minHeight   : 500,
        closeBtn:true
    });
    $j('a.fancybox').fancybox({
        maxWidth    : 700,
        maxHeight   : 550,
        minHeight   : 500,
        closeBtn:true
    });
    $j('#homeslider iframe').each(function() {
        var url = $j(this).attr("src")
        $j(this).attr("src",url+"&amp;amp;wmode=Opaque")
    });
});
&lt;/script&gt;
&lt;script&gt;
var $j = jQuery.noConflict();
$j(function(){
    // jQuery UI Dialog  
    $j('#dialog').dialog({
        autoOpen: false,
        width: 400,
        modal: true,
        resizable: false,
        buttons: {
            "Submit Form": function() {
                document.testconfirmJQ.submit();
            },
            "Cancel": function() {
                $j(this).dialog("close");
            }
        }
        return false;
    });
});
&lt;/script&gt;
</code></pre>

<p>and this</p>

<pre><code>&lt;script type="text/javascript"&gt; 
var $j = jQuery.noConflict();
$j(document).ready(function () {
    $j('.fancybox').fancybox({
        maxWidth    : 700,
        maxHeight   : 550,
        minHeight   : 500,
        closeBtn:true
    });
    $j('a.fancybox').fancybox({
        maxWidth    : 700,
        maxHeight   : 550,
        minHeight   : 500,
        closeBtn:true
    });
    $j('#homeslider iframe').each(function() {
        var url = $j(this).attr("src")
        $j(this).attr("src",url+"&amp;amp;wmode=Opaque")
    });
});
$j(function(){
    // jQuery UI Dialog  
    $j('#dialog').dialog({
        autoOpen: false,
        width: 400,
        modal: true,
        resizable: false,
        buttons: {
            "Submit Form": function() {
                document.testconfirmJQ.submit();
            },
            "Cancel": function() {
                $j(this).dialog("close");
            }
        }
        return false;
    });
});
&lt;/script&gt;
</code></pre>

<p>I removed the close script and start new one to connect these two.  I also removed the redundant noConflict.  Why do I get different behavior with these two different uses in my header?  </p>
