jQuery: Classes and Namespaces
<p>I have been told to start using Classes and Namespacing in my jQuery code and for a new app we are building we will be making the code very simple and slick. For example the following code is used on out login page to load all the content before fading it in:</p>

<pre><code>        // Hide the content and fadein the spinner
        jQuery(document).ready(function()
        {
            $('#hide').hide();
            $('body').append('&lt;div id="loading"&gt;loading...&lt;/div&gt;');
            $("#loading").hide();
            setTimeout($('#loading').fadeIn(), 200);
        });

        // When all content has loaded, fadeout the spinner and THEN fadein the content
        jQuery(window).load(function ()
        {
            $("#loading").fadeOut("slow", function ()
            {
                $("#loading").remove();
                clearInterval(loadingAnim);
                $("#hide").fadeIn("slow");
            });
        });

        var lastx = 0;

        var loadingAnim = setInterval(function () { UpdateSpinner("#loading", 42, 504); }, 42);

        function UpdateSpinner(target, step, width)
        {
            $(target).css("background-position", "0 " + lastx + "px");
            lastx = (lastx - step) % width;
        }
</code></pre>

<p>How could I make this more simple using Name spacing and classes?</p>

<p>Example of where I have seen this used: <a href="http://static.neow.in/js/pegasus/mainpage.js" rel="nofollow">http://static.neow.in/js/pegasus/mainpage.js</a></p>

<p>Thanks</p>
