// Browser Refs
var browser = {	
	getEnv: function() {		
		this.ua = navigator.userAgent.toLowerCase();
		this.dom = (document.getElementById ? true : false);
		this.IE = (document.all && !window.innerWidth && this.ua.indexOf("msie") != -1 ? true : false);
		this.OPR = (this.ua.indexOf("opera") != -1 && document.clear ? true : false);
		this.OPR7 = (this.OPR && document.appendChild ? true : false);
		this.vKON = (this.ua.indexOf("konqueror") != -1 ? parseFloat(this.ua.substring(this.ua.indexOf("konqueror/") + 10)) : false);
		this.KON = (this.vKON >= 2.2 ? true : false);
		this.KON3p = (this.vKON >= 3 ? true : false);
		this.KON31p = (this.vKON >= 3.1 ? true : false);
		this.MAC = (this.ua.indexOf("mac") != -1 ? true : false);
		this.SAF = (this.MAC && this.ua.indexOf("safari") != -1 ? true : false);
		this.IE5M = (this.MAC && this.IE && this.dom ? true : false);
	}
}
browser.getEnv();

// get dom node by id
function getById(id) {
	var node;
	if (browser.dom) {
		 node = document.getElementById(id);
	} else if (browser.IE) {
		node = document.all[id];
	}
	return node;
}

// docroot for paths
// assumes everything but homepage (or any top-level page w/ docroot defined) is 1-level down
var docroot;
if (!docroot) docroot = "../";

// email link spam workaround
var addresses = {
	ajones: ['ajones', 'calstatela.edu'],
	jshindler: ['jshindl', 'calstatela.edu'],
	ctaylor: ['Tayhome', 'aol.com'],
	ctaylor6: ['ctaylor6', 'calstatela.edu'],
	hcadenas: ['hcadena', 'calstatela.edu'],
	bbrown: ['BBrown8164', 'aol.com'],
	tdriver: ['tdriver', 'lkwash.wednet.edu'],
	kstichter: ['kstichter', 'fullerton.edu'],
	kgavin: ['kgavin', 'sbcglobal.net'],
	bgastic: ['billie.gastic', 'umb.edu' ],
	awillia6: ['awillia6', 'calstatela.edu' ]
}
function email(name) {
	window.location.href = "mailto:" + addresses[name][0] + "@" + addresses[name][1];
}

//random img generator
function genImg() {
	var imgNum = Math.round(10 * Math.random());
	if (imgNum < 1) {
		imgNum = 1;
	}
	if (imgNum > 4) {
		if (imgNum == 5) {
			imgNum = 1;
		}
		if ((imgNum > 5) && (imgNum < 8)) {
			imgNum = 2;
		}
		if ((imgNum > 7) && (imgNum < 10)) {
			imgNum = 3;
		}
		if (imgNum > 9) {
			imgNum = 4;
		}
	}

	if (document.images && document.images["nav_photo"]) {
		document.images["nav_photo"].src = "" + docroot + "images/pg_photo" + imgNum + ".jpg";
	}
}

window.onload = function() {

	// load top left image
	genImg();
	
	// load nav
	globalnav.init({
		name: "nav",
		containerId: "nav_menu_container",
		menuClass: "nav_menu",
		//itemContainerClass: "gnav_item_container",
		itemClass: "on"
	});
}
