// JavaScript Document
$arrValues = [ "02", "03", "04", "05","06"];

function setDir(dir){
	$dir = dir;
	}

function setImg(img,i){
	$img = img;
	$thumbCount = i;
	}

function startLoop() {
	$timer = setTimeout( "endLoop();", 500);
	var newPath = $dir + $img.attr("alt") + "/" + $arrValues[$thumbCount] + ".jpg";
	$img.attr({ src: newPath });
}

function endLoop() {
	if($thumbCount < $arrValues.length-1 ){
		$thumbCount++;
		startLoop();
		} else{
		loopStop();
		}
} 

function loopStop(){
	clearTimeout($timer);
	$thumbCount = 0;
	var newPath = $dir + $img.attr("alt") + "/01.jpg";	
	$img.attr({ src: newPath });
	}
