window.onload = function(){
	
	switch_header();
	ie_nav();
}
/*
---------- instantiate menu li:hover class in IE6 ----------------------------------------------------------*/
function ie_nav(){
	
	if (document.all && document.getElementById) {
		
		navRoot = document.getElementById("top_nav");
		
		for (i=0; i<navRoot.childNodes.length; i++) {
			
			node = navRoot.childNodes[i];
			
			if (node.nodeName == "LI") {
				
				node.onmouseover = function(){
					
					this.className += " over";
 	 			}
  				
				node.onmouseout = function(){
					
  					this.className = this.className.replace(" over", "");
   				}
   			}
  		}
 	}
}
function switch_header(){
	
	// preloader - this pre-loads the images so that there is no delay when switching different images in.
	// needs to contain all the images that are to be used
	
	var images = new Array('header1.jpg', 'header2.jpg', 'header3.jpg', 'header4.jpg');
	
	for(var i = 0; i < images.length; i++){
		
		var img = new Image;
		img.src = 'images/' + images[i];
	}
	
	// this function is setup to randomize between 4 different header images, has flexibility for more.
	// NOTE: the header images themselves need to be named "header1.jpg", "header2.jpg" etc...		
	
	var id = Math.floor((4 - 0) * Math.random()) + 1;
		// this generates a random number between 1 and 4
		// 4 represents the max integer
		// 1 represents the min integer
		// 0 represents the min integer - 1
		// this doesn't take into account what the previously selected index was, so there's a 25% chance that the next random number will be the same as the last

	document.getElementById("header").style.backgroundImage = "url(images/header" + id + ".jpg)";
	document.getElementById("header").style.backgroundPosition = "top left";
	document.getElementById("header").style.backgroundRepeat = "no-repeat";

}