// minor cleverness

var startList = function() {
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5.2') != -1
&&
navigator.userAgent.indexOf('Mac') != -1
)

	// quit if this function has already been called
	if (arguments.callee.done) return;

	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;

if (!bugRiddenCrashPronePieceOfJunk && document.getElementById) {

var nav2ary = document.getElementById("w6-2ary");

var navRoot = document.getElementById("wvi");
var node; var noddy; var j; var i;

for (j=0; j<navRoot.childNodes.length; j++) {
  noddy = navRoot.childNodes[j];
  if (noddy.nodeName=="DT") {
    noddy.className += ' dt';
  }
  else if (noddy.nodeName=="DD") {
    noddy.className += ' dd';
  }
}

navRoot.className = 'w6';
document.getElementById('w1').className += ' active';
document.getElementById('w1d').className += ' da';
//document.getElementById('w3').className += ' active';
//document.getElementById('w3d').className += ' da';
var corps = document.getElementById('thischarity-com');
corps = document.getElementsByTagName('body')[0];
corps.className = corps.className.replace(' no-js', '');

for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
 if (node.nodeName=="DT") {
  node.onclick=function() {
    for (j=0; j<navRoot.childNodes.length; j++) {
      noddy = navRoot.childNodes[j];
      if (noddy.nodeName=="DT") {
        noddy.className = noddy.className.replace(' active', '');
      }
      else if (noddy.nodeName=="DD") {
        noddy.className = noddy.className.replace(' da', '');
      }
    }
    this.className+=" active";
    document.getElementById(this.id + 'd').className+=" da";
   }
  node.onmouseover=function() {
    this.className+=' over';
   }
  node.onmouseout=function() {
    this.className=this.className.replace(' over', '');
   }
  }
}

for (i=0; i<nav2ary.childNodes.length - 1; i++) {
node = nav2ary.childNodes[i];
 if (node.nodeName=="LI") {
  node.firstChild.onclick=function() {
    for (j=0; j<navRoot.childNodes.length; j++) {
      noddy = navRoot.childNodes[j];
      if (noddy.nodeName=="DT") {
        noddy.className = noddy.className.replace(' active', '');
      }
      else if (noddy.nodeName=="DD") {
        noddy.className = noddy.className.replace(' da', '');
      }
    }
    noddy = this.parentNode.id.replace('l', 'w');
    document.getElementById(noddy).className+=" active";
    document.getElementById(noddy + 'd').className+=" da";
    return false;
   }
  node.firstChild.onkeypress=function(k) {
   if(!k) {
    k = event;
    k.which = k.keyCode;
   }
   if (k.which != 0) {
    for (j=0; j<navRoot.childNodes.length; j++) {
      noddy = navRoot.childNodes[j];
      if (noddy.nodeName=="DT") {
        noddy.className = noddy.className.replace(' active', '');
      }
      else if (noddy.nodeName=="DD") {
        noddy.className = noddy.className.replace(' da', '');
      }
    }
    noddy = this.parentNode.id.replace('l', 'w');
    document.getElementById(noddy).className+=" active";
    document.getElementById(noddy + 'd').className+=" da";
   }
   }
 }
}
  
  var fb = document.getElementById('fb');

  if(fb) {
    fb.title = 'Click here to flip to feedback form tab.';
    fb.onclick = function() {
     for (j=0; j<navRoot.childNodes.length; j++) {
       noddy = navRoot.childNodes[j];
       if (noddy.nodeName=="DT") {
         noddy.className = noddy.className.replace(' active', '');
       }
       else if (noddy.nodeName=="DD") {
         noddy.className = noddy.className.replace(' da', '');
       }
     }
     document.getElementById('feedback').className+=" active";
     document.getElementById('feedbackd').className+=" da";
    }
  }
 }
}

/* for Mozilla */
	if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", startList, false);
	}
	
/* for Internet Explorer */
	/*@cc_on @*/
	/*@if (@_win32)
		document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
			if (this.readyState == "complete") {
				startList(); // call the onload handler
			}
		};
	/*@end @*/
	
/* for Safari */ // WebKit
	if (/KHTML/i.test(navigator.userAgent)) { // sniff
		var _timer = setInterval(function() {
			if (/loaded|complete/.test(document.readyState)) {
				startList(); // call the onload handler
			}
		}, 10);
	}
	
/* for other browsers */
	window.onload=startList;
