Possible Duplicate:
JQuery: $(window).resize() doesn't work on Load
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.
window.onresize = function resize(event) {
if(window.innerWidth < 620 ){
$('#secondaryNav').hide();
$('#search form').prependTo('div.content');
} else{
$('#secondaryNav').show();
$('.content form').appendTo('#search');
}
}
window.onload = resize(event);
Any help would be greatly appreciated.