<!--
// Webcam-Konfiguration
// picurl.push( [URL_des_Webcam_Bildes, Bild_Text, Hyperlink_wenn_Bild_angeklickt] );
var picurl = [];
// picurl.push(
// 	[  // Tennisclub Bachtobel, Zürich
// 		"http://www.tcb-tennis.ch/images/cam/neu_gross.jpg",
// 		"Plätze des Tennisclub Bachtobel, Zürich<br /><span style=\"font-size:0.8em;\">(Kamera-Standort: Clubhaus. Blick-Richtung: Ost)</span>",
// 		"http://www.tcb-tennis.ch"
// 	]
// );
// picurl.push(
// 	[  // Velo-Gody, Zürich
// 		"http://www.velogody.ch/video.jpg",
// 		"Gody's WebCam über Zürich<br /><span style=\"font-size:0.8em;\">(Kamera-Standort: Talwiesenstrasse, Zürich. Blick-Richtung: Nord-Ost)</span>",
// 		"http://www.velogody.ch"
// 	]
// );
picurl.push(
	[  // Eumetsat visuell
		"http://www.sat24.com/image.ashx?country=eu&type=loop&format=640x480001001",
//		"http://www.sat24.com/images.php?country=eu&type=loop&rnd=",
		"Wolken-Radar (visuell/Infrarot). Quelle: Sat24.com / Eumetsat<br /><span style=\"font-size:0.8em;\">(Entwicklung seit maximal 4 Stunden)</span>",
		"http://www.sat24.com"
	]
);

// Weitere Webcams: wiederhole picurl.push( [ "...","...","..." ] );

var picnbr = 0;
var spicnbr = 0;
var picElt = null;
var txtElt = null;
var refInt = 30000; // Anzeigedauer pro Bild in Millisekunden
var imgWidth = 458; // Bild-Breite in Pixels
var uid;
var fsttime = 1;
var wc_tout = null;
var wc_stopped = false;
var pbtn_on = new Image(12,12);  pbtn_on.src = "/_img/c_hold.gif";
var pbtn_off = new Image(12,12); pbtn_off.src = "/_img/c_run.gif";
txpbtn_on = ' Bild-Wechsler stoppen ';
txpbtn_off = ' Bild-Wechsler starten ';

function refreshWebcam() {
	if (!picElt) { picElt = getElt("webcam"); }
	if (!txtElt) { txtElt = getElt("pictext"); }
	if (picElt) {
		spicnbr = picnbr;
		if ( (picurl[picnbr][0]) && (picurl[picnbr][0]!="") ) {
			var mx = (picurl[picnbr][0].indexOf("?")==-1) ? "?" : "&";
			uid = new UUID(); mx += "uuid="+uid;  // unique modifier to inhbit caching
			if (!fsttime) {
				var ximg = "";
				var bplnk = ( (picurl[picnbr][2]) && (picurl[picnbr][2]!="") );
				if (bplnk) { ximg += "<a href=\"" + picurl[picnbr][2] + "\" target=\"_blank\" title=\""+goto+" '"+picurl[picnbr][2]+"'\">" };
				ximg += "<img src=\"" + picurl[picnbr][0] + mx + "\" width=\""+imgWidth+"\" />";
				if (bplnk) { ximg += "</a>"; }
				picElt.innerHTML = ximg;
			} else { fsttime = 0; }
			if ( (txtElt) && (picurl[picnbr][1]) ) { txtElt.innerHTML = picurl[picnbr][1]; }
			if (!wc_stopped) {
				picnbr++; 
				if (picnbr >= picurl.length) { picnbr=0; }
			}
			if (!isPrintMode) {
				if (wc_stopped) {
					wc_tout = window.setTimeout("refreshWebcam()", refInt * picurl.length);
				} else {
					wc_tout = window.setTimeout("refreshWebcam()", refInt);
				}
			}
		}
	}
}

function togglePresentation() {
	if (wc_stopped) { runPresentation(); } else { stopPresentation(true); }
}

function stopPresentation(settimer) {
	wc_stopped = true;
	picnbr = spicnbr;
	if (wc_tout != null) { window.clearTimeout(wc_tout); wc_tout = null; }
	if (settimer) { wc_tout = window.setTimeout("refreshWebcam()", refInt * picurl.length); }
	document.pbtn.src = pbtn_off.src;
	document.pbtn.alt = txpbtn_off;
	document.pbtn.title = document.pbtn.alt;
}

function runPresentation() {
	wc_stopped = false;
	picnbr = spicnbr;
	if (wc_tout != null) { window.clearTimeout(wc_tout); wc_tout = null; }
	picnbr++; if (picnbr >= picurl.length) { picnbr=0; }
	wc_tout = window.setTimeout("refreshWebcam()", refInt);
	document.pbtn.src = pbtn_on.src;
	document.pbtn.alt = txpbtn_on;
	document.pbtn.title = document.pbtn.alt;
}

function nextWebcam() {
	stopPresentation(false);
	picnbr++; if (picnbr >= picurl.length) { picnbr=0; }
	startWebcam();
}

function previousWebcam() {
	stopPresentation(false);
	picnbr--; if (picnbr<0) { picnbr += picurl.length; }
	startWebcam();
}

function startWebcam() {
	if (wc_tout != null) { window.clearTimeout(wc_tout); wc_tout = null; }
	refreshWebcam();
}

// Unique identifier
function UUID(){
	this.id = this.createUUID();
}

UUID.prototype.valueOf = function(){ return this.id; }

UUID.prototype.toString = function(){ return this.id; }

UUID.prototype.createUUID = function(){
	var dg = new Date(1582, 10, 15, 0, 0, 0, 0);
	var dc = new Date();
	var t = dc.getTime() - dg.getTime();
	var h = '-';
	var tl = UUID.getIntegerBits(t,0,31);
	var tm = UUID.getIntegerBits(t,32,47);
	var thv = UUID.getIntegerBits(t,48,59) + '1'; // version 1, security version is 2
	var csar = UUID.getIntegerBits(UUID.rand(4095),0,7);
	var csl = UUID.getIntegerBits(UUID.rand(4095),0,7);
	var n = 
		UUID.getIntegerBits(UUID.rand(8191),0,7) + 
		UUID.getIntegerBits(UUID.rand(8191),8,15) + 
		UUID.getIntegerBits(UUID.rand(8191),0,7) + 
		UUID.getIntegerBits(UUID.rand(8191),8,15) + 
		UUID.getIntegerBits(UUID.rand(8191),0,15); // this last number is two octets long
	return tl + h + tm + h + thv + h + csar + csl + h + n; 
}

UUID.getIntegerBits = function(val,start,end){
	var base16 = UUID.returnBase(val,16);
	var quadArray = new Array();
	var quadString = '';
	var i = 0;
	for(i=0;i<base16.length;i++){ quadArray.push(base16.substring(i,i+1)); }
	for(i=Math.floor(start/4);i<=Math.floor(end/4);i++){
		if(!quadArray[i] || quadArray[i] == '') quadString += '0';
		else quadString += quadArray[i];
	}
	return quadString;
}

UUID.returnBase = function(number, base){
	return (number).toString(base).toUpperCase();
}

UUID.rand = function(max){
	return Math.floor(Math.random() * (max + 1));
}
// -->			
