Pass in window to the self invoking function