function RestlicheZeichenErmitteln(form){
    var ErlaubteAnzahl = 500;
    var Laenge = document.Formular.Anfrage.value.length;
    if (Laenge > ErlaubteAnzahl){
        document.Formular.Anfrage.value = document.Formular.Anfrage.value.substring(0, ErlaubteAnzahl);
        RestlicheZeichen = 0;
    }else{
        RestlicheZeichen = ErlaubteAnzahl-Laenge;
    }
		document.Formular.Laenge.value = RestlicheZeichen;
}

function start(){
	time();
	window.setInterval("time()", 1000);
}

function time(){
	var now = new Date();
	hours = now.getHours();
	minutes = now.getMinutes();
	seconds = now.getSeconds();
	thetime = (hours < 10) ? "0" + hours + ":" : hours + ":";
	thetime += (minutes < 10) ? "0" + minutes + ":" : minutes + ":";
	thetime += (seconds < 10) ? "0" + seconds : seconds;
	element = document.getElementById("time");
	element.innerHTML = thetime;
}

function getVote(int){
	if(window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
	}else{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = function(){
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
			document.getElementById("poll").innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET", "../include/poll_vote.php?vote=" + int, true);
	xmlhttp.send();
}

function getVote2(int){
	if(window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
	}else{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = function(){
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
			document.getElementById("poll").innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET", "../include/poll_vote2.php?vote=" + int, true);
	xmlhttp.send();
}

function bmi(){
    var w = parseFloat(document.frm.txtWeight.value);
    var h = parseInt(document.frm.txtHeight.value);
    var errors = '';
    if((w < 20) || (w > 200) || isNaN(w)){
		errors += 'Bitte tragen Sie ein korrektes Körpergewicht ein.\n';
	}
    if((h < 100) || (h > 250) || isNaN(h)){
		errors += 'Bitte tragen Sie eine korrekte Körpergröße ein.\n';
	}
    if(errors){
		alert('Fehler:\n' + errors);
		return 0;
	}
    document.getElementById('feedback').innerHTML 
	= '<small><font color="#990000">Ihr BMI-Wert ist ' + Math.round(10 * ((w * 10000 / (h * h)))) / 10 + '</font></small>';
}
