
if (document.images)
{
	homeOn = new Image(125,60);
	homeOn.src="images/home_on.png";
	homeOff = new Image(125,60);
	homeOff.src="images/home_off.png";
	
	aboutOfficeOn = new Image(125,60);
	aboutOfficeOn.src="images/aboutoffice_on.png";
	aboutOfficeOff = new Image(125,60);
	aboutOfficeOff.src="images/aboutoffice_off.png";
	
	aboutStaffOn = new Image(125,60);
	aboutStaffOn.src="images/aboutstaff_on.png";
	aboutStaffOff = new Image(125,60);
	aboutStaffOff.src="images/aboutstaff_off.png";

	treatmentOn = new Image(125,60);
	treatmentOn.src="images/treatment_on.png";
	treatmentOff = new Image(125,60);
	treatmentOff.src="images/treatment_off.png";

	contactOn = new Image(125,60);
	contactOn.src="images/contact_on.png";
	contactOff = new Image(125,60);
	contactOff.src="images/contact_off.png";

        navPauseOn = new Image(100,30);
	navPauseOn.src="images/navpause_on.png";
	navPauseOff = new Image(100,30);
	navPauseOff.src="images/navpause_off.png";

}

var interval = 2500;
var random_display = 0;
var imageDir = "images/tour/";

var imageNum = 0;
imageArray = new Array();
imageArray[imageNum++] = new imageItem(imageDir + "tour1.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "tour2.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "tour3.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "tour4.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "tour5.jpg");
imageArray[imageNum++] = new imageItem(imageDir + "tour6.jpg");

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() {
	if (imageNum != 0) {
		imageNum = (imageNum-1) % totalImages;
	} else {
		imageNum = (totalImages - 1);
	}
	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 doWidthChangeMem(elem,startWidth,endWidth,steps,intervals,powr) { 
//Width changer with Memory by www.hesido.com
    if (elem.widthChangeMemInt)
	window.clearInterval(elem.widthChangeMemInt);
    var actStep = 0;
    elem.widthChangeMemInt = window.setInterval(
	function() { 
	  elem.currentWidth = easeInOut(startWidth,endWidth,steps,actStep,powr);
	  elem.style.width = elem.currentWidth + "px"; 
	  actStep++;
	  if (actStep > steps) window.clearInterval(elem.widthChangeMemInt);
	} 
	,intervals)
}

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) { 
//Generic Animation Step Value Generator By www.hesido.com 
    var delta = maxValue - minValue; 
    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
    return Math.ceil(stepp) 
    } 

function widthChange(elem) { 


    myelem = document.getElementById(elem);

    if (!myelem.currentWidth) myelem.currentWidth = 200; 
	//if no memory is set, set it first; 
    doWidthChangeMem(myelem,myelem.currentWidth,250,10,10,0.7); 
    } 
function widthRestore(elem) { 
    myelem = document.getElementById(elem);
    if (!myelem.currentWidth) return; 
    doWidthChangeMem(myelem,myelem.currentWidth,200,10,10,0.7); 
    }


function pressIt(imgName) {
	if (document.images) {
		newSrc=eval(imgName + "On.src");
		document[imgName].src= newSrc;
	}
}

function unpressIt(imgName) {
	if (document.images) {
		newSrc=eval(imgName + "Off.src");
		document[imgName].src= newSrc;
	}

}


