var timer_expired = true;
var image_loaded1 = false;
var image_loaded2 = false;
var image_loaded3 = false;
/*var image_loaded1 = true;
var image_loaded2 = true;
var image_loaded3 = true;*/

function fnGetFormInputField(strFieldName)
{
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) 
	{
		theform = document.forms["Form1"];
	}
	else 
	{
		theform = document.Form1;
	}
	return eval("theform." + strFieldName)
}

function nextPicture()
{
	var pictNum = parseInt(fnGetFormInputField("nextUpdatePict").value) + 1;
	if (pictNum > fnGetFormInputField("maxUpdatePict").value)
	{
		pictNum = 1;
	}
	fnGetFormInputField("nextUpdatePict").value = pictNum;
	if (pictNum > 9)
	{
		return "updimg/foto_" + pictNum + ".jpg";
	} else {
		return "updimg/foto_0" + pictNum + ".jpg";
	}
}

function pictureLoaded(intPos)
{
	if (intPos==1)
	{
		image_loaded1 = true;
	} else {
		if (intPos==2) 
		{
			image_loaded2 = true;
		} else {
			image_loaded3 = true;
		}
	}
}

function updatePictures()
{
	if (timer_expired)
	{
		timer_expired = false;
		if (image_loaded1)
		{
			document.updvis1.src = document.updhid1.src;
			image_loaded1 = false;
			document.updhid1.src = nextPicture();
		}
		if (image_loaded2)
		{
			document.updvis2.src = document.updhid2.src;
			image_loaded2 = false;
			document.updhid2.src = nextPicture();
		}
		if (image_loaded3)
		{
			document.updvis3.src = document.updhid3.src;
			image_loaded3 = false;
			document.updhid3.src = nextPicture();
		}
		setTimeout('timeout()',8000);
	}
}

function timeout()
{
  timer_expired = true;
  updatePictures();
}
