/*******************************************************************************
FILE NAME    :global.js
DEPENDENCIES :browser.js
********************************************************************************
____________________________ API DOCUMENTATION BEGIN ___________________________
````````````````````````````````````````````````````````````````````````````````
Functions used throughout website.

````````````````````````````````````````````````````````````````````````````````
_____________________________ API DOCUMENTATION END ____________________________
*******************************************************************************/

//-- global variables/functionality begin --------------------------------------
homePage = false; //set home page loaded flag
pageLoaded = false; //set page loaded flag
if(top.location.href != self.location.href) top.location.href = self.location.href; //prevent unauthorized framing
theURL = window.document.location.href;

//used for dialog functionality
maskInitialized = false;
pdfInitialized = false;
windowResizeSet = false;
currentDialog = null; //used for dynamic dialog tracking
dialogEnabled = false;
dailogType = 0;
pdfURL = "";
//-- global variables/functionality end ----------------------------------------

//------------------------------------------------------------------------------
// NEW BROWSER WINDOW FUNCTIONS BEGIN
//------------------------------------------------------------------------------

//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
}

//------------------------------------------------------------------------------
// 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 {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("mbnb", 1, 183);
 else deleteCookie("mbnb");
}

function isPDFMessage() {
 if(getCookie("mbnb")) return true;
 else return false;
}

//------------------------------------------------------------------------------
// PDF MESSAGE END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// CSS FUNCTIONS BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- swap class
function swapClass(theId, theClass) {
 var objId = document.getElementById(theId);
 objId.className = theClass;
}

//------------------------------------------------------------------------------
// CSS FUNCTIONS END
//------------------------------------------------------------------------------

//FUNCTION-- enables linking to home page based on homePage flag
function goHome(url) {
 if(!homePage) window.location.href = url;
}

//---END