/*******************************************************************************
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;

//used for dialog functionality
maskInitialized = false;
leavingSiteInitialized = false;
pdfInitialized = false;
windowResizeSet = false;
currentDialog = null; //used for dynamic dialog tracking
dialogEnabled = false;
dailogType = 0;
externalURL = "";
linkTarget = 0;
//-- global variables and functionality end ------------------------------------

//------------------------------------------------------------------------------
// NEW BROWSER WINDOW FUNCTIONS BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- creates a new 3/4 browser window for links to other websites throughout site
function openExternalWin(argURL) {
 if(argURL != null || argURL != "")
 {
  externalWin = window.open(argURL, null, 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=500');
  if(externalWin != null) externalWin.focus();
 }
 else alert("Error: Missing URL parameter");
}

//FUNCTION-- creates a popup window for pdfs
function newPDFWin(argURL) {
 if(!gBrowser.isMac) //if its not a Mac
 {
	popupWinFeatures = "directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no";
  window.open(argURL,"",popupWinFeatures);
 }
 else window.location.href = url; //mac fix for OS X
}

//FUNCTION-- creates a new window for footer global content
function globalWin(url) {
 if(url != null || url != "")
 {
	var showToolBar = 0;
	if(gBrowser.ie && gBrowser.majorVersion > 6) showToolBar=1;
  globalWin1 = window.open(url,'','directories=no,location=no,menubar=yes,resizable=yes,scrollbars=yes,status=no,titlebar=yes,width=650,height=325,toolbar='+showToolBar);
  if(globalWin1 != null) globalWin1.focus( );
 }
}

//FUNCTION-- determines the target for loading a new href
function doLink() {
 switch(linkTarget)
 {
  case 1:
   linkTarget = 0;
   window.location.href = externalURL; //load into same window
   break;
  default:
   linkTarget = 0;
   openExternalWin(externalURL); //load into popup window
 }
}

//------------------------------------------------------------------------------
// NEW BROWSER WINDOW FUNCTIONS END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// DIALOG AND MASKING BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- moves dialog off screen
function moveOffScreen() {
 currentDialog.m_moveTo(0, -1000);
}

//FUNCTION-- sets dialog
function setDialog() {
 if(dialogEnabled) 
 {
  if(dailogType == 1)
  {
   mask01.objCss.height = 50;
   mask01.objCss.width = 50;
   mask01.m_setMask();
   pdfMessage.m_updateHeight();
   pdfMessage.m_positionObj(false);
  }
  else if(dailogType == 2)
  {
   mask01.objCss.height = 50;
   mask01.objCss.width = 50;
   mask01.m_setMask();
   leavingSite.m_updateHeight();
   leavingSite.m_positionObj(false);
  }
  else {alert("Error: dailogType undefined");}
 }
}

//FUNCTION-- clears dialog and Mask
function clearDialogMask() {
 dialogEnabled = false;
 moveOffScreen();
 if(dailogType == 1) {mask01.m_setDisplay(2);}
 else if(dailogType == 2) {mask01.m_setDisplay(2);}
 else {alert("Error: dailogType undefined");}
}

//FUNCTION-- clears dialog only and retains mask (used when swapping mutliple dialogs when mask is visible)
function clearDialog() {
 dialogEnabled = false;
 moveOffScreen();
}

//------------------------------------------------------------------------------
// DIALOG AND MASKING END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// PDF MESSAGE BEGIN
//------------------------------------------------------------------------------

function setPDFMessage(formObj) {
 if(formObj.checked) setCookie("me", 1, 183);
 else deleteCookie("me");
}

function isPDFMessage() {
 if(getCookie("me")) return true;
 else return false;
}

//------------------------------------------------------------------------------
// PDF MESSAGE END
//------------------------------------------------------------------------------

//---END