/* ••••••••••••••••••• Random Image ••••••••••••••••••••••• */
/* Javascript by Chris Barrett @ outcrop.com */

pic_widthHome=806; /*change to match the height of all your images */
pic_heightHome=283; /* change to match the width of all your images */
img_num=7; /* The number of images to load */
img_holder = "header" /* the id of the image holder */



/* define image Array to hold images*/
var images= new Array(img_num)
for(i=0; i<img_num;i++){
images[i]= new Image(pic_width,pic_height);
}

/* Define image path and descriptions */
if (document.images){ 
images[0].src="/i/header-01.jpg"; 
images[1].src="/i/header-02.jpg";
images[2].src="/i/header-03.jpg";
images[3].src="/i/header-04.jpg";
images[4].src="/i/header-05.jpg";
images[5].src="/i/header-06.jpg";
images[6].src="/i/header-07.jpg";

}

/* Create array of image paths and descriptions */
var pics= new Array(img_num)

for(i=0; i<img_num;i++){
pics[i]=images[i].src 
}

// Generate random number based on time and date
function get_random(maxNum){
if (Math.random && Math.round){
var ranNum= Math.round(Math.random()*(maxNum-1));
ranNum+=1;
return ranNum;
}
else{
today= new Date();
hours= today.getHours();
mins= today.getMinutes();
secn= today.getSeconds();
if (hours==19)
hours=18;
var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
return ranNum;
}
}

/*get a random number */
var choose_one= get_random(img_num); 
choose_one--;

function get_ImageHome(){
if (document.images){
document.getElementById(img_holder).innerHTML = "<img src='"+pics[choose_one]+"' width='"+pic_widthHome+"' height='"+pic_heightHome+"' alt='Nunavut Parks'>";
}
}
