﻿// for use with the telerik rotator slide show

function startRotator(clientId, direction){
	var rotator = getRotator(clientId);
	
	if (!rotator.autoIntervalID){
	    rotator.autoIntervalID = window.setInterval(function(){rotator.showNext(direction);}, rotator.get_frameDuration());
    }
}
function stopRotator(clientId){
	var rotator = getRotator(clientId);
	
	if (rotator.autoIntervalID){
		window.clearInterval(rotator.autoIntervalID);
		rotator.autoIntervalID = null;
	}

}
function updateCounter(sender, args){
	var counter = document.getElementById(sender._clientStateFieldID + "_slideShowCounter");
	var count = eval(sender._clientStateFieldID + "_counter");
	var direction = sender._animationDirection;
	var length = sender.get_items().length;
	if(direction == 1) count++;
	  else if(direction == 2) count--;
	  
	if(count < 1) count = length;
	if(count > length) count = 1;  
	counter.innerHTML = count + " of " + sender.get_items().length;
	
	eval(sender._clientStateFieldID + "_counter = count;");
}
function getRotator(clientId){
	return $find(clientId);
}
