Change window.resize to $(window).resize();