function scroll(objElement, intHeight) {
var self = this;
this._y = 0;
objElement.style.top  = "0px";
this.setPosition = function(intPos, y) {
  if (intPos > 0) intPos = 0;
  if (intPos < intHeight - objElement.offsetHeight)
	intPos = intHeight - objElement.offsetHeight;
  this._y = intPos;
  objElement.style.top  = this._y +"px";
};
this.scrollY = function(y) { this.setPosition(this._y + y, y); };
this.start = function(y) {
  this.scrollTimer = window.setInterval(
	function() { self.scrollY(y); }, 25 );
};
this.stop = function() {
  if (this.scrollTimer) window.clearInterval(this.scrollTimer); };
};

function arraySupprimer(n){ // array element lösch funktion 
var devant=this.slice(0,n);
var derriere=this.slice(n+1,this.length);
return devant.concat(derriere);
}

Array.prototype.del=arraySupprimer;


function humanReadableTime(time) {

	ret = '';

	hours = 0;
	minutes = Math.floor(time/60);
	seconds = time-(minutes*60);

	while (minutes >= 60) {
		minutes -= 60;
		hours += 1;
	}

	if (minutes < 10) minutes = '0'+minutes;
	if (seconds < 10) seconds = '0'+seconds;

	ret = hours + ":";
	ret += minutes + ":";
	ret += seconds
	return ret;
}

function humanReadableTime_2(time) {

	ret = '';

	hours = 0;
	minutes = Math.floor(time/60);
	seconds = time-(minutes*60);

	while (minutes >= 60) {
		minutes -= 60;
		hours += 1;
	}

	if (minutes < 10) minutes = '0'+minutes;
	if (seconds < 10) seconds = '0'+seconds;

	ret = minutes + ":";
	ret += seconds
	return ret;
}

function humanReadableTime_ext(time) {

	ret = '';

	hours = 0;
	days = 0;
	minutes = Math.floor(time/60);
	seconds = time-(minutes*60);

	while (minutes >= 60) {
		minutes -= 60;
		hours += 1;
	}
	
	while (hours>= 24){
		hours -= 24;
		days +=1;
		}

	if (minutes < 10) minutes = '0'+minutes;
	if (seconds < 10) seconds = '0'+seconds;
	if (days < 10) days = '0'+days;
	if (hours < 10) hours = '0'+hours;
	
	ret = "<div class='cd_days'>"+days+"</div><div class='cd_dp'></div>";
	ret += "<div class='cd_hours'>"+hours+"</div><div class='cd_dp'></div>";
	ret += "<div class='cd_minutes'>"+minutes+"</div><div class='cd_dp'></div>";
	ret += "<div class='cd_seconds'>"+seconds+"</div>";
	
	return ret;
}


function countdownField(fld, tmst, interval, msgFinished) {
	
	if (msgFinished == undefined) msgFinished = 'fertig';
	if (tmst > 0) {
		document.getElementById(fld).innerHTML = humanReadableTime(tmst);
		setTimeout("countdownField('"+fld+"', "+(tmst-(interval/1000))+", "+interval+", '"+msgFinished+"');", interval);
	} else {
		document.getElementById(fld).innerHTML = msgFinished;
	}
}

function countdownField_2(fld, tmst, interval, msgFinished) {
	
	if (msgFinished == undefined) msgFinished = 'fertig';
	if (tmst > 0) {
		document.getElementById(fld).innerHTML = humanReadableTime_2(tmst);
		setTimeout("countdownField_2('"+fld+"', "+(tmst-(interval/1000))+", "+interval+", '"+msgFinished+"');", interval);
	} else {
		window.location.reload();
	}
}

function countdownField_ext(fld, tmst, interval, msgFinished) {
	
	if (msgFinished == undefined) msgFinished = 'Jetzt geht es los!';
	if (tmst > 0) {
		document.getElementById(fld).innerHTML = humanReadableTime_ext(tmst);
		setTimeout("countdownField_ext('"+fld+"', "+(tmst-(interval/1000))+", "+interval+", '"+msgFinished+"');", interval);
	} else {
		window.location.reload();
	}
}

function countdownField_3(fld, tmst, interval, msgFinished) {
	
	if (msgFinished == undefined) msgFinished = 'fertig';
	if (tmst > 0) {
		document.getElementById(fld).innerHTML = humanReadableTime_2(tmst);
		setTimeout("countdownField_2('"+fld+"', "+(tmst-(interval/1000))+", "+interval+", '"+msgFinished+"');", interval);
	} else {
		window.location.reload();
	}
}

function flash_out(texto, timus) {  // timus - optionaler zeitparameter
if (typeof timus == "undefined") {
timus = 3000;
}

document.getElementById('flash_result').innerHTML=texto;
opacity('flash_result', 0, 100, 250);
//opacity('flash_result')
setTimeout("opacity('flash_result', 100, 0, 250)", timus);
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function toggle_checkbox(id){
    var obj = document.getElementById(id);
	if(obj.checked){obj.checked=false;}else{obj.checked=true;}	
	}


function check_checkbox(id){
    var obj = document.getElementById(id);
	obj.checked=true;	
	}


function uncheck_checkbox(id){
    var obj = document.getElementById(id);
	obj.checked=false;	
	}


function toggle_radio(id){
    var obj = document.getElementById(id);
	if(obj.checked){obj.checked=false;}else{obj.checked=true;}	
	} 
	
function toggle_div(id){
    var obj = document.getElementById(id);
	if(obj!=null){
		if(obj.style.display=="none"){obj.style.display="block";}else{obj.style.display="none";}	
	}
	}
	
	
	
function toggle_tr(id){
    var obj = document.getElementById(id);
	if(obj!=null){
		if(obj.style.display=="none"){obj.style.display="table-row";}else{obj.style.display="none";}	
	}
	}

function gt(obj){
	var ooo = document.getElementById(obj);
	return ooo;
	}
