	var colNow = 1;
	var rowNow = 1;
	var animateTimeOut; // the variable that holds the TimeOut


	
// 2D Array of Advert Tile Locations
// aaTiles[row][col] where row or col start at 1!!!!
var aaTiles = new Array(4);
aaTiles[1] = new Array(5);
aaTiles[2] = new Array(5);
aaTiles[3] = new Array(5);

// Row ONE
aaTiles[1][1] = "";
aaTiles[1][2] = "";
aaTiles[1][3] = "";
aaTiles[1][4] = "";

// Row TWO
aaTiles[2][1] = "";
aaTiles[2][2] = "";
aaTiles[2][3] = "";
aaTiles[2][4] = "";

// Row THREE
aaTiles[3][1] = "";
aaTiles[3][2] = "";
aaTiles[3][3] = "";
aaTiles[3][4] = "";


	
	// This function:
	//   finds the next thumb in the grid
	//   Checks if its a blank image
	//   if its not blank it replaces it
	function animateGrid()
	{
		// Check if the grid is full of blank gifs
		if ( isGridEmpty() )
			loadRndmGrid(); // reload with images
		
		// Get the Col and Row of the next image
		
		// If we're already on the last column
		if (colNow > 3)
		{
			colNow = 0; // set us back to the first column
			rowNow++; // Drop down a row
		}
		// If we've dropped off the bottom row
		if (rowNow > 3)
		{
			rowNow = 1; // jump back up to the top row
		}
		// Finally increment one column to the right
		colNow++;
		
		// Check if theres a Tile ontop of this cell
		if (aaTiles[rowNow][colNow] == "TILE")
		{
			//alert("Cell [" + rowNow + "] [" + colNow + "]");
			clearTimeout(animateTimeOut); // dont wait!
			animateGrid(); // go and look at the next image
			return;
		}
		
		// get the ThumbImage object
		var oThisThumb = returnObjById( "imgC" + colNow + "R" + rowNow );
		
		// if its a blank image leave it alone
		if (oThisThumb.src.indexOf("Clear.gif") > 1 )
		{
			clearTimeout(animateTimeOut); // dont wait!
			animateGrid(); // go and look at the next image
		}
		else
		{ // The current image is a picture so replace it
			oThisThumb.src = getPercentageImage(85); // 15% chance we'll replace it with a blank image
			animateTimeOut = setTimeout('animateGrid()', 350); // repeat the whole function after 1/4 of a sec
		}
		
		return;		
	}
	
	
	// Checks to see if the grid has any images in it
	function isGridEmpty()
	{
		for (row=1; row<4; row++)
		{
			for (col=1; col<5; col++)
			{
				// Ignore images under a Tile
				if ( aaTiles[row][col] == "TILE" ) continue;
				// Get the image
				var imageSrc = returnObjById( "imgC" + col + "R" + row ).src;
				
				if (imageSrc.indexOf("Clear.gif") < 1)
					return false;
			}
		}
		return true;
	}
	
	// Loads a random image into every cell in the grid
	function loadRndmGrid()
	{
		for (row=1; row<4; row++)
		{
			rowNow = row;
			for (col=1; col<5; col++)
			{
				colNow = col;
				returnObjById( "imgC" + col + "R" + row ).src = getPercentageImage(99); // higher the number the fuller the grid
			}
		}
	}
	
	// Returns the Path and Filename (.src) to a Thumbnail
	// there is a "percentVal" chance of it being an image
	// there is a "100 - percentVal" chance of it being an image
	function getPercentageImage( percentVal )
	{
		if (getRndm(100) < percentVal )
		{
			var imagePath = "/SCI_Website/HomePage/HomePageThumbs";
			
			var test = getRndm(3);
			if (test == 1)
				imagePath = "/SCI_Website/HomePage/HomePageThumbs_" + rowNow + "0";
			if (test == 2)
				imagePath = "/SCI_Website/HomePage/HomePageThumbs_" + rowNow + "5";
				
			var rndImgSrc = aaImage[ (getRndm( aaImage.length ) - 1) ];
			
			return (imagePath + "/" + rndImgSrc);
		
		} else {
			return "/SCI_Website/HomePage/HomePageThumbs/Clear.gif";
		}
	}
	
	function getRndm(maxVal)
	{
		if (null == maxVal)
			maxVal = 99;
		else
			maxVal--;
		return Math.round( Math.random() * maxVal + 1);
	}
	
	function returnObjById( id ) 
	{ 
	    if (document.getElementById) 
	        var returnVar = document.getElementById(id); 
	    else if (document.all) 
	        var returnVar = document.all[id]; 
	    else if (document.layers) 
	        var returnVar = document.layers[id]; 
	    return returnVar; 
	}
	
	
// Array of images
var aaImage = new Array();
aaImage[0] = "100.gif";
aaImage[1] = "101.gif";
aaImage[2] = "102.gif";
aaImage[3] = "103.gif";
aaImage[4] = "104.gif";
aaImage[5] = "108.gif";
aaImage[6] = "113.gif";
aaImage[7] = "118.gif";
aaImage[8] = "121.gif";
aaImage[9] = "122.gif";
aaImage[10] = "132.gif";
aaImage[11] = "134.gif";
aaImage[12] = "16.gif";
aaImage[13] = "18.gif";
aaImage[14] = "19.gif";
aaImage[15] = "195.gif";
aaImage[16] = "197.gif";
aaImage[17] = "20.gif";
aaImage[18] = "220.gif";
aaImage[19] = "224.gif";
aaImage[20] = "225.gif";
aaImage[21] = "226.gif";
aaImage[22] = "230.gif";
aaImage[23] = "232.gif";
aaImage[24] = "233.gif";
aaImage[25] = "234.gif";
aaImage[26] = "237.gif";
aaImage[27] = "239.gif";
aaImage[28] = "241.gif";
aaImage[29] = "257.gif";
aaImage[30] = "258.gif";
aaImage[31] = "259.gif";
aaImage[32] = "260.gif";
aaImage[33] = "261.gif";
aaImage[34] = "262.gif";
aaImage[35] = "263.gif";
aaImage[36] = "264.gif";
aaImage[37] = "265.gif";
aaImage[38] = "266.gif";
aaImage[39] = "267.gif";
aaImage[40] = "268.gif";
aaImage[41] = "269.gif";
aaImage[42] = "272.gif";
aaImage[43] = "275.gif";
aaImage[44] = "276.gif";
aaImage[45] = "33.gif";
aaImage[46] = "34.gif";
aaImage[47] = "37.gif";
aaImage[48] = "39.gif";
aaImage[49] = "42.gif";
aaImage[50] = "47.gif";
aaImage[51] = "48.gif";
aaImage[52] = "49.gif";
aaImage[53] = "51.gif";
aaImage[54] = "52.gif";
aaImage[55] = "53.gif";
aaImage[56] = "54.gif";
aaImage[57] = "59.gif";
aaImage[58] = "60.gif";
aaImage[59] = "61.gif";
aaImage[60] = "62.gif";
aaImage[61] = "67.gif";
aaImage[62] = "70.gif";
aaImage[63] = "71.gif";
aaImage[64] = "77.gif";
aaImage[65] = "79.gif";
aaImage[66] = "81.gif";
aaImage[67] = "82.gif";
aaImage[68] = "90.gif";
aaImage[69] = "91.gif";
aaImage[60] = "92.gif";

aaImage[70] = "anniversary 2.gif";
aaImage[71] = "AnnRev02(GatesheadBridge).gif";
aaImage[72] = "BigBen(1).gif";
aaImage[73] = "bridge.gif";
aaImage[74] = "Composite article 1 picture.gif";
aaImage[75] = "Composite article 2 picture.gif";
aaImage[76] = "Construction site 1.gif";
aaImage[77] = "cover P334.gif";
aaImage[78] = "Daswon_pus_pull2.gif";
aaImage[79] = "dcibridgearticle.gif";
aaImage[80] = "DesCompBeamsP287 cover.gif";
aaImage[81] = "Des_Man_Struct_S_Steel_EP30.gif";
aaImage[82] = "DSS building, Leeds (courtesy AvestaPolarit).gif";
aaImage[83] = "Endevour_House_Learning_from_the_best.gif";
aaImage[84] = "EP32_cover.gif";
aaImage[85] = "fibreconc2.gif";
aaImage[86] = "fibreconc4.gif";
aaImage[87] = "Fire (courtesy of Corus)(1).gif";
aaImage[88] = "Fridge recycling plantmrs.gif";
aaImage[89] = "GKRarticlepicture.gif";
aaImage[90] = "HibiscusPLATFORM_Trinidad-BG.gif";
aaImage[91] = "image001.gif";
aaImage[92] = "Intro_to_SW_Des_P325 cover.gif";
aaImage[93] = "intumes1.gif";
aaImage[94] = "Intumes2.gif";
aaImage[95] = "JAM7.gif";
aaImage[96] = "JAM_Birthday_image015.gif";
aaImage[97] = "jrackhamimage1.gif";
aaImage[98] = "Leaf.gif";
aaImage[99] = "Letter_SGii_Beam_Exploded.gif";
aaImage[100] = "lillie04(1).gif";
aaImage[101] = "Maidenhead Roof.gif";
aaImage[102] = "mdh urban location pic .gif";
aaImage[103] = "MID_CITY_Place.gif";
aaImage[104] = "NFATECover.gif";
aaImage[105] = "P062 6th edition cover.gif";
aaImage[106] = "P185 STEEL BRIDGE COVER.gif";
aaImage[107] = "P332 COV final_1.gif";
aaImage[108] = "P336 COV OUTER final.gif";
aaImage[109] = "p343promoimage.gif";
aaImage[110] = "P346FAA.gif";
aaImage[111] = "P347Cover.gif";
aaImage[112] = "Portal Frames Cover-23-07-04.gif";
aaImage[113] = "Quicon Image.gif";
aaImage[114] = "raines dairy03.gif";
aaImage[115] = "Recyclingnrb.gif";
aaImage[116] = "SBGcoverpic.gif";
aaImage[117] = "stalabuildphotographfinal(1).gif";

aaImage[118] = "SteelInArchitecture_Image1.gif";
aaImage[119] = "SteelInArchitecture_Image10.gif";
aaImage[120] = "SteelInArchitecture_Image13.gif";
aaImage[121] = "SteelInArchitecture_Image20.gif";
aaImage[122] = "SteelInArchitecture_Image23.gif";
aaImage[123] = "SteelInArchitecture_Image24.gif";
aaImage[124] = "SteelInArchitecture_Image25.gif";
aaImage[125] = "SteelInArchitecture_Image26.gif";
aaImage[126] = "SteelInArchitecture_Image27.gif";
aaImage[127] = "SteelInArchitecture_Image4.gif";
aaImage[128] = "SteelInArchitecture_Image5.gif";
