// ************************************************************************<BR>
// DHTML functions for Viking's popup windows.								   <BR>
// ************************************************************************<BR>
// <SCRIPT>

function PopUp(url, name, x, y, width, height, resizable, child)
{
	this.url = url;
	this.name = name;
	this.x = x;
	this.y = y;
	this.resizable = resizable;
	this.child = child;
}

// Shows the popup
PopUp.prototype.show = function()
{
	if (this.x < 0)
		this.x = (window.screen.availWidth - this.width) / 2;
	if (this.x + this.width > screen.availWidth)
		this.x = screen.availWidth - this.width;

	if (this.y < 0)
		this.y = (window.screen.availHeight - this.height) / 2;
	if (this.y + this.height > screen.availHeight)
		this.y = screen.availHeight - this.height;

	var resize = (this.resizable == true ? "yes" : "no");
	var modeless = (this.child == true);

	if (window[this.name] && !window[this.name].closed)
		window[this.name].close();

	if (modeless && document.all)
		window[this.name] = window.showModelessDialog(this.url, window, "dialogLeft:" + this.x + "px;dialogTop:" + this.y + "px;dialogWidth:" + this.width + "px;dialogHeight:" + this.height + "px;help:no;status:no;center:no;scroll:" + resize + ";resizable:" + resize);
	else
		window[this.name] = window.open(this.url, this.name, "width=" + this.width + ",height=" + this.height + ",left=" + this.x + ",top=" + this.y + ",titlebar=no,resizable=" + resize + (modeless ? ",dependent" : ""));

	if (!window[this.name])
	{
		alert("Failed to display the popup window.\nPlease verify popups are enabled.");
		return null;
	}
		
	window[this.name].focus();
    return window[this.name];
}

// Retrieves the proper offset (X or Y) of the given object with respect to the body.
PopUp.prototype.getOffset = function(obj, bLeftOrTop)
{
	var result = (bLeftOrTop ? obj.offsetLeft : obj.offsetTop);

	while (obj != null && obj.offsetParent != null)
	{
		obj = obj.offsetParent;

		if (bLeftOrTop)
		{
			if (obj.offsetLeft)
				result += obj.offsetLeft;
		}
		else
		{
			if (obj.offsetTop)
				result += obj.offsetTop;
		}
	}

	return result;
}

function popup(url) 
{
	sealWin=window.open(url,'win','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = 'mainWin'; 
}
	
function popupfooter(url) 
{
	sealWin=window.open(url,'win','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=760,height=450');
	self.name = 'mainWin'; 
}

