// Layer Swap
// Can be used to hide/show navigation layers eithers automated
// or with a layerAction (show, hide) forced.

layerStatus    = new Array();

function layerSwap(targetLayer, layerAction) {

  thisLayer    = document.getElementById(targetLayer).style;

  if( thisLayer != undefined ) {

    if( layerAction == undefined ) {
    // If no action is specified, reverse the current status
      setVisibility = (layerStatus[targetLayer] != "visible") ? "visible" : "hidden";
    } else {
    // Check for a known action
      switch(layerAction) {
      case "hide": setVisibility = "hidden";  break;
      case "show": setVisibility = "visible"; break;
      } // ! switch
    }

    thisLayer.visibility     = setVisibility;
    layerStatus[targetLayer] = setVisibility;

  } // ! does the layer exist?

} // ! layerSwap
