function showPopUp(sImg){ var oImg = new Image(); var bLoaded; oImg.src=sImg+'?'+randomnumber(); oImg.onload = function evt(){ if (oImg.complete) { bLoaded=true; } else { if (oImg.readyState == 'complete') { bLoaded=true; } } if(bLoaded){ if(document.getElementById('divPopup')){hidePopup()} var iWidth=oImg.width; var iHeight=oImg.height; var oDiv = document.createElement('DIV'); oDiv.id='divPopup'; oDiv.style.position='absolute'; var aScreenResolution = new retScreenResolution(); oDiv.style.left=(aScreenResolution[0]/2)-(iWidth/2)-retBodyLeft()+'px'; oDiv.style.top=(aScreenResolution[1]/2)-(iHeight/2)+'px'; oDiv.style.width=iWidth+'px'; oDiv.style.height=iHeight+'px'; oDiv.style.zIndex=10; document.body.appendChild (oDiv); if(document.getElementById('divPopup')){ oDiv.innerHTML='<a href="javascript:hidePopup()" title="Klik hier om de afbeelding te sluiten"><img src="'+sImg+'" title="Klik hier om te sluiten"/></a>'; var oClose = document.createElement('DIV'); oClose.id='divClose'; oClose.style.position='absolute'; document.body.appendChild (oClose); oClose.innerHTML='<a id=\"popuplink\" href="javascript:hidePopup()" title="Klik hier om te sluiten">Sluiten</a>'; oClose.style.left=((oDiv.offsetLeft+oDiv.offsetWidth)-oClose.offsetWidth)-10+'px'; oClose.style.top=oDiv.offsetTop+5+'px'; oClose.style.zIndex=20; } } } } function retScreenResolution(){ var frameWidth = 0; var frameHeight = 0; if (self.innerWidth) { frameWidth = self.innerWidth; frameHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientWidth) { frameWidth = document.documentElement.clientWidth; frameHeight = document.documentElement.clientHeight; } else if (document.body) { frameWidth = document.body.clientWidth; frameHeight = document.body.clientHeight; } var aFrame = new Array(frameWidth, frameHeight); return aFrame; } function retBodyLeft(){ var bodyLeft = 0; if (self.innerWidth) { bodyLeft = (self.innerWidth - document.body.offsetWidth) / 2; } else if (document.documentElement && document.documentElement.clientWidth) { bodyLeft = document.body.offsetLeft; } else if (document.body) { bodyLeft = document.body.offsetLeft; } return bodyLeft; } function hidePopup(){ var oDiv = document.getElementById('divPopup'); var oClose = document.getElementById('divClose'); if(oDiv){ document.body.removeChild(oDiv); document.body.removeChild(oClose); } } function movePopup(){ var aScreenResolution = retScreenResolution(); if(document.getElementById('divPopup')){ document.getElementById('divPopup').style.left=(aScreenResolution[0]/2)-(document.getElementById('divPopup').offsetWidth/2)-retBodyLeft()+'px'; document.getElementById('divPopup').style.top=(aScreenResolution[1]/2)-(document.getElementById('divPopup').offsetHeight/2)+'px'; document.getElementById('divClose').style.left=((document.getElementById('divPopup').offsetLeft+document.getElementById('divPopup').offsetWidth)-document.getElementById('divClose').offsetWidth)-10+'px'; document.getElementById('divClose').style.top=document.getElementById('divPopup').offsetTop+5+'px'; } } function randomnumber() { return Math.round((99977562 - 10016486) * Math.random() + 1) + 22423; }
