How can I make a function defined in jQuery.ready available globally?
<p>I'm somewhat new to this so I think there is an easy answer. </p>

<p>I have a function that strips the youtube id off a url. I then want to use this function 10 time per page (in the wordpress loop).</p>

<p>The function works great when I feed it the url within my function script tags, but when I start a new set of script tags within the loop, it does not work.</p>

<p>I need to know how I can use my function without declaring it all first.</p>

<p>So this is the code I have in the header:</p>

<pre><code> &lt;script type="text/javascript"&gt; 
$(document).ready(function() {
var getList = function(url, gkey){
        var returned = null;
        if (url.indexOf("?") != -1){
          var list = url.split("?")[1].split("&amp;"),
                  gets = [];

          for (var ind in list){
            var kv = list[ind].split("=");
            if (kv.length&gt;0)
                gets[kv[0]] = kv[1];
        }

        returned = gets;

        if (typeof gkey != "undefined")
            if (typeof gets[gkey] != "undefined")
                returned = gets[gkey];

        }

            return returned;

    };


        // THIS WORKS

    alert(getList('http://www.youtube.com/watch?v=dm4J5dAUnR4', "v"));


      });
</code></pre>

<p>But when I try use this somewhere else on the page, it doesnt work.</p>

<pre><code> &lt;script type="text/javascript"&gt; 

      $(document).ready(function() {
              alert(getList('http://www.youtube.com/watch?v=dm4J5dAUnR4', "v"));
      };
      &lt;/script&gt;
</code></pre>

<p>Firebug gives me <strong>getList is not defined</strong> which makes sense, because its not. Am I able to 'globally' declare this function?</p>
