//adapted from an original script by Dynamic Web Coding at http://www.dyn-web.com/ Copyright 2001-2 by Sharon Paine. See Terms of Use at http://www.dyn-web.com/bus/terms.html Permission granted to use this code as long as this entire notice is included.

var lastChoice;
function turnOn(lnk,lyr) {
	if (document.getElementById||document.all) {
		var curLnk = (document.getElementById)? document.getElementById(lnk): document.all[lnk];
		if (curLnk&&curLnk.blur) curLnk.blur();	// remove IE outline
		if (!curLnk || lastChoice == curLnk) return;
		if (lastChoice) lastChoice.className = "done";
		curLnk.className = "on";
		lastChoice = curLnk;
	}
	loadLyr(lyr);
}

var cur_lyr;

function loadLyr(lyr) {
	if (cur_lyr) {
		var curcss = get_lyr_css(cur_lyr);
		if (curcss) curcss.visibility="hidden";
	}
  cur_lyr = lyr;
	var curcss = get_lyr_css(cur_lyr);
	if (curcss) {
		curcss.visibility = "visible";
		curcss.zIndex = 100;
	}
}

function get_lyr_css(id) {
	var lyr, lyrcss;
	lyr = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (lyr) lyrcss = (lyr.style)? lyr.style: lyr;
	return lyrcss;
}

// for nn4
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}
