function show(id) {
	var intid = document.getElementById(id);
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('dynmenu'+i)) {document.getElementById('dynmenu'+i).style.display='none';}
		}
	if (intid) {intid.style.display='block';}
}//end function

var mainScriptTime;
var intervalLength = 6000;	// (12000) No. milliseconds (12)  before retiling
var imageCounter = 0;		//track of the last image attempted to be drawn
						//in case an image is drawn over another image in the
						//process of being drawn - this makes sure images
						//don't get garbled
var intTransitionCount = 0;		//If this number exceeds 1, no transitions will take
							//place untill only 1 remains
var imageWidth = 306;		//make sure imageVSections into imageWidth has a modulus of 0
var imageHeight = 171;		//make sure imageHSections into imageHeight has a modulus of 0

var imageVSections = 3;		//how many sections verticaly you want the image to be made of
var imageHSections = 3;		//how many sections horizontaly you want the image to be made of

var imageList = new Array();	//Global array of all images used (relative addressing)

imageList[0] = "images/vans.jpg";
// imageList[1] = "images/twovans.jpg";
imageList[1] = "images/vivary-gates-2s.jpg";

var Hoffset, Voffset;	//Horizontal and Vertical offset of the image map placement
Hoffset = 350;
var addedOffset = 5;
//Voffset = 10;

var ScreenWidth = screen.width; // for IE hack if screen width 800

function tilelogo()
	//Constructs the Image according to the Global Variables
	//Starts Timer
{



	if(window.innerWidth != undefined)
	{
		//Not IE browser
		Hoffset = window.innerWidth;
		addedOffset = 5;
	}//end if
	else
	{

		if(document.documentElement.clientWidth != undefined)
		{
			//IE6
			Hoffset = document.documentElement.clientWidth;

			// IE returns screen width - 21 (1003 if width is 1024)

			// IE hack: if screen width only 800 adjust 11 pixels to right
			if (ScreenWidth == 800)
			{
				addedOffset = addedOffset + 11;
			}


		}//end if
		else
		{
			if(document.body.clientWidth != undefined)
			{
				//IE4
				Hoffset = document.body.clientWidth;

				// IE hack: if screen width only 800 adjust 11 pixels to right
				if (ScreenWidth == 800)
				{
					addedOffset = addedOffset + 11;
				}

			}//end if
		}//end else
	}//end else

	Hoffset = Hoffset/2;

	Hoffset = Hoffset - (imageWidth/2);

	Voffset = document.getElementById("contentarea").offsetTop  + document.getElementById("centre").offsetTop;
	Voffset = Voffset + 3;

	Hoffset = Hoffset + addedOffset;

	var imgH = 0, imgV = 0;
	for(imgV = 0; imgV < imageVSections; imgV++)
	{
		for(imgH = 0; imgH < imageHSections; imgH++)
		{
			var divName = "divV" + imgV + "H" + imgH;
			eval("var " + divName + " = document.createElement('div');");
			eval(divName + ".setAttribute('id'," + divName + ")");
			eval("document.body.appendChild(" + divName + ");");

			var tempDiv;
			eval("tempDiv = document.getElementById(" + divName + ")");

			tempDiv.name = divName;
			tempDiv.id = divName;
			tempDiv.style.display = "none";
			tempDiv.style.width = imageWidth/imageHSections + "px";
			tempDiv.style.height = imageHeight/imageVSections + "px";
			tempDiv.style.overflow = "hidden";
			tempDiv.style.position = "absolute"
			//tempDiv.style.backgroundColor = "red";
			tempDiv.style.backgroundImage = "url(" + imageList[0] + ")";
			tempDiv.style.left = parseInt(Hoffset + (imgH*(imageWidth/imageHSections))) + "px";
			tempDiv.style.top = Voffset + (imgV*(imageHeight/imageVSections)) + "px";
			tempDiv.style.backgroundRepeat = "repeat";

			//For Some reason images start at 0,0 in the top left hand corder... but all other coordinates are negative :|
			tempDiv.style.backgroundPosition = "-" + imgH*(imageWidth/imageHSections) + "px -" + imgV*(imageHeight/imageVSections) + "px";

			tempDiv.style.display = "block";
		}//end for
	}//end for
	document.getElementById("imgVans").style.display = "none";
	setTimeout("imagesAnimation3x3_Speckle2();", intervalLength);
	// clearInterval(showtime);	//used to stop the looping, if needed
}//end function

function tileRePosition()
{
	Voffset = document.getElementById("contentarea").offsetTop  + document.getElementById("centre").offsetTop;
	Voffset = Voffset + 3;
	var imgH = 0, imgV = 0;

	for(imgV = 0; imgV < imageVSections; imgV++)
	{
		for(imgH = 0; imgH < imageHSections; imgH++)
		{
			var divName = "divV" + imgV + "H" + imgH;
			var tempDiv;
			tempDiv = document.getElementById(divName);

			tempDiv.style.display = "none";
			tempDiv.style.left = Hoffset + (imgH*(imageWidth/imageHSections));
			tempDiv.style.top = Voffset + (imgV*(imageHeight/imageVSections));

			tempDiv.style.display = "block";
		}//end for
	}//end for
}//end function

function incrementImageNo()
	//increments imageCounter unless will be greater than image
	//count in array, then sets it to 0
{
	if(imageCounter + 1 >= imageList.length)
	{
		imageCounter = 0;
	}//end if
	else
	{
		imageCounter++;
	}//end else
}//end if

function imagesAnimation3x3_Speckle2()
{
	incrementImageNo();
	var setTime = 500;
	setTimeout("document.getElementById('divV0H1').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 0*setTime);
	setTimeout("document.getElementById('divV2H0').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 1*setTime);
	setTimeout("document.getElementById('divV1H2').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 2*setTime);
	setTimeout("document.getElementById('divV1H0').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 3*setTime);
	setTimeout("document.getElementById('divV0H2').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 4*setTime);
	setTimeout("document.getElementById('divV2H2').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 5*setTime);
	setTimeout("document.getElementById('divV0H0').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 6*setTime);
	setTimeout("document.getElementById('divV2H1').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 7*setTime);
	setTimeout("document.getElementById('divV1H1').style.backgroundImage = 'url(" + imageList[eval("imageCounter;")] + ")';", 8*setTime);
}//end if