function vote(id,wert,punkte) {
	params = "id=" + id + "&wert=" + wert;
	new Ajax.Request('echo.php', {
		postBody:  params,
		onLoading: function(){
			if(wert == "pos") $("points"+id).innerHTML = punkte+1;
			if(wert == "neg") $("points"+id).innerHTML = punkte-1;
			$("pos"+id).innerHTML = "&nbsp;&nbsp;";
			$("neg"+id).innerHTML = "&nbsp;&nbsp;";
		}
	});
}
function votewart(id,wert) {
	params = "id=" + id + "&wert=" + wert;
	new Ajax.Request('echo.php', {
		postBody:  params,
		onLoading: function(){
			$("pos"+id).innerHTML = "Danke!";
			$("neg"+id).innerHTML = "";
		}
	});
}
function login() {
		params = "nick=" + encodeURI( $("nick").value ) + "&pw=" + encodeURI( $("pw").value );
		new Ajax.Request('echo.php', {
			postBody:  params,
			onLoading: function(){
				$('sub').value = " bitte warten ";
			},
			onSuccess: function(req){
				if(req.responseText == "no"){
					alert("Ihre Anmeldung war nicht erfolgreich!");
					$('sub').value = " einloggen ";
					$('pw').focus();
				} else {
					document.location = req.responseText;
				}
			}
		});
}

function comment(id) {
	$("comment"+id).style.display = "block";
		params = "c=comment&id=" + id;
		new Ajax.Request('echo.php', {
			postBody:  params,
			onSuccess: function(req){
				$("show"+id).innerHTML = "<a href='' onclick='einklappen("+id+");return false;'>schlie&szlig;en</a>";
				$("comment"+id).innerHTML = req.responseText;
			}
		});
}

function toco(id) {
		params = "c=toco&text=" + encodeURI( $("text"+id).value ) + "&id=" + id;
		new Ajax.Request('echo.php', {
			postBody:  params,
			onLoading: function(){
				$("text"+id).disabled = "true";
				$("tocosub"+id).value = " bitte warten ";
			},
			onSuccess: window.setTimeout("comment("+id+")", 500)
		});
}

function count(id){
	var max = 999;
	var uebrig;
  if ($("text"+id).value.length >= max) {
    $("text"+id).value = $("text"+id).value.substring(0,max);
  }
  
  uebrig = max - $("text"+id).value.length;
	$("wortzahl"+id).innerHTML = "noch "+ uebrig + " Zeichen";
}
function einklappen(id){
	$("comment"+id).style.display = "none";
	$("show"+id).innerHTML = "<a href='' onclick='comment("+id+");return false;'>Kommentare</a>";
}
function melde(id){
	params = "melde=" + id;
	new Ajax.Request('echo.php', {
		postBody:  params
	});
	return "<img style='cursor:default;' border=0 title='gemeldet' src='/inc/meldeover.png'>";
}