
var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
  if (lyr && lyr.css) lyr.css.display = "block";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
  if (lyr && lyr.css) lyr.css.display = "none";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

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;
  }
}

var cur_sublyr;
function swapLayers2(id) {
  if (cur_sublyr) hideLayer2(cur_sublyr);
  showLayer2(id);
  cur_sublyr = id;
}

function showLayer2(id) {
  var sublyr = getElemRefs2(id);
  if (sublyr && sublyr.css) sublyr.css.visibility = "visible";
  if (sublyr && sublyr.css) sublyr.css.display = "block";
}

function hideLayer2(id) {
  var sublyr = getElemRefs2(id);
  if (sublyr && sublyr.css) sublyr.css.visibility = "hidden";
  if (sublyr && sublyr.css) sublyr.css.display = "none";
}

function getElemRefs2(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef2(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function getLyrRef2(lyr,doc) {
	if (document.layers) {
		var theLyr2;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr2 = doc.layers[i];
			if (theLyr2.name == sublyr) return theLyr2;
			else if (theLyr2.document.layers.length > 0) 
	    	if ((theLyr2 = getLyrRef2(sublyr,theLyr2.document)) != null)
					return theLyr2;
	  }
		return null;
  }
}

var cur_subalyr;
function swapLayers3(id) {
  if (cur_subalyr) hideLayer3(cur_subalyr);
  showLayer3(id);
  cur_subalyr = id;
}

function showLayer3(id) {
  var subalyr = getElemRefs3(id);
  if (subalyr && subalyr.css) subalyr.css.visibility = "visible";
  if (subalyr && subalyr.css) subalyr.css.display = "block";
}

function hideLayer3(id) {
  var subalyr = getElemRefs3(id);
  if (subalyr && subalyr.css) subalyr.css.visibility = "hidden";
  if (subalyr && subalyr.css) subalyr.css.display = "none";
}

function getElemRefs3(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef3(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function getLyrRef3(lyr,doc) {
	if (document.layers) {
		var theLyr3;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr3 = doc.layers[i];
			if (theLyr3.name == subalyr) return theLyr3;
			else if (theLyr3.document.layers.length > 0) 
	    	if ((theLyr3 = getLyrRef3(subalyr,theLyr3.document)) != null)
					return theLyr3;
	  }
		return null;
  }
}

var cur_formlyr;
function swapLayers4(id) {
  if (cur_formlyr) hideLayer4(cur_formlyr);
  showLayer4(id);
  cur_formlyr = id;
}

function showLayer4(id) {
  var formlyr = getElemRefs4(id);
  if (formlyr && formlyr.css) formlyr.css.visibility = "visible";
  if (formlyr && formlyr.css) formlyr.css.display = "block";
}

function hideLayer4(id) {
  var formlyr = getElemRefs4(id);
  if (formlyr && formlyr.css) formlyr.css.visibility = "hidden";
  if (formlyr && formlyr.css) formlyr.css.display = "none";
}

function getElemRefs4(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef4(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function getLyrRef4(lyr,doc) {
	if (document.layers) {
		var theLyr4;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr4 = doc.layers[i];
			if (theLyr4.name == formlyr) return theLyr4;
			else if (theLyr4.document.layers.length > 0) 
	    	if ((theLyr4 = getLyrRef4(formlyr,theLyr4.document)) != null)
					return theLyr4;
	  }
		return null;
  }
}
