
// If JavaScript is enabled, change the webtech.css style sheet's 
// WTonIfJS and WToffIfJS class definitions (see webtech.css).

var ruleModified = false;  // Did we modify the WTinit style rule?

try {
  var styleSheets = document.styleSheets;

  // Get the webtech.css style sheet.
  // Assume that it is the last style sheet (it should be), 
  // and abort if not.
  // Note that href will be absolute URL.
  var myStyleSheet = styleSheets[styleSheets.length-1];
  if (myStyleSheet.href.indexOf("webtech.css") < 0) {
  //  window.alert("Error in style sheet retrieval.");
  }
  else {

    // Get the collection of rules contained in this style sheet.
    // Hack for IE6, which has "rules" rather than "cssRules" attribute.
    var styleRules = myStyleSheet.cssRules;
    if (!styleRules) {
      styleRules = myStyleSheet.rules;
    }

    // Change the WToffIfJS and WTonIfJS rules.
    // Each style rule is supposed to have a type attribute with
    // value 1 if it is the type of rule we're looking for.
    // IE6 doesn't have this attribute (all rules are of type 1).
    // Rule's selector may have extraneous white space, so we
    // search for the selector rather than using equality test.
    for (var i=0; i<styleRules.length; i++) {
      var styleRule = styleRules[i];
      if ((!styleRule.type
          || styleRule.type == 1) && 
	  styleRule.selectorText.indexOf(".WToffIfJS") >= 0) {
	ruleModified = true;
	styleRule.style.display = "none";
      }
      else if ((!styleRule.type 
          || styleRule.type == 1) && 
	  styleRule.selectorText.indexOf(".WTonIfJS") >= 0) {
	ruleModified = true;
	styleRule.style.display = "block";
      }
    }
  }
}
// Ignore any errors; we'll just leave the default style sheet as-is
catch (e) {
  // throw e;            // Use to debug IE
  // window.alert(e);    // Can use with Mozilla
}


// Toggle visibility of the element having the given id.
function toggleVis(id) {
  var elt = document.getElementById(id);

  // If this element's display property has not been set,
  // toggle is based on whether or not we successfully changed
  // the style rules.
  if (!elt.style.display) {
    if (ruleModified) {
      elt.style.display = "block";
    }
    else {
      elt.style.display = "none";
    }
  }

  // Otherwise, just toggle the existing value.
  else {
    if (elt.style.display.toLowerCase() != "none") {
      elt.style.display = "none"; 
    } 
    else {
      elt.style.display = "block";
    }
  }
}
