// Script created by Nick Beech
// www.nbWebsiteDesign.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 39
// This includes all images of dogs, cats and wild animals

function getnumber() {
return Math.ceil(Math.random()*39);
}
// assign random numbers to 3 variables
pic1var = getnumber();
pic2var = getnumber();
pic3var = getnumber();
// add 1 to 2nd variable if it's the same as 1st variable
if (pic1var == pic2var) {
	pic2var += 1;
	}
// if 2nd variable after amending is > 39, deduct 5
if (pic2var > 39) {
	pic2var -= 5;
	}
// amend 3rd variable if it's the same as 1st or 2nd variable
while (pic3var == pic1var || pic3var == pic2var) {
	pic3var += 1;
// deduct 5 if 3rd variable is > 39 after amending
	if (pic3var > 39) {
			pic3var -= 5;
			}
	}
pic1var = "allanimals/rspca" + pic1var;
pic2var = "allanimals/rspca" + pic2var;
pic3var = "allanimals/rspca" + pic3var;


function showTable(){
	tableScript = "";
	tableScript = tableScript + ("<table width='540' border='0' align='center'><tr>");
	tableScript = tableScript + ("<td width='180'>");
	tableScript = tableScript + ("<img src='images/" + pic1var + ".jpg' alt='RSPCA random image' ");
	tableScript = tableScript + ("width='160' height='120' border='1'></td><td width='180'>");
	tableScript = tableScript + ("<img src='images/" + pic2var + ".jpg' alt='RSPCA random image' ");
	tableScript = tableScript + ("width='160' height='120' border='1'></td><td width='180'>");
   	tableScript = tableScript + ("<img src='images/" + pic3var + ".jpg' alt='RSPCA random image' ");
	tableScript = tableScript + ("width='160' height='120' border='1'></td></tr></table>");
	document.write(tableScript);
}