function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

function pop(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function close_win() {
  window.close();
}

function swapon(name) {
	if (document.layers){
		eval('document.layers.' + name + '.visibility = "hidden"')
		eval('document.layers.' + name + '.visibility = "show"')
	}	else {
		eval('document.all.' + name + '.style.visibility = "hidden"')
    eval('document.all.' + name + '.style.visibility ="visible"')
	}
}

function swapof(name) {
	if (document.layers) {
		eval('document.layers.' + name + '.visibility = "hidden"');
	}	else {
    eval('document.all.' + name + '.style.visibility = "hidden"');
	}
}

imgObjon = 0;
function changeImage(layer,imgName,imgObj) {
	if (imgName != imgObjon) {
		if (document.images) {
			if (document.layers && layer!='null') eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')
			else document.images[imgName].src = eval(imgObj+".src")
		}
	}
}

function clickon(x) {
  imgObjon = x
}

function showModule(x) {
  if (document.getElementById) {
    eval('document.getElementById("module'+x+'").style.visibility = "visible"');
  } else if (document.all) {
    eval('document.all.module'+x+'.style.visibility = "visible"');
  } else if (document.layers) {
    eval('document.layers.module'+x+'.visibility = "show"');
  }
}

function hideModule(x) {
 if (document.getElementById) {
    eval('document.getElementById("module'+x+'").style.visibility = "hidden"');
  } else if (document.all) {
    eval('document.all.module'+x+'.style.visibility  = "hidden"');
  } else if (document.layers) {
    eval('document.layers.module'+x+'.visibility =  "hidden"');
  }
}

function toggleModule(x, origVisibility, hrefRoot) {
  var currentVisibility;
  var visibility;
  var visLayers;
  if (document.getElementById) {
    currentVisibility = eval('document.getElementById("module'+x+'").style.visibility');
  } else if (document.all) {
    currentVisibility = eval('document.all.module'+x+'.style.visibility')
  } else if (document.layers) {
    currentVisibility = eval('document.layers.module'+x+'.visibility')
  }
  if ((currentVisibility == null) || (currentVisibility.length == 0)) {
    currentVisibility = origVisibility;
  }
  if (currentVisibility == "visible" || currentVisibility == "show") {
    visibility = "hidden";
    visLayers = "hide";
  } else {
    visibility = "visible";
    visLayers = "show";
  }
  if (document.getElementById) {
    eval('document.getElementById("module'+x+'").style.visibility = "' + visibility + '"');
  } else if (document.all) {
    eval('document.all.module'+x+'.style.visibility = "' + visibility + '"');
  } else if (document.layers) {
    eval('document.layers.module'+x+'.visibility = "' + visLayers + '"');
  }

  // Lifted from Netflix.com's "Starbar" js
  var href;
  var sendWindow;
  href = hrefRoot + "clickrespond.php?module=" + x + "&visibility=" + visibility;
  //href = "http://carya/safeclimate-redesign/clickrespond.php?module=1&visibility=hidden";
  //alert("Going here: " + href);
  // Try to use an IFRAME.
  if (window.callback_iframe) {
    window.callback_iframe.location.href = href;
    return void(0);
  }
  // If that failed, try using a pop-up window.
  sendWindow =
    window.open("", "pop", "resizable=no,dependent=yes,width=1,height=1,screenX="+window.screenX+",screenY="+window.screenY+",top="+window.screenX+",left="+window.screenY);
  if (sendWindow && ! sendWindow.closed) {
    sendWindow.location.href = href;
    return void(0);
  }
  // If that failed, run in this window.
  window.location.href = href+"&url="+escape(window.location.href);
  return void(0);
}



// Netscape Resize Fix Functions
// a Netscape 4 specific function to reload the browser when it has been resize to avoid layout problems associated with layers
// 19990326

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) {
	widthCheck = window.innerWidth
	heightCheck = window.innerHeight
	window.onResize = resizeFix
}
function resizeFix() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
	document.location.href = document.location.href
}


// THIS CAME WITH THE MODULES JavaScript
// IS THIS REALLY NECESSARY??? --------------------------->
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function save_DoFSCommand(command, args) {
  var saveObj = InternetExplorer ? save : document.save;
  if (command == "pop") {
    page = "/graphs/" + args;
    window.open(page,'graph','width=400,height=495');
  }
}

// Hook for Internet Explorer
if (navigator.appName &&
    navigator.appName.indexOf("Microsoft") != -1 &&
		navigator.userAgent.indexOf("Windows") != -1 &&
		navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub save_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call save_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

