/*******************************************************************************
FILE NAME    :global.js
DEPENDENCIES :browser.js
********************************************************************************
____________________________ API DOCUMENTATION BEGIN ___________________________
````````````````````````````````````````````````````````````````````````````````
Functions used throughout website.

````````````````````````````````````````````````````````````````````````````````
_____________________________ API DOCUMENTATION END ____________________________
*******************************************************************************/

//-- global variables and functionality begin ----------------------------------
pageLoaded = false; //set page loaded flag
homePage = false;
theURL = window.document.location.href;
if(top.location.href != self.location.href) top.location.href = self.location.href; //prevent unauthorized framing
//-- global variables and functionality end ------------------------------------

//------------------------------------------------------------------------------
// ROLLOVER FUNCTIONS BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- preload images
function preloadImage(virtualName, filePath, fileName) {
 eval(virtualName +' = new Image()'); //create a new image object
 eval(virtualName +'.src = "' + filePath + fileName + '"');
}

//FUNCTION-- dynamically swaps one image (also used for rollovers in layers for Netscape 4)
function swapImageSingle(imageName, imageState, imageLayer) {
 if(gBrowser.ns4 && imageLayer!=null) eval('document.' + imageLayer + '.document.images["'+ imageName +'"].src =' + imageName + imageState + ".src"); //path to nested layer for Netscape 4
 else document.images[imageName].src = eval(imageName + imageState + ".src");
}

//FUNCTION-- sets rollover highlight
function setRollover(imageId, imageFilePath, imageFileName) {
 preloadImage(imageId+"_off", imageFilePath, imageFileName);
 preloadImage(imageId+"_on", imageFilePath, imageFileName);
 swapImageSingle(imageId, '_on', null);
}

//------------------------------------------------------------------------------
// ROLLOVER FUNCTIONS END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// NEW BROWSER WINDOW FUNCTIONS BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- creates a new 3/4 browser window for links to other websites throughout site
function newWin(url) {
 if(url != null || url != "")
 {
  newWin1 = window.open(url,"nemb_newWin",'directories=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=yes,width=700,height=350');
  newWin1.focus( );
 }
}

if(gBrowser.isWin && gBrowser.ie) {pdfReaderInitialized = false;} //used for newPDFWin function

//FUNCTION-- creates a popup window for pdfs
function newPDFWin(url) {
 if(url != null || url != "")
 {
  if(!gBrowser.isMac) //if its not a Mac
  {
   popupWinName = "nemb_newPDFWin";
	 popupWinFeatures = "directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no,width=700,height=350";

	 if(gBrowser.ie)
	 {
		try
		{
		 if(!newPDFWin1.name) {} //check property existance
		} 
    catch (e)
		{
		 pdfReaderInitialized = false; //reset flag
		}  

	  if(pdfReaderInitialized)
	  {
		 newPDFWin1 = window.open("",popupWinName,popupWinFeatures);
		 newPDFWin1.close();
		 newPDFWin1 = window.open(url,popupWinName,popupWinFeatures);
	  }
	  else 
		{
		 newPDFWin1 = window.open(url,popupWinName,popupWinFeatures);
		 pdfReaderInitialized = true;
		}
	 }
	 else
	 {
	  newPDFWin1 = window.open(url,popupWinName,popupWinFeatures);
	  newPDFWin1.focus();
	 }
  }
  else window.location.href = url; //mac fix for OS X
 }
}

//------------------------------------------------------------------------------
// NEW BROWSER WINDOW FUNCTIONS END
//------------------------------------------------------------------------------

//FUNCTION-- enables linking to home page based on homePage flag
function goHome(url) {
 if(!homePage) window.location.href = url;
}

//---END