// JavaScript Document

//-- clear/replace text in the form input fields --//
function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}


// jh (below)

function clickMenu(link) {
	var group = getNextSibling(link);
	
	if(group && group.className == "menu-group") {
		if(group.style.display == "block") {
			group.style.display = "none";
			removeClass(link, "current");

		} else {
			group.style.display = "block";
			addClass(link, "current");
		}
		
		return false; // don't follow HTML link
	}

	return false; // follow HTML link
}


// Get the next element node (this way ignores spaces etc.)
function getNextSibling(node) {
	var x = node.nextSibling;
	while(x.nodeType != 1) {
  		x = x.nextSibling;
  	}
	return x;
}

function addClass(element, className) {
	if(element.className)
		element.className += " " + className;
	else
		element.className = className;
}

function removeClass(element, className) {
	if(! element.className)
		return;
		
	var regexp = new RegExp("\\b"+className+"\\b", "");
	element.className = element.className.replace(regexp, "");
}

