<!--
// by Nannette Thacker
// http://www.shiningstar.net
// This script allows you to display a popup that does not pop
// off the edge of the screen if the link is toward the edge
// If the link sits on the edge of the screen, the popup will
// pop the other direction
// also allows a popcenter in the middle of the screen
// Modified Dec 2006 by Richard White to work with current browsers
// Modified Aug 2007 by Richard White to add scrollbar and resizable options
// -->

var popupHandle;
function closePopup() {
if(popupHandle != null && !popupHandle.closed) popupHandle.close()
}

function displayPopup(position,url,name,height,width,evnt,scrollbars,resizable)
{

// position=1 POPUP: makes screen display up and/or left,
//    down and/or right
// depending on where cursor falls and size of window to open
// position=2 CENTER: makes screen fall in center

var properties = "toolbar=0,status=0,location=0,height="+height
properties = properties+",width="+width

if(scrollbars != null)
{
properties = properties+",scrollbars="+scrollbars
}

if(resizable != null)
{
properties = properties+",resizable="+resizable
}

var leftprop, topprop, screensizeX, screensizeY, cursorX, cursorY, padAmt

	screensizeY = window.screen.availHeight
	screensizeX = window.screen.availWidth

if(position == 1)	// if POPUP not CENTER
{
	cursorX = evnt.screenX
	cursorY = evnt.screenY
	padAmtX = 10
	padAmtY = 10
	
	if((cursorY + height + padAmtY) > screensizeY)	
	// make sizes a negative number to move left/up
	{
		padAmtY = (-30) + (height*-1);	
		// if up or to left, make 30 as padding amount
	}
	if((cursorX + width + padAmtX) > screensizeX)
	{
		padAmtX = (-30) + (width*-1);	
		// if up or to left, make 30 as padding amount
	}

	leftprop = cursorX + padAmtX
	topprop = cursorY + padAmtY

}
else	// CENTER
{
	leftprop = (screensizeX - width) / 2
	topprop = (screensizeY - height) / 2
}

if(evnt != null)
{
properties = properties+",left="+leftprop
properties = properties+",top="+topprop
}
closePopup()
popupHandle = open(url,name,properties)
}

//-->