// JavaScript Document

function Popup( key, value, image, name, attr )
{
	this.linkItem = new Link( key, value, image, null );
	this.name = name;
	this.h = PopupH;
	this.w = PopupW;
	this.attr = attr;
}

Popup.prototype.setMap = function( map )
{
	this.linkItem.setMap( map );
}

Popup.prototype.show = function()
{
	this.linkItem.setAction( "doPopup(this.href,'" + this.name + "'," + 
		this.h + "," + this.w + ",'" + this.attr + "')" );
	
	document.write( this.linkItem.toMarkup( false, true ) );
}

function doPopup( url, name, h, w, attr )
{
	var props = "scrollbars,menubar,resizable,status,titlebar,toolbar";

	switch ( attr )
	{
	case "dialog":
		props = "scrollbars,resizable,status";
		break;
	case "modal":
		props = "scrollbars";
		break;
	default:
		break;
	}
	
	if ( h != undefined )
	{
		// allow for taskbar, chrome
		var y = ( window.screen.height - 32 )/2 - ( h + 50 )/2;
		props += ",height=" + h + ",top=" + y + ",screenY=" + y
	}
	
	if ( w != undefined )
	{
		var x = window.screen.width/2 - w/2;
		props += ",width=" + w + ",left=" + x + ",screenX=" + x
	}

	var nw = window.open( url, name, props );
	if ( nw == null )
	{
		alert( "Could not open new window.  If you have a popup blocker, try disabling it for this site" )
		return false;
	}
	
	if ( window.focus ) { nw.focus(); }
	return false;
}
