image_path = "assets/templates/kresiva/rotate/"; //the base "path/name" of the image set without the numbers
image_type = "gif"; //"gif" or "jpg" or whatever your browser can display
first_image = 0; //first image number
last_image = 11; //last image number
delay = 4100;
current_image = first_image; //number of the current image
timeID = null;

if (first_image > last_image) 
	{
	var help = last_image;
	last_image = first_image;
	first_image = help;
	};

leftImages = new Array();
left2Images = new Array();
rightImages = new Array();
right2Images = new Array();
for (var i = first_image; i <= last_image; i++) 
	{
	leftImages[i] = new Image();
	leftImages[i].src = image_path + "left" + i + "." + image_type;
	left2Images[i] = new Image();
	left2Images[i].src = image_path + "left_left" + i + "." + image_type;
	rightImages[i] = new Image();
	rightImages[i].src = image_path + "right" + i + "." + image_type;
	right2Images[i] = new Image();
	right2Images[i].src = image_path + "right_right" + i + "." + image_type;
	};

function calc(A)
	{
	now = A;
	if (A > last_image) {
		A = A - last_image - 1;
		}
	if (A < first_image) {
		A = last_image + A + 1;
		}
	return A;
	}

function display_img(number)
	{
	left2_image = calc(number-2);
	left_image = calc(number-1);
	current_image = calc(number);
	right_image = calc(number+1);
	right2_image = calc(number+2);
	document.left2.src = left2Images[left2_image].src;
	document.left.src = leftImages[left_image].src;
	document.right.src = rightImages[right_image].src;
	document.right2.src = right2Images[right2_image].src;
	clearTimeout (timeID)
	}

function animate_fwd() 
	{
	current_image++;
	if(current_image > last_image)
		{ 
		current_image = first_image; 
		};
	display_img(current_image)
	timeID = setTimeout("animate_fwd()", delay);
	}

function animate_rev() 
	{
	current_image--;
	if(current_image < first_image)
		{ 
		current_image = last_image; 
		};
	display_img(current_image)
	timeID = setTimeout("animate_rev()", delay);
	}




function showlr(L){
if(document.layers)document.layers[L].visibility='show'
else document.getElementById(L).style.visibility='visible'}
function hidelr(L){
if(document.layers)document.layers[L].visibility='hide'
else document.getElementById(L).style.visibility='hidden'}








