jQuery: sharing function between page code and document.ready code
<p>I have some nice dialogues defined as such in jQuery:</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function() {

    $( "#someDialog" ).dialog({
        autoOpen: false,
        model: true,
        buttons: {
            "Do Something": function() {
                var cleanInput = sanitizeInput(input);
                // Do something with the clean input
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        },
        close: function() {
        }
    });

    function sanitizeInput(input) {
        // Some magic here
        return input;
    }
});
&lt;/script&gt;
</code></pre>

<p>Somewhere in the page, unrelated to the dialog, I have an element that calls a function with a parameter:</p>

<pre><code>&lt;a href="#" onclick="doSomething('wendy');"&gt;Wendy's stats&lt;/a&gt;
</code></pre>

<p>And the associated JavaScript:</p>

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

function doSomething(input) {
    var cleanInput = sanitizeInput(input);
    // Some code here
}

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

<p>I would like to reuse the sanitizeInput() function for this function as well. However, from outside the document.ready function, the dialog does not work. Putting the doSomething() function inside the document.ready function breaks it likewise. So where do I put the sanitizeInput() function such that both can use it?</p>

<p>Thanks.</p>
