Script does not function when dynamically including jQuery
<p>I've got a script that I'm trying to modify so that I don't load the jQuery library if its already present. However, the only way I can get things to work is example 1 below (explictly loading the jQuery library). When I try to conditionally load it, the slider does not work...</p>

<p>Example #1 - the slider works fine in this example (but jQuery may be loaded multiple times)</p>

<pre><code>&lt;head&gt;
    &lt;script type='text/javascript' src='scripts/js/jquery-1.4.2.min.js'&gt;&lt;/script&gt;
    &lt;script type='text/javascript' src='scripts/js/slider/jquery.slider.js'&gt;&lt;/script&gt;
    &lt;script type='text/javascript'&gt;
        jQuery(document).ready(
            function(){
                jQuery('#accordion-1').slider({
                    autoStart:true,
                    slideInterval:5000,
                    slideNum:false
                });
            })
    &lt;/script&gt;
&lt;/head&gt;
</code></pre>

<p>Example #2 - Trying to dynamically load jQuery. Slider does not work.</p>

<pre><code>&lt;head&gt;
    &lt;script type='text/javascript'&gt;
        if (typeof jQuery == 'undefined') {  
            // jQuery is not loaded =&gt; load it:
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
            document.getElementsByTagName('body')[0].appendChild(script);
        }
    &lt;/script&gt;

    &lt;script type='text/javascript' src='scripts/js/slider/jquery.slider.js'&gt;&lt;/script&gt;
    &lt;script type='text/javascript'&gt;
        jQuery(document).ready(
            function(){
                jQuery('#accordion-1').slider({
                    autoStart:true,
                    slideInterval:5000,
                    slideNum:false
                });
            })
    &lt;/script&gt;
&lt;/head&gt;
</code></pre>

<p>Example #3 - This does not work either...</p>

<pre><code>&lt;head&gt;
    &lt;script type="text/javascript"&gt;
        if (typeof jQuery == 'undefined') {  
            document.write(unescape('%3Cscript src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"%3E%3C/script%3E'));
        }
    &lt;/script&gt;
    &lt;script type='text/javascript' src='scripts/js/slider/jquery.slider.js'&gt;&lt;/script&gt;
&lt;/head&gt;
</code></pre>
