Consolidated overlay jQuery code into a function and a callback