//Creating a function array allows each page to add a new function to an array to be added on load.
//That way you aren't adding every function to every page load if the function isn't used on every page.
initOnload();

function initOnload(){
    addEvent(window, 'load',initRollovers);
}

var browser = navigator.appName;
var versionInfo = navigator.appVersion;
var versionNum = parseFloat(versionInfo);
var vendor = navigator.vendor;
var IE = "Microsoft Internet Explorer";
var IE6 = "MSIE 6.0";
var IE7 = "MSIE 7.0";
var safari = "Apple Computer, Inc.";
var imagePath = "images/";
var classAttribute = classAttr();   //Get the appropriate class attribute to set. IE and Firefox use different attributes for class in the DOM.

/***** Begin preload images *****/
var origImg = new Array();	//Array of images for rollovers
origImg[0] = '';

var overImg = new Array();	// Array of images to preload
overImg[0] = '';

var preloadFlag = false;
function preloadImages() {
	for (i=0; i<overImg.length; i++) {
		var images = new Array();
		images[i] = new Image();
		images[i].src = imagePath + overImg[i];
	}
	preloadFlag = true;
}
/***** End preload images *****/

/***** Begin image rollover funtion *****/
/* Function to initalize rollover */
function initRollovers(){	
	var rollovers = getElementsByClass('rollover',null,null);	//Get elements with a class of "rollover"
	
	if (rollovers.length > 0){		//If there is at least one element with a class "rollover"
		for(var i=0;i<rollovers.length;i++){	//Loop through all elements with class "rollover"
			var classValue = rollovers[i].getAttribute(classAttribute);
			
			if((versionInfo.match(IE6) != null) && (classValue.match('tpng') != null) ){ //If the browser is IE6 and a transparent png				
				addEvent(rollovers[i],'mouseover',rolloverPNG);	//Attach mouseover event
				addEvent(rollovers[i],'mouseout',rolloverPNG);	//Attach mouseout event				
			}
			else {
				addEvent(rollovers[i],'mouseover',rollover);	//Attach mouseover event
				addEvent(rollovers[i],'mouseout',rollover);	//Attach mouseout event
			}
		}		
	}
}

// This function grabs the src attribute and replaces "off" with "on" (for mouseover) or "on" with "off (for mouseout) in the attribute string. KM
function rollover(event) {
	var etype = event.type;
	var imgSrc = getObjectAttribute(this,"src");
	var newImgSrc;
	
	if (etype == 'mouseover'){
	    newImgSrc = imgSrc.replace('off.','on.','gi');
		this.setAttribute('src',newImgSrc);
	}
	
	else if (etype == 'mouseout') {
	    newImgSrc = imgSrc.replace('on.','off.','gi');
		this.setAttribute('src',newImgSrc);
	}
}

// IE 6 transparent PNG rollover function. KM
function rolloverPNG(event) {
	var etype = event.type;
	var imgSrc = getObjectAttribute(this,"name");
	var newImgSrc;
	
	if (etype == 'mouseover'){
	    newImgSrc = imgSrc.replace('off.','on.','gi');
		this.setAttribute('src',newImgSrc);
	}
	
	else if (etype == 'mouseout') {
	    newImgSrc = imgSrc.replace('on.','off.','gi');
		this.setAttribute('src',newImgSrc);
	}
}
/***** End image rollover function *****/

/***** Begin pop up functions *****/
function popWindow(href,title,sb,width,height) {
	window.open(href,title,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+ sb +',resizable=0,width='+ width +',height='+ height +',top=150,left=150');
}
/***** End pop up functions *****/