var images = new Array('images/banners/new/1.jpg', 'images/banners/new/2.jpg');
var imageloaded = new Array(false, false);
var curId = 0;

function preLoadImages()
{
	++curId;
	preLoadImage(curId);
}

function preLoadImage(id)
{
	if (id == 2) setTimeout("rotateImage();", 12000);
	imageloaded[id-1] = true;
	//0 = <img> already so start at 1.
	if (id < images.length)
	{
		var img = new Image();
		img.src = images[id];
		img.onload = preLoadImages;
		images[id] = img;
	}
}

//var imageIndex = parseInt(Math.random() * (images.length - 1));
var imageIndex = -1;

function rotateImage()
{
	imageIndex = (imageIndex + 1) % images.length;
	if (imageIndex == 0) imageIndex++;
	if (imageloaded[imageIndex] != false && imageIndex != 0) 
		document.getElementById('topbanner').src = images[imageIndex].src;
	setTimeout("rotateImage();", 12000);
}