function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

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

function greyOutQuotes() {
	
	if (!document.getElementById('quotes')) return;
	
	document.getElementById('quotes').style.color = "#222222";
}

var t = new Array();
var j = -1;

function quotesFadeIn() {
	var startRGB = 0x222222;
	var quoteCntr;
	
	if (!document.getElementById('quotes')) return;
	
	quoteArray = document.getElementById('quotes').getElementsByTagName('li');
	
	for (quoteCntr = 0; quoteCntr < quoteArray.length; quoteCntr++) {
		t[j++] = setTimeout("quoteFadeIn("+quoteCntr+","+startRGB+")", 1500*quoteCntr);
	}
}	

function quoteFadeIn(index, currRGB) {
	brightestRGB = 0xeeeeee;

	if (currRGB < brightestRGB) {
		currRGB += 0x010101;
		quoteArray[index].style.color = "#"+currRGB.toString(16);
		t[j++] = setTimeout("quoteFadeIn("+index+","+currRGB+")", 6);
	} else {
		quoteArray[index].style.color = "#f9ffe1";
	}
}

function initPages() {
  startList();
  externalLinks();
  greyOutQuotes();
  quotesFadeIn();
}

function killTimeouts() {
	for(k in t) {
		clearTimeout(t[k]);
	}
}

window.onload = initPages;

window.onunload = killTimeouts();
