/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// set these variables equal to the original top and left of layers
var orig_x=190;  // layers' left
var orig_y=412;	// layers' top

// onresize for ns4
var origWidth2, origHeight2;
if (document.layers) {
	origWidth2 = window.innerWidth; origHeight2 = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth2 || window.innerHeight != origHeight2) history.go(0); }
}

var cur_lyr2;	// holds id of currently visible layer
function swapLayers2(id) {
  if (cur_lyr2) hideLayer2(cur_lyr2);
  shiftLayerTo2( id, orig_x, orig_y + getScrollY() );
  showLayer2(id);
  cur_lyr2 = id;
}

function showLayer2(id) {
  var lyr2 = getElemRefs(id);
  if (lyr2 && lyr2.css) lyr2.css.visibility = "visible";
}

function hideLayer2(id) {
  var lyr2 = getElemRefs(id);
  if (lyr2 && lyr2.css) lyr2.css.visibility = "hidden";
}

function shiftLayerTo2(id,x,y) {
  var px = document.layers? 0: "px";
  var lyr2 = getElemRefs(id);
  if (lyr2 && lyr2.css) {
    lyr2.css.top = y + px;
    lyr2.css.left = x + px;
  }
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// credit to http://www.13thparallel.org for the following function
// returns amount of vertical scroll
function getScrollY() {
	var sy = 0;
	if (document.documentElement && document.documentElement.scrollTop)
		sy = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) 
		sy = document.body.scrollTop; 
	else if (window.pageYOffset)
		sy = window.pageYOffset;
	else if (window.scrollY)
		sy = window.scrollY;
	return sy;
}
