var reloadInterval = 5;
var i = 0;
var webcamurl;
var active;

window.onload = init;

function init()
{
	if (document.images["webcamimage"])
	{
		webcamurl = document.images["webcamimage"].src;
		active = window.setInterval("reloadImage()", 1000);
	}
}

function reloadImage()
{
	currentSecond = i % reloadInterval;
	
	if(currentSecond == 0)
	{
		if (document.images["webcamimage"]) {
			document.images["webcamimage"].src = webcamurl + '?' + i;
		}
	}
	
	document.html.seconds.value = reloadInterval - currentSecond;
	
	i++;
}
