var countDownInterval=3;
var imgSource = 'modules/Webcam/image.php';
var refreshed = true;


function countDown(){
	counter=setTimeout("reloadImage()", countDownInterval * 1000);
}

function reloadImage(notagain)
{
	imgSourceWithTime = imgSource + '?' + (new Date()).getTime();
	$('#Webcam_camImage').add('#Webcam_frontpage').get(0).src = imgSourceWithTime;
	refreshed = true
	
	if (!notagain && $('#Webcam_camImage').get(0))
	{
		countDown();
	}
}
$(document).ready(function() {
	if($('#Webcam_camImage').get(0))
	{
		countDown();
	}
	
	$('#Webcam_frontpage').mouseover(function(){
		if(refreshed)
		{
			refreshed = false;
			countDown();
		}
	});
	
	$('#Webcam_camImage').click(function(){
		reloadImage(true);
	});
});

