﻿var thumbs=new Array();var stat=new Array();var thumb=new Array();
function rt(i,str)
{var loop=0;
	if (stat[str])
	{
		while ((thumbs[str][i]==0 || i>=4) && loop<100)
		{if (i>=4){i=0;}else{i++;}loop++;}

		if (thumb[str][i].complete)
		{	document.getElementById(str).src=thumb[str][i].src;
			setTimeout("rt("+(i+1)+",'"+str+"')",500);
		}
		else{setTimeout("rt("+i+",'"+str+"')",20);}
	}
}
function lt(url,str,j)
{if(stat[str]){thumb[str][j].src=url;}}
function slideOn(str,ta,te)
{	stat[str]=1;
	var num;
	var first=1;

	for(var j=0;j<16;j++)
	{ if (thumbs[str][j]==1)
		{ thumb[str][j]=new Image();
			num=j+1;
			if (first) { first=0; lt(ta+num+te,str,j); }
			else { setTimeout("lt('"+ta+num+te+"','"+str+"',"+j+")",j*50); }
		}
	}
	rt(0,str);
}
function slideOff(str){stat[str]=0;}
// new code
var currentResult = 0; var timerIdThumb = 0; var thumbIndex = 2;
function th(id) {
    if (currentResult != id) {
        currentResult = id;
        if (timerIdThumb) { clearTimeout(timerIdThumb); }
        timerIdThumb = setTimeout('tr(' + id + ')', 200);
    }
}
function to(id) {
    currentResult = 0;
    clearTimeout(timerIdThumb);
    timerIdThumb = 0;
}
function tr(id) {
    var img = document.getElementById('thb' + id);
    var thumbIndex = window['thb' + id + '_id'];
    var preload = new Image();
    if (window['thb' + id + '_' + thumbIndex] == null) { thumbIndex = 1; }
    preload.src = window['thb' + id + '_' + thumbIndex];
    img.src = window['thb' + id + '_' + thumbIndex];
    timerIdThumb = setTimeout('tr(' + id + ')', 600);
    thumbIndex++;
    if (thumbIndex > 4) { thumbIndex = 1; }
    window['thb' + id + '_id'] = thumbIndex;
}