//Random Image set

function randomImage(){
	holder = placeholders.shift();
		
	image = holder[1].shift(); //rotate images
	if(document.getElementById('random_'+holder[0])){
		document.getElementById('random_'+holder[0]).src = "images/homepage_images/"+image[1]+"";
		document.getElementById('random_'+holder[0]).alt = ""+image[0];
		document.getElementById('random_'+holder[0]).title = ""+image[0];
	}
	holder[1].push(image);
				
	placeholders.push(holder);
}

var imagesA = [];
var imagesB = [];
var imagesC = [];
var imagesD = [];
//images[i] = array(ALT TEXT, IMAGE FILENAME);
imagesB.push(["Anderson Hall",'AndersonHall.jpg']);
imagesA.push(["AYPE Forestry Building",'AYPEforestrybldg.jpg']);
imagesA.push(["AYPE Forestry Building 2",'AYPEforestrybldg2.jpg']);
imagesD.push(["Bunch Berry",'bunchberry.jpg']);
imagesA.push(["Choke Setters D Kinsey 1728",'chokesettersD_Kinsey1728.jpg']);
imagesB.push(["Drumheller Fountain",'drumheller.jpg']);
imagesB.push(["UBNA Floating Bridge",'floatingbridge_ubna.jpg']);
imagesA.push(["Forest Products Lab",'forestproductslab.jpg']);
imagesA.push(["Forestry Class",'forestryclass.jpg']);
imagesA.push(["Forestry Field Lecture",'forestryfieldlecture.jpg']);
imagesA.push(["Forestry Library",'forestrylibrary.jpg']);
imagesA.push(["Forestry Professor and Students",'forestryprof_students.jpg']);
imagesC.push(["Forests Oil Class",'forestsoilsclass.jpg']);
imagesA.push(["1964 Gard Bay",'garbday1964.jpg']);
imagesD.push(["Glacier Lily",'Glacier_Lily.jpg']);
imagesB.push(["Herbarium Volunteer",'herbariumvolunteer.jpg']);
imagesC.push(["LOQ Quality SMC",'loqqualitySMC.jpg']);
imagesA.push(["Mock Campsite and Hall",'mockcampsiteAndHall.jpg']);
imagesD.push(["Mountain Goat",'mountaingoat.jpg']);
imagesD.push(["Mountain Reflection",'mountainreflection.jpg']);
imagesD.push(["Mt Rainier",'mtrainier.jpg']);
imagesC.push(["Nature Mapping",'naturemapping.jpg']);
imagesA.push(["1940 Pack Forest",'packforest1940.jpg']);
imagesD.push(["Pack Forest Mushrooms",'packforestmushrooms.jpg']);
imagesD.push(["Plant Collecting",'plantcollecting.jpg']);
imagesD.push(["Sea Holly",'seaholly.jpg']);
imagesB.push(["Seattle Urban",'seattleurban.jpg']);
imagesC.push(["Sediment Sampling",'sedimentsampling.jpg']);
imagesB.push(["Soest Garden",'SoestGarden.jpg']);
imagesC.push(["Stream Research",'streamresearch.jpg']);
imagesC.push(["Stream Sampling",'streamsampling.jpg']);
imagesC.push(["Student in the PSE Lab",'student_PSElab.jpg']);
imagesC.push(["Students on a Field Trip 1",'studentfieldtrip1.jpg']);
imagesC.push(["Students on a Field Trip in Hats",'studentfieldtrip2.jpg']);
imagesC.push(["Students on a Field Trip with Professor",'studentfieldtrip3.jpg']);
imagesC.push(["Students at WRCCRF",'studentsatWRCCRF.jpg']);
imagesC.push(["Students at the UWBG",'studentsUWBG.jpg']);
imagesD.push(["Sunbeam through Trees",'Sunbeam_Tree.jpg']);
imagesD.push(["Taos Creek Falls",'taoscreekfalls.jpg']);
imagesB.push(["UBNA Tree Planting",'UBNAtreeplanting.jpg']);
imagesB.push(["Urban Trees",'urbantrees.jpg']);
imagesD.push(["Wildlife",'wildlife.jpg']);
imagesC.push(["Wildlife: A Student and a Raven",'wildlifestudent_raven.jpg']);
imagesB.push(["Winkerwerden Bench",'winkenwerderbench.jpg']);
imagesB.push(["WPA Guide Training",'WPAguidetraining.jpg']);

//Randomizing individual set of images
shuffle(imagesA);
shuffle(imagesB);
shuffle(imagesC);
shuffle(imagesD);

var placeholders = [];
placeholders.push(['A',imagesA]);
placeholders.push(['B',imagesB]);
placeholders.push(['C',imagesC]);
placeholders.push(['D',imagesD]);

function shuffle( array ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // *     example 1: shuffle(['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
 
    for(var j, x, i = array.length; i; j = parseInt(Math.random() * i), x = array[--i], array[i] = array[j], array[j] = x);
    return true;
}

//Display the mainnav submenus
function showMenu(menuID) {
	if(document.getElementById(menuID)!=null){
		document.getElementById(menuID).style.display = 'block';
		document.getElementById(menuID).style.position = 'absolute';
		document.getElementById(menuID).style.zIndex = '200';

		if(document.getElementById('current_section_header')!=null){
			document.getElementById('current_section_header').className = '';
			if(document.getElementById('current_section')!=null){
				if (typeof restore!="undefined") {
					clearTimeout(restore);
				}
				document.getElementById('current_section').style.display = 'none';
			}
		}
		document.getElementById('header_'+menuID).className = 'current';
	}
}
//Hide Menu
function hideMenu(menuID) {
	if(document.getElementById(menuID)!=null){
		document.getElementById(menuID).style.display = 'none';
		document.getElementById('header_'+menuID).className = '';
	}
}
//Set the timer for hiding menu
function delayHideMenu(menuID) {
	delayhide=setTimeout("hideMenu('"+menuID+"')",50);
	restore = setTimeout("if(document.getElementById('current_section_header')!=null){ document.getElementById('current_section').style.display = 'block'; document.getElementById('current_section_header').className = 'current'; }",50);
}
//Reset the timer for hiding the menu
function clearHideMenu(menuID) {
	if (typeof delayhide!="undefined") {
		clearTimeout(delayhide);
	}
	if (typeof restore!="undefined") {
		clearTimeout(restore);
	}
}

