// support for capturing the document.write()s of included js src
var originalWriteFunction = document.write;
var capturedWrites = "";
function captureWrites() {
  document.write = function(str) { capturedWrites = capturedWrites + str; };
}
function allowWrites() {
  document.write = originalWriteFunction;
}
function writeUnless(candidateText, regexp, alternateText) {
  if(candidateText.match(regexp)) {
    document.write(alternateText);
  } else {
    document.write(candidateText);
  }
}
// if the item's class ends in 0, make it 1; if 1, make it 0
function toggleClass(elementId) {
	if (document.getElementById && document.getElementById(elementId) != null) {
		oldClass = document.getElementById(elementId).className;
                document.getElementById(elementId).className =
                  oldClass.substring(0,oldClass.length-1) + 
                  (oldClass.charAt(oldClass.length-1)=='0' ? '1' : '0');
	}
}
// if the item's class ends in 0, make it 1; if 1, make it 0
function toggleDisplay(elementId) {
	if (document.getElementById && document.getElementById(elementId) != null) {
		oldDisplay = document.getElementById(elementId).style.display;
                document.getElementById(elementId).style.display =
		  oldDisplay == '' ? 'none' : '';
	}
}
