
/* -------------------------------------
	generate an iframe overlay
	acdhirr - trilobiet 2007
	
	include:
	<script type="text/javascript" src="_resources/js/popframe.js"></script>

	call as:	
	<a href="javascript:popframe('[url]','[text')">
------------------------------------- */
function popframe(popUrl,text) {

	if (popUrl != '') {
	
		navigator.userAgent.indexOf("MSIE 6.0")>=0?IE6 = true:IE6 = false;
		
		// full screen container
		var DIV = document.createElement('DIV');
		DIV.style.display = 'block';
		DIV.style.position = 'fixed'
		DIV.style.top = '0';DIV.style.left = '0';
	 	DIV.style.height = '100%';
		DIV.style.width = '100%';
		DIV.style.zIndex = '100';
		DIV.onclick = function(e) { closePop() }
		document.body.appendChild(DIV);

		// IE 6 hacks
		if (IE6) {
			if (IE6) document.body.style.height='100%'; 
			DIV.style.position = 'absolute';
			// IE6 doesn't support position:fixed, so we position the layer absolute
			// and turn off scrollbars in the parent document
			DIV.style.top = document.documentElement.scrollTop + 'px';
			var oldOverflow = document.documentElement.style.overflow;
			document.documentElement.style.overflow = 'hidden';
		}
		
		//opacity
		var BG = document.createElement('DIV');
		BG.style.display = 'block';
		BG.style.position = 'fixed'
		BG.style.top = '0';BG.style.left = '0';
		BG.style.height = '100%';
		BG.style.width = '100%';
		BG.style.backgroundColor = "black";
		if (BG.runtimeStyle) BG.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=90)"; // IE
		else BG.style.opacity = "0.9";
		DIV.appendChild(BG);
		
		if (IE6) BG.style.width = document.documentElement.clientWidth; 
		
		// viewport
		var IFR = document.createElement('IFRAME');
		IFR.style.position = 'absolute';
		IFR.style.top = '50px'; IFR.style.left = '50px'; 
		IFR.style.border = 'solid 1px #777';
		IFR.src = popUrl;
		DIV.appendChild(IFR);
		
		// close button
		var CLR = document.createElement('SPAN');
		CLR.style.color = 'white';
		CLR.innerHTML = 'sluiten X';
		CLR.style.fontSize = '11px';	
		CLR.style.position = 'absolute';
		CLR.style.cursor = 'pointer';
		CLR.style.right = '50px'; CLR.style.top = '30px';
		DIV.appendChild(CLR);

		// caption
		var CAP = document.createElement('SPAN');
		CAP.style.fontSize = '11px';	
		CAP.style.display = 'block';
		CAP.style.height = '20px';
		CAP.style.color = 'white';
		CAP.style.overflow = 'hidden';
		CAP.innerHTML = unescape(text);
		CAP.style.position = 'absolute';
		CAP.style.left = '50px'; CAP.style.top = '30px';

		CLR.onclick = function() { closePop() }
		DIV.appendChild(CAP);
		
		setSizes();

		// recalc on resize
		window.onresize = function(e) {
			setSizes();
		}
	}	
	
	function setSizes() {

		IFR.style.width = DIV.clientWidth - 100 + "px"; 
		IFR.style.height = DIV.clientHeight - 100 + "px"; 
		CAP.style.maxWidth = DIV.clientWidth - 250 + "px"; 
	}
	
	function closePop() {
		// empty iFrame to force reloading on next call
		IFR.src='';
		document.body.removeChild(DIV);
		// restore documents scrollbar property for IE6
		if (IE6) document.documentElement.style.overflow = oldOverflow;
	}
	
}

