var img_pos = 0;
var slshw = null;
var slshw2 = null;
var img_list = null;
var obj_img = new Image();
var completeCounter = 0; // Workaround for Safari, missing the 'complete' property.

function showimage(imgnum)
{
	if (slshw2 != null) window.clearTimeout(slshw2);
		slshw2 = null;
//		obj_ID = document.getElementById('href'+img_pos);
//		if ((typeof obj_ID == "object" ) && (obj_ID != null)) {
//			DEBUGDisplayObject(obj_ID.style, 1);
//			obj_ID.style.fontWeight = 'normal';
//		} else alert("Can't find object 'href"+img_pos+"' in showimage.");
		while (true) {
			if (imgnum >= img_list.length) imgnum = 0;
			if (img_list[imgnum].length > 0) break;
			imgnum ++;
		}
		img_pos = imgnum;
//		DEBUGDisplayObject(obj_img, 1);
//alert ('Requesting image '+imgnum+': '+img_list[imgnum]);
//		newimg = 
//		newimg.src = str_path+img_list[imgnum];
		obj_img.src = str_path+img_list[img_pos];
		slshw = window.setTimeout('presentimage()',1000);
	return false;
}

function presentimage()
{
//alert ('Called');

	if(obj_img.complete || (completeCounter >= 3)) {
		window.clearTimeout(slshw);
		completeCounter = 0;
		slshw = null;
//		obj_ID = document.getElementById('href'+img_pos);
//		if ((typeof obj_ID == "object" ) && (obj_ID != null)) {
//			DEBUGDisplayObject(obj_ID.style, 1);
//			obj_ID.style.fontWeight = 'bold';
//		} else alert("Can't find object 'href"+img_pos+"' in presentimage.");
		if (slshw2 != null) window.clearTimeout(slshw2);
		slshw2 = null;
		slshw2 = window.setTimeout('showimage(img_pos+1)', delay);
//alert ('Done '+newimg.src);
	} else {
		completeCounter++
//		alert(obj_img.src+" not ready.");
	slshw = window.setTimeout('presentimage()',1000);
	}
}

function nextimage()
{
	if (slshw == null) showimage(img_pos + 1);
	return true;
}

function stepshow(imgnum)
{
	obj_img = document.getElementById('imgtarget');
	if ((typeof obj_img == "object" ) && (obj_img != null)) {
		img_pos = imgnum;
		slshw2 = window.setTimeout('showimage(img_pos+1)',delay);
	} else alert("Can't find object 'imgtarget'.");
	return true;
}