var popupContainer, popupContainerContentNode, closeButton, closeButtonImg, popupContainerCaptionBar;

function showPopupContainer(show, x, y, w, h, contentNode)
{
    var div=document.getElementById("page_disabled");

    if (!popupContainer)
    {
	popupContainer=document.createElement("div");
	popupContainer.style.position="absolute";
	//popupContainer.style.backgroundColor="#ffffff";
	//popupContainer.style.border="1px red solid";
	popupContainer.style.paddingTop="40px";
	
	popupContainerCaptionBar=document.createElement("div");
	popupContainerCaptionBar.style.height="40px";
	popupContainerCaptionBar.style.position="absolute";
	popupContainerCaptionBar.style.top="0px";
	popupContainerCaptionBar.style.left="0px";
	popupContainerCaptionBar.style.width="100%";
	popupContainerCaptionBar.style.borderBottom="1px #c9c9c9 solid";
	popupContainerCaptionBar.style.backgroundColor="#e4e4e4";
	popupContainerCaptionBar.innerHTML="&nbsp;";
	
	closeButton=document.createElement("a");
	closeButton.style.position="absolute";
	closeButton.style.display="block";
	closeButton.style.width="20px";
	closeButton.style.height="20px";
	//closeButton.style.border="1px red solid";
	closeButton.style.top ="10px";
	closeButton.style.right="10px";
	closeButton.style.cursor="pointer";
	closeButton.onclick=new Function ("evt", "showPopupContainer(false); return false;");
	
	closeButtonImg=new Image();
	closeButtonImg.src="/img/buttons/close_x_button.gif";
	    
	closeButton.appendChild(closeButtonImg);
	
	popupContainer.appendChild(popupContainerCaptionBar);
	popupContainerCaptionBar.appendChild(closeButton);
	
	if (navigator.userAgent.toLowerCase().indexOf("msie 6")==-1)
	{
	    div.style.position="fixed";
	}
	else
	{
	    div.style.position="absolute";
	}
	
	div.appendChild(popupContainer);
    
    }

    if(show)
    {
	if(popupContainerContentNode)
	{
	    popupContainer.removeChild(popupContainerContentNode);
	    popupContainerContentNode=null;	
	}
	contentNode.style.display="none";
	popupContainerContentNode=contentNode.cloneNode(true);
	popupContainerContentNode.style.display="block";
	popupContainer.appendChild(popupContainerContentNode);
	
	div.style.display="block";
	//popupContainer.style.display="block";
	popupContainer.style.top=y+"px";
	popupContainer.style.left=x+"px";
	//popupContainer.style.width=w+"px";
	//popupContainerCaptionBar.style.width=w+"px";
	//alert(popupContainer.style.width);
	popupContainer.style.height=h+"px";
    }
    else
    {
	div.style.display="none";
	//popupContainer.style.display="none";
    }
}
function onClickSampleCertificate(link, width, height)
{
	var div, imgs, img, ch, cw;
	
	div=document.getElementById("page_disabled");
	
	ch= window.innerHeight || document.documentElement.clientHeight;
	cw= window.innerWidth || document.documentElement.clientWidth;
		
	
	div.style.height=(ch>document.body.offsetHeight?ch:document.body.offsetHeight)+"px";
	imgs=div.getElementsByTagName("img");
	img=imgs[0];
	
	showPopupContainer(true, parseInt((cw-width)/2), parseInt((ch-height)/2), width, height, img );
    
	return;
	if (navigator.userAgent.toLowerCase().indexOf("msie 6")==-1)
	{
		img.style.position="fixed";	
		div.style.display="block";
		img.style.top=parseInt((ch-img.height)/2)+"px";
		img.style.left=parseInt((cw-img.width)/2)+"px";
		
	}
	else
	{	
		var yScroll = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
		div.style.display="block";
	   	img.style.marginTop=yScroll+parseInt((ch-img.height)/2)+"px";
	}

}
function popupIFrame(link, width, height)
{
	
	var url, div, iframes, iframe, ch, cw;
	
	url=link.href;
		
	div=document.getElementById("page_disabled");
	
	ch= window.innerHeight || document.documentElement.clientHeight;
	cw= window.innerWidth || document.documentElement.clientWidth;
	
	div.style.height=(ch>document.body.offsetHeight?ch:document.body.offsetHeight)+"px";
	iframes=div.getElementsByTagName("iframe");
	iframe=iframes[0];
	iframe.contentWindow.document.body.innerHTML="";
	iframe.src=url;
	if (width)
	{
	    iframe.style.width=width+"px";
	}
	if (height)
	{
	    iframe.style.height=height+"px";
	}

	showPopupContainer(true, parseInt((cw-parseInt(iframe.style.width))/2), parseInt((ch-parseInt(iframe.style.height))/2), iframe.width, iframe.height, iframe );
	return;
		if (navigator.userAgent.toLowerCase().indexOf("msie 6")==-1)
	{
		cw= window.innerWidth || document.documentElement.clientWidth;
		iframe.style.position="fixed";
		div.style.display="block";
		iframe.style.top=parseInt((ch-parseInt(iframe.style.height))/2)+"px";
		iframe.style.left=parseInt((cw-parseInt(iframe.style.width))/2)+"px";
		
	}
	else
	{	
		var yScroll = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
		div.style.display="block";
	   	iframe.style.marginTop=yScroll+parseInt((ch-parseInt(iframe.style.height))/2)+"px";
	}
}
