Try this
<script>
function popup_img() {

var layer=document.createElement("div");
layer.id="layer_id";
layer.style.position="absolute";
layer.style.left=0;
layer.style.top=0;...