function go() {
	if(to) showTimeout(to);
	if(document.getElementById("z")) showTime("z",timer);
	var i=1;
	while(document.getElementById("x"+i)) {
		var t=document.getElementById("x"+i).firstChild.nodeValue.split(":");
		var h=parseInt(t[0]);
		var m=parseInt(t[1]);
		var s=parseInt(t[2]);
		countdown("x"+i,h,m,s);
		i++;
	}
	var i=1;
	while(document.getElementById("y"+i)) {
		var t=document.getElementById("y"+i).firstChild.nodeValue.split(":");
		var h=parseInt(t[0]);
		var m=parseInt(t[1]);
		var s=parseInt(t[2]);
		//alert(h+"/"+m+"/"+s+" - "+t[0]+"/"+t[1]+"/"+t[2]);
		countdown2("y"+i,h,m,s);
		i++;
	}
}

function showTime(id,t) {
	var z=new Date();
	z.setTime(t);
	zd="00"+z.getDate();
	zd=zd.substr(zd.length-2,2);
	zm="00"+(z.getMonth()+1);
	zm=zm.substr(zm.length-2,2);
	zh="00"+z.getHours();
	zh=zh.substr(zh.length-2,2);
	zmi="00"+z.getMinutes();
	zmi=zmi.substr(zmi.length-2,2);
	zs="00"+z.getSeconds();
	zs=zs.substr(zs.length-2,2);
	document.getElementById(id).firstChild.nodeValue=zd+"."+zm+"."+z.getFullYear()+" "+zh+":"+zmi+":"+zs;
	t+=1000;
	window.setTimeout('showTime("'+id+'",'+t+')',1000);
}

function showTimeout(to) {
	if(to>0) {
		to2=to;
		hs=Math.floor(to2/60/60);
		to2-=(hs*60*60);
		ms=Math.floor(to2/60);
		ss=to2-(ms*60);
		ms="00"+ms;
		ms=ms.substr(ms.length-2,2);
		ss="00"+ss;
		ss=ss.substr(ss.length-2,2);
		window.status="Session: "+hs+":"+ms+":"+ss;
		to--;
		window.setTimeout('showTimeout("'+to+'")',1000);
	} else {
		window.status='Session abgelaufen.';
	}
}

function countdown(id,h,m,s) {
	if((h+m+s)>0) {
		var hs="";
		var ms="";
		var ss="";
		hs=h+":";
		ms="00"+m+":";
		ms=ms.substr(ms.length-3,3);
		ss="00"+s;
		ss=ss.substr(ss.length-2,2);
		document.getElementById(id).firstChild.nodeValue=hs+ms+ss;
		s--;
		if(s<0) { s=59; m--; }
		if(m<0) { m=59; h--; }
		window.setTimeout('countdown("'+id+'","'+h+'","'+m+'","'+s+'")',1000);
	} else {
		document.getElementById(id).firstChild.nodeValue="Abgeschlossen";
		location.reload();
	}
}

function countdown2(id,h,m,s) {
	if((h+m+s)>0) {
		var hs="";
		var ms="";
		var ss="";
		hs="00"+h+":";
		hs=hs.substr(hs.length-3,3);
		ms="00"+m+":";
		ms=ms.substr(ms.length-3,3);
		ss="00"+s;
		ss=ss.substr(ss.length-2,2);
		document.getElementById(id).firstChild.nodeValue=hs+ms+ss;
		s--;
		if(s<0) { s=59; m--; }
		if(m<0) { m=59; h--; }
		window.setTimeout('countdown2("'+id+'","'+h+'","'+m+'","'+s+'")',1000);
	} else {
		document.getElementById(id).firstChild.nodeValue="Angekommen";
	}
}

function iS(d) {
	d+=2;
	while(document.forms[0].elements[d]) {
		if(document.forms[0].elements[d].name!="sb") {
			if(document.forms[0].elements[d].checked) {
				document.forms[0].elements[d].checked=false;
			} else {
				document.forms[0].elements[d].checked=true;
			}
			d+=13;
		} else {
			break;
		}
	}
}

function iM() {
	var i=0;
	while(document.getElementsByTagName("input")[i]) {
		if(document.getElementsByTagName("input")[i].checked) {
			document.getElementsByTagName("input")[i].checked=false;
		} else {
			document.getElementsByTagName("input")[i].checked=true;
		}
		i++;
	}
}
