Function prevents window.resize in jquery firing multiple times