﻿var imageIndex = 0;
var tempIndex = 0;

function RotateImages() {

	var ImageHolder1 = document.getElementById('carousel-image');	
	var linkHolder1 = document.getElementById('carousel-link');

	tempIndex = imageIndex;
	
	var highlightHolder1 = document.getElementById(imageArray[tempIndex][2]);
	
	for(c=0;c<imageArray.length;c++) {
		document.getElementById(imageArray[c][2]).className = 'carousel-normal';
	}


	ImageHolder1.src = imageArray[tempIndex][0];
	linkHolder1.href = imageArray[tempIndex][1];
	highlightHolder1.className = 'carousel-highlight';
	NextTempIndex();
	NextIndex();
}

function highlightOption(option) {
	tempIndex = option;
	imageIndex = option;
	var ImageHolder1 = document.getElementById('carousel-image');	
	var linkHolder1 = document.getElementById('carousel-link');
	
	ImageHolder1.src = imageArray[option][0];
	linkHolder1.href = imageArray[option][1];

	window.clearInterval(imageRotator);
	for(c=0;c<imageArray.length;c++) {
		document.getElementById(imageArray[c][2]).className = 'carousel-normal';
	}
	document.getElementById(imageArray[option][2]).className = 'carousel-highlight';
}

function clearHighlight() {
	window.clearInterval(imageRotator);
	imageRotator = window.setInterval('RotateImages()', 3000);
}

function haltRotator() {
	window.clearInterval(imageRotator);
}

function NextTempIndex() {
	if(tempIndex + 1 == imageArray.length) {
		tempIndex = 0;
	}
	else {
		tempIndex++;
	}
}

function NextIndex() {
	if(imageIndex + 1 == imageArray.length) {
		imageIndex= 0;
	}
	else {
		imageIndex++;
	}
}

