
function popupWindow(winLoc, winSettings)  {
	 // This function must be run using JavaScript1.1.
	 // Set the windows Features value for the Popup.

	if (arguments.length == 2) 	{
		var sPopupSettings = winSettings;
	}
	else	{
		var sPopupSettings = getDefaultPopupSettings(2);
		// Set the name of this browser window before loading the popup browser window.(JS1.1)
		window.name = 'AMA_Main'; 
		// Open the popup screen.(JS1.0)		
		popupWindows = window.open(winLoc, 'AMA_Popup', sPopupSettings);
	}
	// Check if the popup Window was opened. If it was make sure it has focus.
	if (popupWindows != null)	{
		popupWindows.focus();
	}
	return popupWindows;
}
  
function popupPackage(winLoc, winSettings)  {
	// Location where to put the top left corner of the Popup window.
	// From the left side of the screen.
	var popupLeft = 50; 
	// From the top of the screen.
	var popupTop = 40; 
	var popupSettings = 
	"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=600,width=500,screenY="+popupTop+",screenX="+popupLeft+
	      ",top="+popupTop+",left="+popupLeft;
	 // Set the name of this browser window before loading the popup browser window.(JS1.1)
	 window.name = 'AMA_Main'; 
	 // Open the popup screen. (JS1.0)
	 popupWindows = window.open(winLoc, 'Package_Popup', popupSettings); 
	 // Check if the popup Window was opened. If it was make sure it has focus.
	 if (popupWindows != null)  {
	  popupWindows.focus();
	 }
	 return popupWindows;
}
 
 function popupGlossary(winLoc, winSettings)  {
	 // Location where to put the top left corner of the Popup window.
	 // From the left side of the screen.
	 var popupLeft = 250; 
	 // From the top of the screen.
	 var popupTop = 300; 
	 var popupSettings = 
	 "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=200,width=350,screenY="+popupTop+",screenX="+popupLeft+
	      ",top="+popupTop+",left="+popupLeft;
	 // Set the name of this browser window before loading the popup browser window.(JS1.1)
	 window.name = 'AMA_Main'; 
	 // Open the popup screen. (JS1.0)
	 popupWindows = window.open(winLoc, 'Glossary_Popup', popupSettings);
	 // Check if the popup Window was opened. If it was make sure it has focus.
	 if (popupWindows != null)  {
	  popupWindows.focus();
	 }
	 return popupWindows;
}

function popupNoURL(winLoc, winSettings)	{
  // -------------------------------------------------------------
  // This function must be run using JavaScript1.1.
  // Set the windows Features value for the Popup.(JS1.1)
  if (arguments.length == 2) 	{
    var sPopupSettings = winSettings;
  }
  else	{
    var sPopupSettings = getDefaultPopupSettings(2);
  }
  // Set the name of this browser window before loading the popup browser window.(JS1.1)
  window.name = 'AMA_Main'; 
 
  // Open the popup screen. (JS1.0)
  popupWindow = window.open(winLoc, 'NoURL_Popup', sPopupSettings); 
  
  // Check if the popup Window was opened. If it was make sure it has focus.
  if (popupWindow != null)	{
    popupWindow.focus();
  }
  return popupWindow;
} 
  
function getDefaultPopupSettings(winFeatures)	  {
  // This fucnction must be run using JavaScript1.2.
  //  This is used to pass the navigation size to use.
  
  // GET THE BROWSER TYPE AND VERSION:
  // Convert all characters to lowercase to simplify testing
  var agt=navigator.userAgent.toLowerCase();
  var is_ie   = (agt.indexOf("msie") != -1);
  
  // Adjust the popup page height by this number.
  // This is to allow for Menus, address bars, etc...
  // Default IE vs Netscape  
  var adjHeight = (is_ie ? 78 : 50);
  
  // Build the window Features String to be returned and browser popup height ajustment.
  switch (winFeatures)	   {
    case 1 :
      var sPopupSettings = 
        "toolbar=yes,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes";
      // Add the Size of the Toolbar and Location.
      adjHeight += (is_ie ? 66 : 67);
      break;
	case 2 :
	  var sPopupSettings = 
	    "toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes";
	  // Add the Size of the Toolbar and Location.
	  adjHeight += (is_ie ? 66 : 67);
	  break;
	case 3 :
	  var sPopupSettings =
	  popupParameters = "toolbar=yes,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=815,screenY=50,screenX=50,top=50,left=50";
	  break;
    default :
      var sPopupSettings = 
        "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes";
    }
  
  // Get the Screen Width (JS1.2)
  // Width less borders. (JS1.2)
  var pageWidth = (screen.availWidth - 10);
  // Get the Screen Height
  // Height less borders. (JS1.2)
  var pageHeight = (screen.availHeight - adjHeight); 
    
  // Location where to put the top left corner of the Popup window.
  // From the left side of the screen.
  var popupLeft = 25; 
  // From the top of the screen.
  var popupTop = 50; 
  
  // The Size of the popup window.
  // Popup Width.
  var popupWidth = (pageWidth - popupLeft); 
   // Popup Height
  var popupHeight = (pageHeight - popupTop);
  // Set the Popup size and locations values.
  sPopupSettings += ",screenY=" + popupTop + ",screenX=" + popupLeft +
      ",top=" + popupTop + ",left=" + popupLeft + 
      ",height=" + popupHeight + ",width=" + popupWidth;
  
  return sPopupSettings;
}


function targetParent(parentURL, close_window)	{
	// --------------------------------------------------------------------------------
	// Function: targetPartent(parentURL, close_window)
	// Description: This function will change the url of the parent that opened this
	//              popup window. It has a flag to close the window if set to true.
	// Parameters: partentURL - The URL to be loaded in the Parent window plane.
	//             close_window - boolean value:
	//                            true = close this window after loading the parent URL
	//                            false = do not close this window after loading the parent URL
	// --------------------------------------------------------------------------------

	// Check if this window that opened this popup has been closed.
	// If the opening window has been closed
	if (this.window.opener == null || this.window.opener.closed == true) 	{
	// window.alert('Opener window was closed - Opening new window.');
		NewWindow = window.open(parentURL,'AMA_Main');
		NewWindow.focus();
	}
	else 	{
	// If the opening window has not been closed.
	// window.alert('Opener window was not closed - Re-Using window.');
		this.opener.location = parentURL;
		this.opener.focus();
	}
	// Close the popup window if close_window=true.
	if ( close_window == true )	{
		window.top.close();
	}
	return;
}
