// JavaScript Document

var rainbow_count = 0;
function getObject(objectName) {
	var obj = null;
	if (document.getElementById) {
		obj = document.getElementById(objectName);
	}
	else if (document.all) {
		obj = document.all[objectName];
	}
	else if (document.layers) {
		obj = document.layers[objectName];
	}
	return obj;
}
function d2h(d) {return d.toString(16);}
function h2d(h) {return parseInt(h,16);} 
function rand(min, max) {return Math.floor((Math.random()* (min + max)) - min);}
function pad(s, pad_str, minlen) {
	if(s.length<minlen) {
		for (var i=s.length; i<minlen; i++) {
			s = pad_str + s;
		}
	}
	return s;
}
function rainbow() {
	rainbow_count++;
	var d = null;
	d = getObject("sitetitle");
	if (d != null) {
		var s = "Aaron Caffrey";
		var z = "";
		for (var i=0; i<s.length; i++) {
			z = z + '<font color="#' + pad(d2h(rand(0,255)),"0",2) + pad(d2h(rand(0,255)),"0",2) + pad(d2h(rand(0,255)),"0",2) + '">' + s[i] + '</font>';
		}
		d.innerHTML = z;
	}
	if (rainbow_count > 10) {
		var t=setTimeout("rainbow();", 10000);
		rainbow_count = 0;
	} else {
		var t=setTimeout("rainbow();", 250);
	}
}
function rotateVisibility(objectName, objectNamesToHide) {
	if (objectNamesToHide != null && objectNamesToHide != "") {
		objectNamesToHideArr = objectNamesToHide.split(" ");
		for (i = 0; i<objectNamesToHideArr.length; i++) {
			obj = getObject(objectNamesToHideArr[i]);
			if (obj != null) {
				obj.style.display = "none";
			}
			obj = getObject(objectNamesToHideArr[i] + "_wrapper");
			if (obj != null) {
				obj.style.display = "none";
			}
		}
	}
	obj = getObject(objectName);		
	if (obj != null) {
		if (obj.style.display != "block") {
			obj.style.display = "block";
		} else {
			obj.style.display = "none";
		}
	} 
	obj = getObject(objectName + "_wrapper");
	if (obj != null) {
		if (obj.style.display != "block") {
			obj.style.display = "block";
		} else {
			obj.style.display = "none";
		}
	}
}
function menu(n) { 
	var m = null;
	m = getObject("menu");
	if (m != null) { 
		var mi = null;
		mi = m.firstChild;
		while (mi) { 
			if (mi.nodeName == "LI") {
				var mii = null;
				mii = mi.firstChild;
				while (mii) {
					if (mii.nodeName == "A") {
						mii.setAttribute("class", "");
					}
					mii = mii.nextsibling;
				}
			}
			mi = mi.nextSibling;
		}		
	}
	m = getObject("menu_" + n);
	if (m != null) {
		m.setAttribute("class", "current");
		rotateVisibility(n, "Home Portal Contact");
	}
}
function jslinks() {
	var m = getObject("menu");
	if (m != null) {
		var mi = null;
		mi = m.firstChild;
		while (mi) {
			if (mi.nodeName == "LI") {
				var mii = null;
				mii = mi.firstChild;
				while (mii) {
					if (mii.nodeName == "A") {
						mii.setAttribute("href", "#");
					}
					mii = mii.nextsibling;
				}
				
			}
			mi = mi.nextSibling;
		}		
		
	}
}
function init() {
	rainbow();
	jslinks();
	rotateVisibility("Home", "Home Portal Contact");
}