/*====================================================================*\

  Stormchild.net
  Common JavaScript Functions

  | Jason Sims
  | Symmetriq
  | www.symmetriq.net

  Feel free to use and adapt this for your own purposes.

  Onload event handler by Simon Willison (http://simon.incutio.com/)
  (described here: http://simon.incutio.com/archive/2004/05/26/addLoadEvent)

  IE navbar enabler by Patrick Griffiths and Dan Webb
  (described here: http://www.alistapart.com/articles/dropdowns/)

  > 2006-07-14
  - Initial release

\*====================================================================*/

// Onload event handler
// (functions to run when the page is finished loading)
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

// IE navbar enabler
// (makes subnavs work in IE)

// (Opera userAgent string contains MSIE but this buggers up Opera 8 and isn't needed for 7)
if (navigator.userAgent.search(/MSIE/) != -1 && navigator.userAgent.search(/Opera/) == -1) {

	function startList() {

		if (document.all && document.getElementById) {
			navRoot = document.getElementById("main_nav");
			for (i = 0; i < navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName == "LI") {
					if (!node.className) {
						node.onmouseover = function() {
							this.className += "over";
						}
						node.onmouseout = function() {
							this.className = this.className.replace("over", "");
						}
					}
				}
			}
		}
	}

	addLoadEvent(startList);

}

// Show/Hide DIV
function toggle(id) {
	var theBox = document.getElementById(id);
	var toggleWord = document.getElementById('toggle_' + id);

	if (theBox.style['display'] == 'block') {
		theBox.style['display'] = 'none';
		toggleWord.innerHTML = 'Show';
	} else {
		theBox.style['display'] = 'block';
		toggleWord.innerHTML = 'Hide';
	}
}

// mailto: encoder by Tyler Akins
// http://rumkin.com/tools/mailto_encoder/

function mail_links() {

	// Mail button in header
	ML="p6rocu3gwh@ :dnE>.ijtel=0\"am<fSsT/";
	MI="LJ;92EMGIKJBFD3<CJO3>:OD32K49BF=A>EDI@LBK7;O24GI5BQO0J4E2A7BMI;JFDGI?KJBFI;8B=D9GI61I;9EB79DGI6HI;DBDFEGINE>=;?KJBF;P3;ND32K49BF=I@LQJ@";
	OT="";
	for(j=0;j<MI.length;j++){
	OT+=ML.charAt(MI.charCodeAt(j)-48);
	}
	document.getElementById("email").innerHTML = OT;

	// Mail link at bottom
	ML="r/t:oElh<.n dSf>@iajm=s\"ec";
	MI="8B;70H>EGDBA6243CBF4:@F240DI7A6<9:H2G?5DBA6;=240DI7A6<81B?";
	OT="";
	for(j=0;j<MI.length;j++){
	OT+=ML.charAt(MI.charCodeAt(j)-48);
	}
	document.getElementById("email2").innerHTML = OT;

}

addLoadEvent(mail_links);
