// Script created by Nick Beech
// www.nbWebsiteDesign.co.uk
// www.LookAndLearnTraining.com and .co.uk
// This script is copyrighted - Please ask permission to reuse

// This script generates random numbers and assigns them to variables. 
// Image names are substituted with these variables to create 
// different images each time the page is loaded.

// Function to generate random number between 1 and 13
// This includes all images of archive photos

// function to generate random number from 1 to 13
function getNumber(){
  return Math.ceil(Math.random()*13);
}
// call function and assign to variables
  var pic1var = getNumber();
  var pic2var = getNumber();
  var pic3var = getNumber();
  
// compare pic1var with pic2var and add 1 if the same
  if(pic1var == pic2var){
     pic2var = pic2var + 1;
	 }
  
// check to see if pic2var is > 12
  if(pic2var > 13){
     pic2var -=5;
	 }
  
// compare 3rd value with first two
  while(pic3var == pic1var || pic3var == pic2var){
     pic3var +=1;
	 }
  
// check to see if pic3var is >13
  if(pic3var > 13){
     pic3var -=5;
	 }
	 
// final test for matches
  if(pic3var == pic1var || pic3var == pic2var){
     pic3var +=1;
	 }
  
// create output for slideshow
var image1 = '<img src="images/archives/' + pic1var + '.jpg" alt="Archive photo" width="180" height="135" border="1" />';
var image2 = '<img src="images/archives/' + pic2var + '.jpg" alt="Archive photo" width="180" height="135" border="1" />';
var image3 = '<img src="images/archives/' + pic3var + '.jpg" alt="Archive photo" width="180" height="135" border="1" />';
  