// Global JavaScripts

/* Function to add routines to page load event */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/* Just add class="rollover" to the img tag and make sure your images are named whatever.gif and whatever-over.gif */
/* You can use any kind of images and name them what you like.  The "-over" is the part that matters */
function initrollovers() {
	if (!document.getElementById) return;
	var aPreLoad = new Array();
	var sTempsrc;
	var aImages = document.getElementsByTagName('img');
	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'rollover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '-over'+ftype);
			aImages[i].setAttribute('hsrc', hsrc);
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			aImages[i].onmouseover = function() {
				sTempsrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}
			aImages[i].onmouseout = function() {
				if (!sTempsrc) sTempsrc = this.getAttribute('src').replace('-over'+ftype, ftype);
				this.setAttribute('src', sTempsrc);
			}
		}
	}
} 


/* This script and many more are available free online at The JavaScript Source :: http://javascript.internet.com
Created by: Philip Myers :: http://virtualipod.tripod.com/bookmark.html */
function bookmark(url,title) {
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		window.external.AddFavorite(url,title);
	} else if (navigator.appName == "Netscape") {
		window.sidebar.addPanel(title,url,"");
	} else {
		alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
	}
}


function sfHover() {
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.setAttribute('hclassname', this.className);
			this.className+=" selected sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.getAttribute('hclassname');
		}
	}
}


addLoadEvent(initrollovers);
addLoadEvent(sfHover);
