function navHover (id, newClass) 
{
	el = document.getElementById (id);
	el.className = newClass;
}


function resizeText (direction)
{
	var default_increment = 10;
	var new_size;

	/* Phil's styles sheets have the default font size at 72% 
	** so start from that. If it changes, then the value needs 
	** updating here as well. 
	*/
	var PHIL_DEFAULT = 72;


	if (document.body.style.fontSize == '')
		{

			
			if (direction == 'down')
				{	
					new_size = PHIL_DEFAULT - 10;		
				}
			else if (direction == 'up')
				{
					new_size = PHIL_DEFAULT + 10;
				}
			else // if (direction == 'reset')
				{
					new_size = PHIL_DEFAULT;
				}
		}
	else 
		{
			var new_size = parseInt (document.body.style.fontSize);
			
			if (direction=='down')
				{	
					new_size -= default_increment;
				}
			else if (direction == 'up')
				{
					new_size += default_increment;
				}
			else // if (direction == 'reset')
				{
					new_size = PHIL_DEFAULT;
				}				
		}

	document.body.style.fontSize = new_size + '%';
}


function popUp(ourArticleTitle) {
	// Idea by:  Nic Wolfe (Nic@TimelapseProductions.com) 
	// Web URL:  http://fineline.xs.mw 
	//
	// This script and many more are available free online at 
	// The JavaScript Source!! http://javascript.internet.com 

	day = new Date();
	ourName = day.getTime();

	ourFeatures = "toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=370,height=445";
	ourUrl = "/mail/email.jsp?title=" + ourArticleTitle + "&url=" + eval ("window.top.location");

	window.open(ourUrl, ourName, ourFeatures);
}


function toggleAttribute (idName, attrName, value1, value2) {

//	alert ("idName: " + idName);
	var elem = document.getElementById (idName);

//	alert ("elem: " + elem);
	if (elem != null) {

//		alert ("attrName: " + attrName);

		var attr = eval ('elem.' + attrName);
//		alert ("attr: " + attr);
		if (attr != null) {
//			alert ("value1: " + value1);
//			alert ("value2: " + value2);
			attr = trim (attr);
			var s = "";
			if (attr == value1) {
				s = 'elem.' + attrName +  " = '" + value2 + "'";
			} else {
				s = 'elem.' + attrName +  " = '" + value1 + "'";
			}
//			alert ("S: " + s);
			eval (s);
		}
	}
}

function trim (s) {
	var l = 0; 
	var r = s.length - 1;
	
	while ((l <= r) && (s [l] == ' ')) {
		++ l; 
	}
	
	while ((r > l) && (s [r] == ' ')) {
		-- r;
	}

	return s.substring (l, r + 1);
}


function setStyleByClass (rootId, tagName, className, propertyName, value1, value2) {
	var elements;
	var ie = (document.all) ? true : false;
	if(tagName == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementById (rootId).getElementsByTagName(tagName);
	}

	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
//		alert ("i: " + i + " node: " + node.nodeName + " length: " + node.attributes.length);
		for(var j = 0; j < node.attributes.length; j++) {
			var thisItem = node.attributes.item (j);
			var attrName = thisItem.nodeName.toLowerCase ();
//			alert ("i: " + i + " attribute " + j + ": " + attrName);
			if(attrName == 'class') {
				var attrValue = thisItem.nodeValue.toLowerCase ();
//				alert ("i: " + i + " in class: " + attrValue);
				if(attrValue == className.toLowerCase ()) {
					var propertyValue = eval('node.style.' + propertyName);
//					alert ("propertyValue: " + propertyValue);

					if (propertyValue == value1) {
						eval('node.style.' + propertyName + " = '" + value2 + "'");
					} else {
						eval('node.style.' + propertyName + " = '" + value1 + "'");
					}
				}
			}
		}
	}
}


function toggleList (idName, firstTitle, secondTitle, firstLink, secondLink, hiddenClass) {

	var toggleElem = idName + "toggleLink";
	var titleElem = idName + "toggleableListTitle";
	var listElem = idName + "toggleableList";

//	alert (toggleElem);
//	alert (titleElem);

	setStyleByClass (listElem, "li", hiddenClass, "display", "list-item", "none");
	toggleAttribute (toggleElem, "innerHTML", firstLink, secondLink);
	toggleAttribute (titleElem, "innerHTML", firstTitle, secondTitle);
}

