var thumbs_prefix = "http://video.cecontent.com/repo/ce_members/640x480/animated_thumbs_160x120/";
var thumb_positions = [];
var show_thumbs = false;
var current_thumb;
var cur_vid_name;
var timer;
var images = [];

function start_thumbs(img, vid_name)
{
	current_thumb = img;
	cur_vid_name = vid_name
	show_thumbs = true;
	
	// preload the thumbs for better display
	for (var i=0; i<5; i++) {
		images[i] = document.createElement('img');
		images[i].src = thumbs_prefix+cur_vid_name+"/"+vid_name+".jpg";
		images[i].style.width = '160px';
		images[i].style.height = '120px';
	}
	if (!thumb_positions[vid_name]) thumb_positions[vid_name] = 0;
	timer = setTimeout("advance_thumb()", 500);
}

function advance_thumb()
{
	if (!show_thumbs) return;
	if (thumb_positions[cur_vid_name]==4) thumb_positions[cur_vid_name] = 0;
	else thumb_positions[cur_vid_name]++;
	
	current_thumb.src = thumbs_prefix+cur_vid_name+"/"+thumb_positions[cur_vid_name]+".jpg";
	with(current_thumb.style) { width="160px"; height="120px"; }
	timer = setTimeout("advance_thumb()", 500);
}

function stop_thumbs()
{
	clearTimeout(timer);
	show_thumbs = false;
}
