how to reuse a jquery function
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2597152/jquery-window-resize-doesnt-work-on-load">JQuery: $(window).resize() doesn&#39;t work on Load</a>  </p>
</blockquote>



<p>I have the below jQuery function. I  want to use it twice. Once on window resize and again on page load without having to repeat myself. I have tried the below which works on resizing the browser window but the function is not working when I try to run again it on page load.</p>

<pre><code> window.onresize = function resize(event) {
    if(window.innerWidth &lt; 620 ){
        $('#secondaryNav').hide();
        $('#search form').prependTo('div.content');
    } else{
        $('#secondaryNav').show();
        $('.content form').appendTo('#search');
    }

}

window.onload =  resize(event);
</code></pre>

<p>Any help would be greatly appreciated.</p>
