// initBeachcam (no parameters)
// Calls updateBeachcam() when there is an image that needs to be updated
//
//  mathieu@ahaweb.nl, september 2005, modified in april 2007 for new beachcams
function initBeachcam() {
	// Find beachcam-images
	beachcamImgElement1 = document.getElementById('beachcamImg1');
	beachcamImgElement2 = document.getElementById('beachcamImg2');		
	
	// Call update-function when beachcam-images are found
	if(beachcamImgElement1 && beachcamImgElement2) {
		updateBeachcam(beachcamImgElement1, beachcamImgElement2);
	}
}

// updateBeachcam(HTML-element beachcamImg)
// Calls itself with a 5 second (5000 ms) timeout and sets source of beachcam-image with a random-id to prevent caching by browser
//
// mathieu@ahaweb.nl, september 2005,  modified in april 2007 for new beachcams
function updateBeachcam(beachcamImgElement1, beachcamImgElement2) {
	var newImg = new Image();
	var oldSrc = Array();
	
	oldSrc = beachcamImgElement1.src.split('&');
	newImg.src = oldSrc[0] + '&rand=' + Math.round(Math.random()*9999999999);
	beachcamImgElement1.src = newImg.src;

	oldSrc = beachcamImgElement2.src.split('&');
	newImg.src = oldSrc[0] + '&rand=' + Math.round(Math.random()*9999999999);
	beachcamImgElement2.src = newImg.src;
	
	setTimeout("updateBeachcam(beachcamImgElement1, beachcamImgElement2)",20000);
}
