How do I get this function to not only run on window resize but also on initial page load?
$(window).resize(function() {
...
});
You'll want to use:
$(document).ready(function() { /* your code */ });
To make something happen onload. If you want something to work onload and onresize, you should do:
onResize = function() { /* your code */ }
$(document).ready(onResize);
$(window).bind('resize', onResize);