// Create a function to change our picture
function changepic() {
// Instantiate a new date object, so we can get our timestamp
var d = new Date();
// Create a new image in the DOM
var i = document.createElement('img');
var j = document.getElementById('webcamimg');
// Assign our source to the new image. We are going to append a nonsense query string, based on the current timestamp, to our image URI, in order to keep it from getting cached
i.src = "http://meteo.gilbi.it/webcam.jpg?"+d.getTime();
// Assign the same ID we assigned to our original image
i.id = j.id;
// Assign the same ALT tag we assigned to our original image
i.alt = j.alt;
// Assign the same width we assigned to our original image
i.width = j.width;
// Replace our original image with our new image
document.getElementById('webcamimg').parentNode.replaceChild(i,document.getElementById('webcamimg'));
// Set a timer to execute this function again
t = setTimeout("changepic()",60000); // The timer is currently set to 10,000 milliseconds (or 10 seconds)
}
// Instantiate our timer the first time
var t = setTimeout("changepic()",60000);