currentStatus = "play";
currentPosition = 1;
changing = false;
transitionTime = 10000;
hlTimer = setInterval("hlRotator()", transitionTime);
imgArr = new Array();

function hlPlay(){
	if(currentStatus == "pause"){
		currentStatus = "play";
		$("pause").style.display = "block";
		$("play").style.display = "none";
		hlRotator();
		hlTimer = setInterval("hlRotator()", transitionTime);
	}
}

function hlPause(){
	if(currentStatus == "play"){
		currentStatus = "pause";
		$("pause").style.display = "none";
		$("play").style.display = "block";
		clearInterval(hlTimer);
	}
}

function hlNext(){
	if(hlTimer){
		clearInterval(hlTimer);
	}
	if(imgArr.length > 1){
		if(currentPosition < imgArr.length){
			currentPosition++;
			img = new Image();
			img.src = imgArr[currentPosition-1];
			img.onLoad = setImg(img.src);
		} else {
			currentPosition = 1;
			img = new Image();
			img.src = imgArr[currentPosition-1];
			img.onLoad = setImg(img.src);
		}
	}
	if(currentStatus == "play"){
		hlTimer = setInterval("hlRotator()", transitionTime);
	}
}

function hlPrev(){
	if(hlTimer){
		clearInterval(hlTimer);
	}
	if(imgArr.length > 1){
		if(currentPosition > 1){
			currentPosition--;
			img = new Image();
			img.src = imgArr[currentPosition-1];
			img.onLoad = setImg(img.src);
		} else {
			currentPosition = imgArr.length;
			img = new Image();
			img.src = imgArr[currentPosition-1];
			img.onLoad = setImg(img.src);
		}
	}
	if(currentStatus == "play"){
		hlTimer = setInterval("hlRotator()", transitionTime);
	}
}

function hlSetImage(img_target){
	if(hlTimer){
		clearInterval(hlTimer);
	}
	currentPosition = img_target+1;
	img = new Image();
	img.src = imgArr[img_target];
	img.onLoad = setImg(img.src);
	if(currentStatus == "play"){
		hlTimer = setInterval("hlRotator()", transitionTime);
	}
}

function hlRotator(){
	if(imgArr.length > 1){
		if(currentPosition < imgArr.length){
			currentPosition++;
			img = new Image();
			img.src = imgArr[currentPosition-1];
			img.onLoad = setImg(img.src);
		} else {
			currentPosition = 1;
			img = new Image();
			img.src = imgArr[currentPosition-1];
			img.onLoad = setImg(img.src);
		}
	}
}

function setImg(imgSrc){
	if(changing == false){
		changing = true;
		new Effect.Fade($("highlights_img"), {duration:1, 
			afterFinish: function(){
				$("highlights_img").src = imgSrc;
				for(i=1; i<=imgArr.length; i++){
					$("hlButton"+i).className = "button";
				}
				$("hlButton"+currentPosition).className = "button_selected";
				new Effect.Appear($("highlights_img"), {duration:1, 
					afterFinish: function(){
						changing = false;
					}
				});
			}
		});
	} else {
		toDo = "setImg('"+imgSrc+"')";
	}
}