//Select images at random and display on a web page.
//  given a set of images for potential display of count N
//  given a number of images to actualy display of count x
//  this code will randomly select x images from the set N. 
// g.mcleod, 2007.04.05

var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

// IMAGE NAMES ARRAY - relative path to images
// To add more image files, continue with the
// pattern below, adding to the array.
theImages[0]  =  'weatherimages/autumn_hwy24.jpg';
theImages[1]  =  'weatherimages/fog_summit.coquihalla.jpg';
theImages[2]  =  'weatherimages/ice_passengers_plane.jpg';
theImages[3]  =  'weatherimages/icy_road_hixon.jpg';
theImages[4]  =  'weatherimages/rainbow_barn.jpg';
theImages[5]  =  'weatherimages/rain_cars.jpg';
theImages[6]  =  'weatherimages/snowshed_greatbear.jpg';
theImages[7]  =  'weatherimages/snowstorm_PGcyclist.jpg';
theImages[8]  =  'weatherimages/snow_fog_highway.jpg';
theImages[9]  = 'weatherimages/snow_kakwa.jpg';
theImages[10] = 'weatherimages/snow_kakwaprovincialpark.jpg';
theImages[11] = 'weatherimages/snow_mist_loggingtruck_6-milehill.jpg';
theImages[12] = 'weatherimages/snow_plow.jpg';
theImages[13] = 'weatherimages/snow_plow2.jpg';
theImages[14] = 'weatherimages/snow_weather_station.jpg';
theImages[15] = 'weatherimages/spring_kootenaylake.jpg';
theImages[16] = 'weatherimages/sunny_day_Valemount.jpg';
theImages[17] = 'weatherimages/sunset_glare_dividedhwy.jpg';
theImages[18] = 'weatherimages/sunset_lionsgate.jpg';
theImages[19] = 'weatherimages/sunshine_qualicum.jpg';
theImages[20] = 'weatherimages/wetroad_Nisgaa_autumn.jpg';
theImages[21] = 'weatherimages/wet_road_dumptruck.jpg';
theImages[22] = 'weatherimages/vertical_tagum.jpg';
theImages[23] = 'weatherimages/rain_semi.jpg';
theImages[24] = 'weatherimages/sunset.jpg';
theImages[25] = 'weatherimages/icy.jpg';
theImages[26] = 'weatherimages/snowblower.jpg';
theImages[27] = 'weatherimages/vi_cebc.jpg';
theImages[28] = 'weatherimages/lava_lake.jpg';
theImages[29] = 'weatherimages/robson.jpg';
theImages[30] = 'weatherimages/Aircraft-sunset.jpg';
theImages[31] ='weatherimages/marine.jpg';
theImages[32] ='weatherimages/Sea-SkyHwy99.jpg';
theImages[33] ='weatherimages/skytrain-overpass.jpg';
theImages[34] ='weatherimages/train-trestle.jpg';

var NumPics = 3; // number of pics to be displayed on page (this is the x in 'x of N')(drawn at random)

//////////////////////////////////////////////////
// do not edit anything below this line
//////////////////////////////////////////////////
var preBuffer = new Array();

//preload randomly selected images
for (i = 0; i < NumPics; i++){
	preBuffer[i] = new Image();
	var whichImage = Math.floor(Math.random()*(theImages.length));
	preBuffer[i].src = theImages[whichImage];
	theImages.splice(whichImage,1);
}

//iter through preload array 
//Page requires sufficient elements to hold new IMG tags (div, td, span, etc).  
//Each of these must have id attributes = "img_x" where x = I[0..z] for z images to display on the page.  NOTE the zero based numbering.
function displayPics() {
	for (i = 0; i < preBuffer.length; i++) {
		var theLocationID = "pic_" + i;
		var theLocationEl = document.getElementById(theLocationID);
		theLocationEl.innerHTML = '<img  src="' + preBuffer[i].src + '" name="Photo" alt="Photo">';
	}
}

