if ( document.documentElement )
    window.onresize = Resize;
else if ( document.all )
    window.onresize = Resize;
else
    window.addEventListener ( "resize", Resize, false );

	
function ClosePopup ( )
{
	var background = document.getElementById('background');
	if ( background )
		background.style.display = 'none';

	var container = document.getElementById('image-container');
	if ( container )
		container.style.display = 'none';
		
	var flash1 = document.getElementById('main1');
	if ( flash1 ) {
		flash1.style.visibility = 'visible';
		flash1.focus();
	}
	var flash2 = document.getElementById('main2');
	if ( flash2 ) {
		flash2.style.visibility = 'visibility';
		flash2.focus();
	}
}

function PopupImage ( src )
{
	Resize();
	
	var flash1 = document.getElementById('main1');
	if ( flash1 )
		flash1.style.visibility = 'hidden';
	var flash2 = document.getElementById('main2');
	if ( flash2 )
		flash1.style.visibility = 'hidden';

		var background = document.getElementById('background');
	background.style.display = 'block';

	var container = document.getElementById('image-container');
	container.innerHTML = '';
	container.style.display = 'block';
	
	var img = new Image();
	img.onload = function()
	{
		container.style.marginLeft = (-(img.width / 2) - 10) + "px";
		container.style.marginTop = (-(img.height / 2) - 10) + "px";
		container.onmousedown = function () { return false; }
		container.onmouseup = function() { return false; }
		container.appendChild(img);
	};
	img.src = src;
}

function Resize ( )
{
    var clientX, clientY;
    if (self.innerHeight)
    {
    	clientX = self.innerWidth;
    	clientY = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
    	clientX = document.documentElement.clientWidth;
    	clientY = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
    	clientX = document.body.clientWidth;
    	clientY = document.body.clientHeight;
    }
    
	var background = document.getElementById('background');
	background.style.width = clientX + "px";
	background.style.height = clientY + "px";
}
