/*
function call: addGetElementById();
function returns: void;
function purpose:
This function adds the getElementById() function to browsers without it but with the document.all or
document.layers collections.
*/
function addGetElementById() {
	if (!document.getElementById && document.all) {
		document.getElementById = new Function('id', 'return document.all[id]');
	}
	if (!document.getElementById && document.layers) {
		document.getElementById = new Function('id', 'return document.layers[id]');
	}
}

/*
function call: preloadImages();
function returns: void;
function purpose:
This function loops through all images on a page and loads additional images into the cache
where exists an image with "off" in the filename.  Essentially pre-loads rollover images.
*/
function preloadImages(){
	var str, ro, j=1, di=document.images;
	for(var i=0;i<di.length;i++){
		str = new String(di[i].src);
		if(str.indexOf('/off/')!=-1){
			ro = str.replace(/off/gi, 'on');
			di[di.length+j] = new Image();
		    di[di.length+j].src = ro;
		    j++; 
		}
	}
}

/*
function call: refreshImages();
function returns: void;
function purpose:
This function refreshes cached images on a page.  By adding a random number as a variable name
to the end of the image src, the browser is fooled into thinking it's a new image.  This function
should be used sparingly since it could fill the user's cache with duplicate unwanted images.
*/
function refreshImages() {
	// code below refreshes images on the page
	// by adding a random number as variable name to the image src
	var str, di=document.images;
	for(var i=0;i<di.length;i++){
		str = new String(di[i].src);
		di[i].src = str+"?"+Math.floor(Math.random() * 1000);
	}

}

/*
function call: rollOver("image name");
function returns: void;
function purpose:
This function is a generic rollover script.  To use this script you must store like-named images for
the off and on rollover states in separate directories, identical in pathname except for "off" and "on".
(e.g. /path/name/on/image.gif, /path/name/off/image.gif)
*/
function rollOver(img){
	var cImg = document.images[img];
	var str = new String(cImg.src);
	cImg.src = (str.indexOf('off')==-1?str.replace(/\/on\//gi, '/off/'):str.replace(/\/off\//gi, '/on/'));
}

/*
function call:  sendMail("user id", "domain name", "domain suffix", "subject heading");
function returns: void;
function purpose:
This function acts as a mailto link without requiring the verbatim email address be included in page
*/
function sendMail(user, domain, suffix, subject) {
	var loc = "mailto:"+user+"@"+domain+"."+suffix;
	if (subject != "") { loc += "?subject="+subject; }
	location.href=loc;
}