// JavaScript Document
//--------------------
//-  SlideShow Code  -
//--------------------

//Timer.  1000 = 1 second.
var interval = 5000;
//Whether or not you want the pictures to display in random order...Boni might go for that at some point.
//0 = false, 1 = True
var random_display = 0;
//The photo Directory the photos are in
var imageDir = "http://intouchtoday.com/images/";


var imageNum = 0;
imageArray = new Array();

//This is the list of Images and Links.  Just copy these first two lines of code and paste 
//them below in the order you want them to create a longer list of photos/links.
imageArray[imageNum++] = new imageItem(imageDir + "monthly-postcard-recipe.gif");
imageArray[imageNum-1].sLink = "09february.php"
imageArray[imageNum++] = new imageItem(imageDir + "monthly-postcard-image.gif");
imageArray[imageNum-1].sLink = "09february.php"
imageArray[imageNum++] = new imageItem(imageDir + "monthly-postcard-home-tips.gif");
imageArray[imageNum-1].sLink = "09february.php"

//Don't Touch anything from here down to... :-)
var totalImages = imageArray.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 randNum(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}

function getNextImage() {
if (random_display) {
imageNum = randNum(0, totalImages-1);
}
else {
imageNum = (imageNum+1) % totalImages;
}

var new_image = get_ImageItemLocation(imageArray[imageNum]);
return(new_image);
}

function getPrevImage() {
imageNum = (imageNum-1) % totalImages;
var new_image = get_ImageItemLocation(imageArray[imageNum]);
return(new_image);
} 

function prevImage(place) {
var new_image = getPrevImage();
document[place].src = new_image;
}

function switchImage(place) {

var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "switchImage('"+place+"')";
timerID = setTimeout(recur_call, interval);

}
function link() {
window.location = imageArray[imageNum].sLink;
}

//...Here :-)
