// Setup browser detection variables
var appName = navigator.appName;
var appVersion = parseInt(navigator.appVersion);
var isMac = false;
var isNetscape4 = false;
var isIE4 = false;

if (navigator.appVersion.indexOf("Mac") != -1 ) isMac = true;
if (appName == "Netscape" &&  appVersion == 4) isNetscape4 = true;
if (appName == "Microsoft Internet Explorer" && appVersion == 4) isIE4 = true;

// General functions
function preLoadImage() {
  if (document.images) {
    var imgFiles = preLoadImage.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
      var n = document.preloadArray.length;
      with (document) for (var j=0; j<imgFiles.length; j++){
        preloadArray[n] = new Image;
        preloadArray[n++].src = imgFiles[j];
      }
  }
}

function swapImage(imageSpace,newImagePath) {
  imageObj = getImage(imageSpace);
  imageObj.src = newImagePath;
}

function getImage(name) {
  return findImage(name, document);
  return null;
}

function findImage(name, doc) {

  var i, img;

  for (i = 0; i < doc.images.length; i++)
    if (doc.images[i].name == name)
      return doc.images[i];
  for (i = 0; i < doc.layers.length; i++)
    if ((img = findImage(name, doc.layers[i].document)) != null) {
      img.container = doc.layers[i];
      return img;
    }
  return null;
}

function openWin(url) { 
  newWindow = window.open(url,"newWindow");
  newWindow.focus();
  return;
}

// Handle menu link mouseover
function highlightMenuItem(num) {
	if(isIE4) {
			eval("document.all.td1" + num).style.backgroundImage="url(../images/dark_blue_background.jpg)";
			eval("document.all.td2" + num).style.backgroundImage="url(../images/dark_blue_background.jpg)";
			eval("document.all.link" + num).style.color="#FFFFFF";
	}
	else {
			eval("document.getElementById(\'td1"+ num +"\')").style.backgroundImage="url(../images/dark_blue_background.jpg)";
			eval("document.getElementById(\'td2"+ num +"\')").style.backgroundImage="url(../images/dark_blue_background.jpg)";
			eval("document.getElementById(\'link"+ num +"\')").style.color="#FFFFFF";
	}
}

// Handle menu link mouseoff
function unHighlightMenuItem(num,textColour) {
	if(isIE4) {
			eval("document.all.td1" + num).style.backgroundImage="url(../images/blue_background.jpg)";
			eval("document.all.td2" + num).style.backgroundImage="url(../images/blue_background.jpg)";
			eval("document.all.link" + num).style.color= textColour;
	}
	else {
			eval("document.getElementById(\'td1"+ num +"\')").style.backgroundImage="url(../images/blue_background.jpg)";
			eval("document.getElementById(\'td2"+ num +"\')").style.backgroundImage="url(../images/blue_background.jpg)";
			eval("document.getElementById(\'link"+ num +"\')").style.color= textColour;
	}
}

// Fix for CSS bug in Netscape 4
function netscapeCssFix() {
	if (document.windowProperties.initWindowWidth != window.innerWidth || document.windowProperties.initWindowHeight != window.innerHeight) { document.location = document.location; }
}

function netscapeCssFixInit() {
	if (isNetscape4) {
		if (typeof document.windowProperties == 'undefined') {
			document.windowProperties = new Object;
			document.windowProperties.initWindowWidth = window.innerWidth;
			document.windowProperties.initWindowHeight = window.innerHeight;
		}
	window.onresize = netscapeCssFix;
	window.onscroll = netscapeCssFix;
	}
}

netscapeCssFixInit();
