/*
<BETA Version 1.3b, secondconstruction.com>
Instructions:
1. Include only at the bottom of the the <body>.
2. use this link to display.
	javascript:showPopper([HEIGHT of the window],[WIDTH of the window],[FILE PATH (html, asp, php)]);
3. optional:to close display.(Default: click on the black screen to close)
	javascript:hidePopper();
*/
var publicContentHeight=0;
var publicContentWidth=0;
IE=document.all?1:0;
n=document.layers?1:0;
ns6=document.getElementById&&!document.all?1:0;
var docBody=document.getElementsByTagName('body')[0];

var bodyHeight=0;
if(document.body.scrollHeight<document.documentElement.clientHeight)
	bodyHeight = document.documentElement.clientHeight+10;
else
	bodyHeight = document.body.scrollHeight+20;
var bodyWidth=document.body.scrollWidth;

var divBackdrop = document.createElement('div');
divBackdrop.style.cssText='position:absolute; display:none; top:-10px; left:0; width:' + bodyWidth + 'px; height:'+ eval(bodyHeight + 10) +'px; _height:'+ bodyHeight +'px; background:#000000; -moz-opacity:.50; filter:alpha(opacity=50); cursor:pointer;';
docBody.appendChild(divBackdrop);

var divContent = document.createElement('div');
var iframeContent = document.createElement('iframe');
divContent.style.cssText='position:absolute; background-color:#EEEEEE; display:none; left:0px; top:0px; height:1px; width:1px;';
iframeContent.frameBorder='0';
iframeContent.scrolling='auto';
divContent.appendChild(iframeContent);
docBody.appendChild(divContent);

function scrollAdjust(){
	var viewWidth = eval((document.documentElement.clientWidth-publicContentWidth)/2);
	var viewHeight = eval((document.documentElement.clientHeight-publicContentHeight)/2);
	
    if (!document.documentElement.scrollTop){
       scrollY = document.body.scrollTop;
	}else{
       scrollY = document.documentElement.scrollTop;
	}
	if (n||ns6){
		divContent.style.top = eval(viewHeight+window.scrollY)+"px";
		divContent.style.left = eval(viewWidth+document.documentElement.scrollLeft)+"px";
	}else if (IE){
		divContent.style.top = eval(viewHeight+scrollY)+"px";
		divContent.style.left = eval(viewWidth+document.documentElement.scrollLeft)+"px";
	}
}

window.onresize=function(){
	if(document.body.scrollHeight<document.documentElement.clientHeight)
		bodyHeight = document.documentElement.clientHeight+10;
	else
		bodyHeight = document.body.scrollHeight+20;
	divBackdrop.style.height = bodyHeight + 'px';
	resbodyWidth=document.documentElement.offsetWidth;
	divBackdrop.style.width = resbodyWidth + 'px';
	scrollAdjust();
};
window.onscroll=function(){
	resbodyWidth=document.documentElement.scrollWidth;
	divBackdrop.style.width = resbodyWidth + 'px';
	divBackdrop.style.left='0px';
	scrollAdjust();
};

function showPopper(cHeight, cWidth,cPath){
	allInputDisplay('hidden');
	divContent.style.height=cHeight+'px';
	divContent.style.width=cWidth+'px';
	iframeContent.style.height=cHeight+'px';
	iframeContent.style.width=cWidth+'px';
	iframeContent.contentWindow.location.replace(cPath);
	publicContentHeight=cHeight;
	publicContentWidth=cWidth;

	resbodyWidth=document.documentElement.scrollWidth;
	divBackdrop.style.width = resbodyWidth + 'px';
	if(!IE)	divBackdrop.style.left = document.documentElement.scrollLeft + 'px';
	scrollAdjust();
	
	divBackdrop.style.display='block';
	divContent.style.display='block';
}
function hidePopper(){
	allInputDisplay('visible');
	divBackdrop.style.display='none';
	divContent.style.display='none';
	iframeContent.contentWindow.location.replace("about:blank");
}
function allInputDisplay(status){
	if(IE){
		for(i=0; i<document.getElementsByTagName('input').length;i++)
			document.getElementsByTagName('input')[i].style.visibility = status;
		
		for(i=0; i<document.getElementsByTagName('select').length;i++)
			document.getElementsByTagName('select')[i].style.visibility = status;
	}
}

divBackdrop.onclick = function(){
	hidePopper();
};
