﻿// JScript File

function ShowPopup(url, width, height)
{
	var centWin = null;
	var w = 800;
	var h = 600;
	if (typeof(screen.availWidth) != 'undefined')
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var lPos = (w-width)/2
	var tPos = (h-height)/2;
	centWin=window.open(url,'Popup','toolbar=' +"no"+ ', directories=' + "no" + ',location=' + "no" + ', status=' + "no" + ',dependent=' + "yes" + ',scrollbars=' + "yes" + ',menubar=' + "no"+ ',resizable=' + "no" + ',copyhistory=' + "no" + ',width=' + width + ',height=' + height + ',left=' + lPos + ',top=' + tPos);
	centWin.window.focus();
}

var popup = null;
var popupDesc = null;
var popupImg = null;
function HidePopup()
{
	popup.style.display='none';
	popupImg.src = "";
}
function ShowImagePopup(width, height, imageUrl, description)
{
	var windowSize = new Object()
	GetWindowSize(windowSize);
	if(popup != null)
	{
		popup.style.display='none';
	}
	else
	{
		popup = document.createElement("div");
		popupDesc = document.createElement("div");
		var popupClose = document.createElement("div");	
		popupClose.style.cssText = "float:right;cursor:pointer;height:20px;font-family:Verdana;font-size:14px;padding-right:4px;padding-top:2px;";
		popupClose.innerHTML = "×";
		popupImg = document.createElement("img");
		popup.appendChild(popupDesc);
		popup.appendChild(popupClose);
		popup.appendChild(popupImg);
		document.body.appendChild(popup);
		addEvent(popup, "click", HidePopup, false);
	}

	popupDesc.innerHTML = description;
	popupDesc.style.cssText = "float:left;height:20px;font-family:Verdana;font-size:12px;font-weight:bold;padding-left:5px;padding-top:2px;";
	height+=22;	// For header.
	popupImg.src = imageUrl;
	var lPos = (windowSize.Width - width)/2
	var tPos = (windowSize.Height - height)/2;
	popup.style.cssText = "display:block;background-color:#f0f0f0;position:absolute;border:solid 1px black;z-index:100;width:" + width + "px;height:" + height + "px;left:" + lPos + "px;top:" + tPos + "px;";
}

function addEvent(obj, evType, fn, useCapture)
{
	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (obj.attachEvent)
	{
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else
	{
		alert("Handler could not be attached");
	}
}
function GetWindowSize(size)
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	size.Width = myWidth;
	size.Height = myHeight;
	//window.alert( 'Width = ' + myWidth );
	//window.alert( 'Height = ' + myHeight );
}