// ------------------------ Rollover scripts ------------------------ 
var index = 0;
var imgobj = new Array();

function preloader(name, onimg, offimg) {
    imgobj[index] = new Array(3);
    imgobj[index][0] = new Image();
    imgobj[index][0].src = onimg;
    imgobj[index][1] = new Image();
    imgobj[index][1].src = offimg;
    imgobj[index][2] = name;
    index++;
}

function imgRoll(name, on) {
	for (i = 0; i < index; i++) {
		if (name == imgobj[i][2]) document.images[imgobj[i][2]].src = (on) ? imgobj[i][1].src : imgobj[i][0].src;
	}
}

// Load global rollover images (section specific are loaded in section_xxxx.js)

preloader("topnavinfo","/_global/images/topnav/bio_info.gif","/_global/images/topnav/bio_info_over.gif");
preloader("topnavgames","/_global/images/topnav/bio_games.gif","/_global/images/topnav/bio_games_over.gif");
preloader("topnavsupport","/_global/images/topnav/support2.gif","/_global/images/topnav/support2_over.gif");
preloader("topnavforums","/_global/images/topnav/forums2.gif","/_global/images/topnav/forums2_over.gif");
preloader("topnavstore","/_global/images/topnav/store.gif","/_global/images/topnav/store_over.gif");

// ------------------------- Image Preloader (for non-rollovers) -------------------------------

var icount = 0;
var iarray = new Array();

function preloaderlite(imgsrc) {
	iarray[icount] = new Image();
    iarray[icount].src = imgsrc;
    icount++;
}

// Load images into cache to speed up using image later
//preloaderlite("/path/to/file.gif");

// Determine wether mouseover will trigger Menu or rollover only (for those browsers unable to display menu)
function onmouseSwitch(strImageName, strOnOff, strMenuNum, eventObj) {
	if (strOnOff == "on") { 		// onmouseover
		if (HM_IsMenu) {
			HM_f_PopUp('elMenu' + strMenuNum, eventObj); // Calling Menus
		}
		else {
			imgRoll(strImageName,true); // Calling Rollover only
		}
	}
	else { 							// onmouseout
		if (HM_IsMenu) {
			HM_f_PopDown('elMenu' + strMenuNum) // Calling Menus
		}
		else {
			imgRoll(strImageName,false); // Calling Rollover only
		}
	}
	
}

// -------------------------------------------------------------------

function openWin(winName, loc){					// Opens a std new window
	var newWindow

	newWindow = window.open(loc,winName,"location=yes,status=yes,scrollbars=yes,toolbar=yes,menubar=yes,directories=yes,resizable=yes");		
	newWindow.focus();
}	

/******************************************************************************
* Layer functions                                                             *
*                                                                             *
* Copyright 1999 by Mike Hall.												  *
* Visit http://www.dynamicdrive.com                                           * 
* Last update: November 30, 1999.                                             *
* Modified: Robin Mayne/Duleepa Wijayawardhana 2001   						  *
* currently disabled for IE5 for Mac/using HM_Loader.js browser detect		  *
******************************************************************************/

//-----------------------------------------------------------------------------
// Layer visibility.
//-----------------------------------------------------------------------------

function hideLayer(layer) {
	if (!HMBio_IE5M) {
	  if (HM_NS4) 
	    layer.visibility = "hide";
	  if (HM_IE || HMBio_NS6) 
	    layer.style.visibility = "hidden";
	}
}

function showLayer(layer) {
	if (!HMBio_IE5M) {
	  if (HM_NS4) 
	    layer.visibility = "show";
	  if (HM_IE || HMBio_NS6) 
	  	layer.style.visibility = "visible";
	}
}

//-----------------------------------------------------------------------------
// Layer utilities.
//-----------------------------------------------------------------------------

function getLayer(name) {
	if (!HMBio_IE5M) {
	  if (HM_NS4) 
	    return findLayer(name, document);
	  if (HMBio_NS6) 
		return document.getElementById(name); 
	  if (HM_IE)
	  	return eval('document.all.' + name);  
	}
  return null;
}

function findLayer(name, doc) {

  var i, layer;

  for (i = 0; i < doc.layers.length; i++) {
    layer = doc.layers[i];
    if (layer.name == name)
      return layer;
    if (layer.document.layers.length > 0) {
      layer = findLayer(name, layer.document);
      if (layer != null)
        return layer;
    }
  }

  return null;
}

//-----------------------------------------------------------------------------
// Layer positioning.
//-----------------------------------------------------------------------------

function moveLayerTo(layer, x, y) {
	if (!HMBio_IE5M) {
		if (HM_NS4) 
		    layer.moveTo(x, y);
		if (HM_IE || HMBio_NS6) { 
		    layer.style.left = x;
		    layer.style.top = y;
	   }
	}
}

/******************************************************************************
* End Layer functions                                                         *
******************************************************************************/

/******************************************************************************
* Netscape 4.0 has problems with resizing and then losing its CSS 			  *
* variables and stuff. This Fix is a common Net Fix for the problem.		  *
******************************************************************************/

function WM_netscapeCssFix() {
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth ||
        document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
     document.location = document.location;
    }
}

function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
       document.WM = new Object;
       }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
       document.WM.WM_netscapeCssFix = new Object;
       document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
       document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
       }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn();

// catch all errors...
function stopError() {return true;}
window.onerror=stopError;

