function countdown(sekunden,ident,iPercentIdent,duration){
	this.percentIdent = iPercentIdent;
	this.duration = duration;
	this.sekunden = sekunden;
	this.random_name = "counter_"+Math.floor(Math.random(1,99999)*1000);
	this.ident = ident;
	this.show = function () {
		if(this.ident && this.ident != null) {
			this.random_name = this.ident;
		}
		if(this.sekunden > 0) {
			if(!$(this.random_name)) {
				document.write('<span id="'+this.random_name+'">#</span>');
			}
			time = this.sekunden;
            hours = (time - (time % 3600)) / 3600;
            time = time - (hours * 3600);
            mins = (time - (time % 60)) / 60;
            time = time - (mins * 60);
            secs = (time - (time % 1)) / 1;
            if(hours < 10) hours = "0" + hours;
            if(mins < 10) mins = "0" + mins;
            if(secs < 10) secs = "0" + secs;
			$(this.random_name).innerHTML = hours+':'+mins+':'+secs;
			if(this.percentIdent) {
				this.refreshPercent();
			}
			setTimeout("countdown('"+(this.sekunden-1)+"','"+this.random_name+"','"+this.percentIdent+"','"+this.duration+"')",1000);
		} else {
			if(this.percentIdent) {
				this.refreshPercent();
			}
			$(this.random_name).innerHTML = "Fertig";
			//window.setTimeout('__countdownreload()',2000);
		}
	}
	this.refreshPercent = function() {
		if(!$(this.percentIdent)) { return true;}
		var diff = (this.duration - this.sekunden);
		var percent = Math.ceil(((diff/this.duration)*100));
		var obj = $(this.percentIdent);
		if(percent == 100) {
			obj.innerHTML = '<div class="percent_done" style="width:100px;height:10px;"></div>';
		} else {
			var html = '<div class="percent" style="width:100px;">';
			html += '<div class="percent_done" style="width: '+percent+'px;">&nbsp;</div>';
			html += '</div>';
			obj.innerHTML = html;
		}
	}
	this.show();
}
function __countdownreload() {
	window.location.href=window.location.href;
}
