Move layer var out of document.ready