﻿function popupLayer(s,w,h,id,page,kind,refresh,nr)
{
	if (!w) w = 600;
	if (!h) h = 400;
    if (!nr) nr = "0";

var scrollPos; 
if (typeof window.pageYOffset != 'undefined') { 
   scrollPos = window.pageYOffset; 
} 
else if (typeof document.compatMode != 'undefined' && 
     document.compatMode != 'BackCompat') { 
   scrollPos = document.documentElement.scrollTop; 
} 
else if (typeof document.body != 'undefined') { 
   scrollPos = document.body.scrollTop; 
} 

	var pixelBorder = 3;
	var titleHeight = 12;
	w += pixelBorder * 2;
	h += pixelBorder * 2 + titleHeight;

	var bodyW = document.body.clientWidth;
	var bodyH = document.body.clientHeight;

	var posX = (bodyW - w) / 2;
	var posY = (bodyH - h) / 2;

	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = 0;
		top = 0;
        width = document.body.scrollWidth;
		height = document.body.scrollHeight;
		backgroundColor = "#cbcbcb";
		filter = "Alpha(Opacity=50)";
		opacity = "0.5";
	}
	obj.id = "objPopupLayerBg";
	document.body.appendChild(obj);

	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = posX + document.body.scrollLeft;
		top = posY + document.body.scrollTop;
        top=200;
        top=posY/2 + scrollPos;
		width = w;
		height = h;
		backgroundColor = "#ffffff";
		border = "3px solid #CBCBCB";
		zIndex=2;
	}
	obj.id = "objPopupLayer";
	document.body.appendChild(obj);

    var bottom = document.createElement("div");
	with (bottom.style){
		position = "absolute";
		width = w - pixelBorder * 2;
		height = 18;
		left = 0;
		top = h - titleHeight - pixelBorder * 3;
		padding = "0px 0 0 0";
		textAlign = "right";
		backgroundColor = "#EbEBEB";
		color = "#ffffff";
		font = "bold 11px tahoma";
	}
	bottom.innerHTML = "<table width=30 height=18 align=right bgcolor='#50504F'><tr><td align=center onclick='javascript:closeLayeronly();' style='cursor:pointer'><font  color='#ffffff'>X</font></td></tr></table>";
	obj.appendChild(bottom);


	var ifrm = document.createElement("iframe");
	with (ifrm.style){
		width = w;
		height = h - pixelBorder * 2 - titleHeight - 3;
	}
	ifrm.frameBorder = 0;
	ifrm.src = s;
             ifrm.marginwidth="0";
	obj.appendChild(ifrm);

}

function closeLayer(id,page,kind,refresh,nr) {
		_ID('objPopupLayer').parentNode.removeChild( _ID('objPopupLayer') );
		_ID('objPopupLayerBg').parentNode.removeChild( _ID('objPopupLayerBg') );
       if (refresh==1 && nr!='')parent.document.forms[nr].submit();
       if (refresh==1 && nr=='')parent.document.location.reload();
}
function closeLayeronly() {
		_ID('objPopupLayer').parentNode.removeChild( _ID('objPopupLayer') );
		_ID('objPopupLayerBg').parentNode.removeChild( _ID('objPopupLayerBg') );
}


function _ID(obj){return document.getElementById(obj)}
