// JavaScript Document
window.onload = choosePic;

var myTop = new Array("images/header1.jpg","images/header2.jpg","images/header3.jpg","images/header4.jpg");
var myPix = new Array("images/park1.jpg","images/park2.jpg","images/park3.jpg","images/park4.jpg","images/park5.jpg");
var myThumbs = new Array("imagesthumbs/park1.jpg","images/thumbs/park2.jpg","images/thumbs/park3.jpg","images/thumbs/park4.jpg","images/thumbs/park5.jpg"); 
var adURL = new Array("pages/park1.html","pages/park2.html","pages/park3.html","pages/park4.html","pages/park5.html");
var thisAd = 0;

function choosePic() {
	randomNum = Math.floor((Math.random() * myTop.length));
	document['headerimage'].src = myTop[randomNum];
	/* document['myPicture'].src = myThumbs[randomNum]; */
	/* document['prevLink'].onclick = processPrevious;
	document['nextLink'].onclick = processNext;
	
	if (document.getElementById("myPicture").parentNode.tagName == "A") {
		document.getElementById("myPicture").parentNode.onclick = newLocation;
	}
	
	rotate(); */
}

function processPrevious() {
	if (thisPic == 0) {
		thisPic = myPix.length;
	}
	thisPic--;
	document.getElementById("bigPicture").src = myPix[thisPic];
	return false;
}

function processNext() {
	thisPic++;
	if (thisPic == myPix.length) {
		thisPic = 0;
	}
	document.getElementById("bigPicture").src = myPix[thisPic];
	return false;
}

function rotate() {
	thisAd++;
	if (thisAd == myThumbs.length) {
		thisAd = 0;
	}
	document.getElementById("myPicture").src = myThumbs[thisAd];

	setTimeout("rotate()", 3 * 1000);
}

function newLocation() {
	document.location.href = "http://hwangecons.org.uk" + adURL[thisAd];
	return false;
}
