﻿var _currentPopUp = null;

function SetBlanketSize() 
{
	if (_currentPopUp == null) return;

	if (typeof window.innerWidth != 'undefined') 
	{
		viewportheight = window.innerHeight;
	} 
	else 
	{
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) 
	{
		blanket_height = viewportheight;
	} 
	else 
	{
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		}
		else 
		{
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('PopUpBlanket');
	blanket.style.height = blanket_height + 'px';
	//var popUpDiv = document.getElementById(popUpDivVar);

	var browserX = 0;
	var browserY = 0;
	if (document.documentElement && document.documentElement.clientWidth)
	{
		browserX = document.documentElement.clientWidth;
		browserY = document.documentElement.clientHeight;
	}
	else if (document.body && document.body.clientWidth)
	{
		browserX = document.body.clientWidth;
		browserY = document.body.clientHeight;
	}
	else
	{
		browserX = window.innerWidth;
		browserY = window.innerHeight;
	}

	popUpDiv_X = browserX / 2 - ((870+15*2)/2); // popup's width
	popUpDiv_Y = browserY / 2 - ((400+15*2+15)/2); // popup's height

	_currentPopUp.style.left = popUpDiv_X + 'px';
	_currentPopUp.style.top = popUpDiv_Y + 'px';
}

function ShowPopUp(windowname)
{
	_currentPopUp = document.getElementById(windowname);

	SetBlanketSize(windowname);
	document.getElementById('PopUpBlanket').style.display = 'block';
	_currentPopUp.style.display = 'block';
}

function HidePopUp()
{
	_currentPopUp.style.display = 'none';
	document.getElementById('PopUpBlanket').style.display = 'none';
	_currentPopUp = null;
}

function ShowPopUpIFrame(WindowName, Url) 
{
	var content = document.getElementById(WindowName + 'Content');
	content.innerHTML = '<iframe src="' + Url + '" width="870px" height="400px" frameborder="0" border="0"></iframe>';

	ShowPopUp(WindowName);
}

Event.observe(window, 'resize', SetBlanketSize);

