/**
 *   consolidated.js
 *
 *   This file consolidates commonly used JavaScript functions
 *   found in these files previously: top.js, rollImg.js,
 *   openwin.js, popupwin.js, and euiwindow.js
 */



/*
 *   Force the page to the top frame of the window.
 */

 self.name="topFrame";


/**
 *  Function:		openWindow / popupWindow
 *
 *  Version History:	?
 *
 *  Description:	Use this function to open/popup a new window to display a link in.
 *
 *  Special Notes:	none
 *
 *  Syntax:		openWindow(url, w, h)
 *
 *  Parameters:		url: (input) target link
 *			w: (input) width of the popup window in pixels
 *			h: (input) height of the popup window in pixels
 *
 *  Returns:		void
 */

  function openWindow(url, w, h) {
    var options  = "width=" + w + ",height=" + h + ",";
        options += "resizable=yes,scrollbars=yes,status=yes,";
        options += "menubar=yes,toolbar=yes,location=yes,directories=no";
    var newWin = window.open(url, 'newWin', options);
    newWin.focus();
  }

  function popupWindow(url, w, h) {
    openWindow(url, w, h);
  }

  function videoWindow(url, w, h) {
    var options  = "width=" + w + ",height=" + h + ",";
        options += "resizable=no,scrollbars=no,status=no,";
        options += "menubar=no,toolbar=no,location=no,directories=no";
    var videoWin = window.open(url, 'videoWin', options);
    videoWin.focus();
  }

/**
 *  Function:		rollImgSetup
 *
 *  Version History:	2001-04-02, Richard Coles, Initial Version
 *
 *  Description:	Use this function in a page body 'onLoad' event handler
 *			to initialize variables rollover image processing via 'rollImg'.
 *			The document.images array is parsed.  Variables for image rollover
 *			are create for all images with names ending in '_on', '_off',
 *			'_at' and '_over' (Note: image name does not include the
 *			file-type; e.g.: .gif, .jpg, etc).  Complementary images
 *			(e.g.: an '_on' for each '_off') must exist in the same
 *			source directory.
 *
 *  Syntax:		rollImgSetup()
 *
 *  Parameters:		none
 *
 *  Return:		none
 */

function rollImgSetup() {
  var boolArrayDefined;
  var i;
  var result;
  var strOnImgSrc;
  var strOffImgSrc;
  var strMsg = "";

  for (i = 0; (i < document.images.length); i++) {
    strOnImgSrc = "";
    strOffImgSrc = "";
    result = document.images[i].src.match(/(.+)_(on|off|over|at)\.(.+)$/i);
    if(result == null){
      continue
    } else {
      if(result[2] == "off" || result[2] == "on"){
        strOnImgSrc = result[1] + "_on." + result[3];
        strOffImgSrc = result[1] + "_off." + result[3];
      } else if (result[2] == "over" || result[2] == "at") {
        strOnImgSrc = result[1] + "_over." + result[3];
        strOffImgSrc = result[1] + "_at." + result[3];
      }
    }

    if ((strOnImgSrc != "") && (strOffImgSrc != "") && (document.images[i].name != "")) {
      eval("((typeof " + document.images[i].name + "0) == \"object\") ? boolArrayDefined = 1 : boolArrayDefined = 0;");
      //if (boolArrayDefined) continue;
      if ((document.images[i].height > 0) &&
	  (document.images[i].width > 0)) {
        eval(document.images[i].name + "0 = new Image(document.images[i].height,document.images[i].width);");
        eval(document.images[i].name + "1 = new Image(document.images[i].height,document.images[i].width);");
      }
      else {
	eval(document.images[i].name + "0 = new Image();");
	eval(document.images[i].name + "1 = new Image();");
      }
      eval(document.images[i].name + "0.src = strOffImgSrc;");
      eval(document.images[i].name + "1.src = strOnImgSrc;");
    }
  }
}



/**
 *  Function:		rollImg
 *
 *  Version History:	2001-04-02, Richard Coles, Initial Version
 *
 *  Description:	Use this function in an 'onMouseOver' or 'onMouseOut'
 *			event handler for rollover image processing.
 *
 *  Special Notes:	You must call 'imgRollSetup()' from the page body
 *			'onLoad' event for variable initialization.
 *
 *  Syntax:		rollImg(image-name, state)
 *
 *  Parameters:		image-name: (input) 'name' value from image tag
 *			state: (input) 1 for 'on'; 0 for 'off'
 *
 *  Returns:		void
 */

function rollImg(strImgName, intState) {
  var boolArrayDefined = 0;

  if (intState <= 0)
    intState = 0;
  else
    intState = 1;
  eval("((typeof " + strImgName + intState + ") == \"object\") ? boolArrayDefined = 1 : boolArrayDefined = 0;");
  if (!boolArrayDefined) return;
  eval("document.images." + strImgName + ".src = " + strImgName + intState + ".src;");
}



