var restzeit;
restzeit = document.getElementById('bpa').innerHTML;
var s;
var m;
var h;
s = restzeit.substr(restzeit.length-2, 2);
m = restzeit.substr(restzeit.length-5, 2);
h = restzeit.substr(0,restzeit.length-6);
var boolblink;
boolblink = true;

function startbpc(){
	if(restzeit!='Vorbei') window.setTimeout("bankpotcountdown()", 1000);
}

function bankpotcountdown(){

	s--;
	if(s<0){
		s=59;
		m--;
		if(m<0){
			m=59;
			h--;
		}
	}
	
	if(s<10)s='0'+s;
	if(m<10)m=''+m;
	if(m.length<2)m='0'+m;
	
	if(h<=0){
		document.getElementById('bpa').style.color='red';
		if(m<=30){
			(boolblink) ? document.getElementById('bpa').style.backgroundColor='Yellow' : document.getElementById('bpa').style.backgroundColor='White';
			(boolblink) ? boolblink = false : boolblink = true;
		}	
	}
	
	if(h<=0 && m<=0 && s<=0){
		document.getElementById('bpa').innerHTML = 'Vorbei';
	}else{
		document.getElementById('bpa').innerHTML = h+':'+m+':'+s;
		window.setTimeout("bankpotcountdown()", 1000);
	}
}

startbpc();