// Rotator Script

var interval = 4;
var random_display = 0;
interval *= 1000;
// create the array of images
var image_index = 0;
imgList = new Array();
imgList[image_index++] = new imageItem("images/01.jpg");
//imgList[image_index++] = new imageItem("images/02.jpg");
// create the array of image URLs
var url_index = 0;
urlList = new Array();
urlList[url_index++] = new imageItem("http://www.bikearlington.com/");
//urlList[url_index++] = new imageItem("http://www.bikearlington.com/btwd08.cfm");
//
var number_of_url = urlList.length;
var number_of_image = imgList.length;

function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
//
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function get_UrlItemLocation(imageObj) {
return(imageObj.image_item.src)
}
//
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
//
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(imgList[image_index]);
return(new_image);
}

function getNextUrl() {
if (random_display) {
url_index = generate(0, number_of_url-1);
}
else {
url_index = (url_index+1) % number_of_url;
}
var new_url = get_UrlItemLocation(urlList[url_index]);
return(new_url);
}
//
var newURL;
function rotateImage(place) {
var new_image = getNextImage();
newURL = getNextUrl();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}

function goURL(){
	window.location = newURL;
}