<!--

var newWin = null;
var winname = null;

var docWin = null;
var docwinname = null;

var currentX = 0;
var currentY = 0;
var xOffset = 20;
var yOffset = 20;

var wtoolbar = "no";
var wmenubar = "no";
var wlocation = "no";
var wdirectories = "no";
var wstatus = "no";
var wscrollbars = "yes";
var wresizable = "yes";
var wcopyhistory = "no";

var lastPopupIsRemote = false;
var currentlyRemote = false;

function setPosition(winSize, newSize, axis)
{
	pos = winSize;
	parentPos = 0;
	if (winSize == -1)
	{
		//Center on screen.
		if (axis == 'horiz')
		{
			//Get the screen width.
			screenSize = screen.width;
		}
		else
		{
			//Get the screen height.
			screenSize = screen.height;
		}
		//Calculate the center and return the value.
		pos = Math.round((screenSize / 2) - (newSize / 2));
	}
	else
	{
		if (winSize == -2)
		{
			//Center within the parent window.
			if (axis == 'horiz')
			{
				//Get the parent window width.
				if (document.all)
				{
					//IE.
					parentSize = document.body.clientWidth;
					parentPos = window.screenLeft;
				}
				else
				{
					parentSize = window.outerWidth;
					parentPos = window.screenX;
				}
			}
			else
			{
				//Get the parent window height.
				if (document.all)
				{
					//IE.
					parentSize = document.body.clientHeight;
					parentPos = window.screenTop;
				}
				else
				{
					parentSize = window.outerHeight;
					parentPos = window.screenY;
				}
			}
			//Calculate the center and return the value.
			pos = parentPos + Math.round((parentSize / 2) - (newSize / 2));
		}
	}
	//alert("Original position = " + winSize + "\nParent position = " + parentPos + "\nNew position = " + pos);
	return pos
}

function setSize(winSize, direction, type)
{
	//Default to return the original value.
	parentSize = 1;
	if (winSize > 0 && winSize < 1)
	{
		//Use this value as a percentage of the parent window.
		if (direction == 'height')
		{
			//Get the parent window height.
			if (document.all)
			{
				//IE.
				parentSize = document.body.clientHeight;
			}
			else
			{
				parentSize = window.innerHeight;
			}
		}
		else
		{
			//Get the parent window width.
			if (document.all)
			{
				//IE.
				parentSize = document.body.clientWidth;
			}
			else
			{
				parentSize = window.innerWidth;
			}
		}
	}
	//Calculate the new size and return the value.
	wsize = Math.abs(parentSize * winSize);
	//alert("Original size = " + winSize + "\nParent size = " + parentSize + "\nNew size = " + wsize);
	return wsize;
}

function newWindow(jmppage, wname, h, w, x, y)
{
	//See if the new window size needs to be adjusted.
	w = setSize(w, 'width');
	h = setSize(h, 'height');
	
	//See if the new window location needs to be adjusted.
	//Size matters.  Pass the new size across in case the 
	//  new location will be based on the size.
	x = setPosition(x, w, 'horiz');
	y = setPosition(y, h, 'vert');

	// See if window reference is already set.  It will still be set
	// even if the user closes the window manually.
	if (newWin != null)
	{
		// See if we are trying to open the same window or a new one or 
		// if window has been closed.
		if ((winname != wname) || (newWin.closed))
		{
			// New window or old window has been closed.  Close the old one first.
			closeNewWin();
			openNewWin(jmppage, wname, h, w, x, y);
		}
		else
		{
			// Trying to open the same window.  Bring it to the front.
			newWin.focus()
		}
	}
	else
	{
		// Brand new window.
		openNewWin(jmppage, wname, h, w, x, y);
	}

	// Save the current window position.
	currentX = x;
	currentY = y;
}

function openNewWin(jumpref, wname, hsize, wsize, xpos, ypos)
{
	//Build the new window property string.
	winString = "toolbar=" + wtoolbar;
	winString += ",menubar=" + wmenubar;
	winString += ",location=" + wlocation;
	winString += ",directories=" + wdirectories;
	winString += ",status=" + wstatus;
	winString += ",scrollbars=" + wscrollbars;
	winString += ",resizable=" + wresizable;
	winString += ",copyhistory=" + wcopyhistory;
	winString += ",width=" + wsize;
	winString += ",height=" + hsize;
	
	if (navigator.appName.indexOf("Microsoft")>=0) 
	{
		winString += ',left=' + xpos + ',top=' + ypos + ''
	}
	else
	{
		winString += ',screenX=' + xpos + ',screenY=' + ypos + ''
	}
   
	newWin = window.open(jumpref, wname, winString);

	// Special code to check for PDF file in IE (still thinks its IE3).
	if ((document.all) && (jumpref.indexOf(".pdf") != -1))
	{
		// Need to open the window a second time with no URL.
		newWin = window.open("", wname, winString);
	}

	// Hold onto the current window name.
	winname = wname
}

function closeNewWin()
{
	// See if window reference is already set.  Only close an open window.
	if (newWin != null)
	{
		// alert("pdfFlag = " + pdfFlag)
		// See if window is closed.  Only close an open window.
		if (newWin.closed == false)
		{
			// Close the window.
			newWin.close();
		}
		else
		{
			//The window is already closed.
			//alert("Window already closed.");
		}
 
		// Clear the current window name.
		winname = null;
	}
}

function docWindow(jmppage, wname, h, w, x, y)
{
	currentlyRemote = false;
	
	//See if the new window size needs to be adjusted.
	w = setSize(w, 'width');
	h = setSize(h, 'height');
	
	//See if the new window location needs to be adjusted.
	//Size matters.  Pass the new size across in case the 
	//  new location will be based on the size.
	x = setPosition(x, w, 'horiz');
	y = setPosition(y, h, 'vert');
	
	// Offset this window from the more popup.
	x = x + xOffset;
	y = y + yOffset;
	
	if (jmppage.indexOf("content/downloads/") != -1 && jmppage.indexOf("http://") != -1) {
		jmppage = jmppage.substring(jmppage.indexOf("http://"),jmppage.length);
		// this page is remote, so IE security will prevent opening files on local domain
		currentlyRemote = true;
	}

	// See if window reference is already set.  It will still be set
	// even if the user closes the window manually.
	if (docWin != null)
	{

		// See if we are trying to open the same window or a new one or 
		// if window has been closed.
		if ((docwinname != wname) || (docWin.closed))
		{
			// New window or old window has been closed.  Close the old one first.
			closeDocWin();
			openDocWin(jmppage, wname, h, w, x, y);
		}
		else
		{
			
			if (lastPopupIsRemote && !currentlyRemote) {
				
				// last popup was on a different domain.  For IE you must close the window
				lastPopupIsRemote = false;
				closeDocWin();
				openDocWin(jmppage, wname, h, w, x, y);
				
			} else {
				// Trying to open the same window.  Bring it to the front.
				docWin.focus();
				docWin.document.location = jmppage;
				
			}
		}
	}
	else
	{
		// Brand new window.
		openDocWin(jmppage, wname, h, w, x, y);
	}

	currentX = x;
	currentY = y;
	
	if (currentlyRemote) {
		lastPopupIsRemote = true;
	}
	
}

function openDocWin(jumpref, wname, hsize, wsize, xpos, ypos)
{
	//Build the new window property string.
	winString = "toolbar=" + wtoolbar;
	winString += ",menubar=" + wmenubar;
	winString += ",location=" + wlocation;
	winString += ",directories=" + wdirectories;
	winString += ",status=" + wstatus;
	winString += ",scrollbars=" + wscrollbars;
	winString += ",resizable=" + wresizable;
	winString += ",copyhistory=" + wcopyhistory;
	winString += ",width=" + wsize;
	winString += ",height=" + hsize;
	
	if (navigator.appName.indexOf("Microsoft")>=0) 
	{
		winString += ',left=' + xpos + ',top=' + ypos + ''
	}
	else
	{
		winString += ',screenX=' + xpos + ',screenY=' + ypos + ''
	}
   
	docWin = window.open(jumpref, wname, winString);

	// Special code to check for PDF file in IE (still thinks its IE3).
	if ((document.all) && (jumpref.indexOf(".pdf") != -1))
	{
		// Need to open the window a second time with no URL.
		docWin = window.open("", wname, winString);
	}

	// Hold onto the current window name.
	docwinname = wname;
}

function closeDocWin()
{
	// See if window reference is already set.  Only close an open window.
	if (docWin != null)
	{
		// alert("pdfFlag = " + pdfFlag)
		// See if window is closed.  Only close an open window.
		if (docWin.closed == false)
		{
			// Close the window.
			docWin.close();
		}
		else
		{
			//The window is already closed.
			//alert("Window already closed.")
		}
 
		// Clear the current window name.
		docwinname = null
	}
}

// -->

