function check(feld,welches,maxlength) {
  
  StrLen = feld.value.length;
  
  if (welches=="name") {
    if (StrLen==1&&feld.value.substring(0,1)==" "){
      feld.value="";
      StrLen=0;
    }
    if (StrLen>maxlength ){
      feld.value=feld.value.substring(0,maxlength);
      CharsLeft=0;
    }
    else {
      CharsLeft=maxlength-StrLen;
    }
    document.getElementById('rest_zeichen_name').innerHTML = CharsLeft;
  }
  
  if (welches=="desc") {
    if (StrLen==1&&feld.value.substring(0,1)==" "){
      feld.value="";
      StrLen=0;
    }
    if (StrLen>maxlength ){
      feld.value=feld.value.substring(0,maxlength);
      CharsLeft=0;
    }
    else {
      CharsLeft=maxlength-StrLen;
    }
    document.getElementById('rest_zeichen_desc').innerHTML = CharsLeft;
  }
  
  
  if (welches=="key") {
    if (StrLen==1&&feld.value.substring(0,1)==" "){
      feld.value="";
      StrLen=0;
    }
    if (StrLen>maxlength ){
      feld.value=feld.value.substring(0,maxlength);
      CharsLeft=0;
    }
    else {
      CharsLeft=maxlength-StrLen;
    }
    document.getElementById('rest_zeichen_key').innerHTML = CharsLeft;
  }
  
  if (welches=="comment") {
    if (StrLen==1&&feld.value.substring(0,1)==" "){
      feld.value="";
      StrLen=0;
    }
    if (StrLen>maxlength ){
      feld.value=feld.value.substring(0,maxlength);
      CharsLeft=0;
    }
    else {
      CharsLeft=maxlength-StrLen;
    }
    document.getElementById('rest_zeichen_comment').innerHTML = CharsLeft;
  }
}

// ************************************************************************ //



// ************************************************************************ //

function tooltip(id,element) {
  //Elternelement
	var newTooltip = document.createElement("div");
  newTooltip.style.width = '250px';
  newTooltip.style.position = 'absolute';
  newTooltip.style.top = absTop(element)+'px';
  var left = absLeft(element)-250;
  newTooltip.style.left = left+'px';
  
  //DIV oben
  var toolContentTop = document.createElement("div");
  toolContentTop.style.height = '17px';
  toolContentTop.style.cursor = 'pointer';
  toolContentTop.style.padding = '9px 0px 0px 10px';
  toolContentTop.style.fontWeight = 'bold';
  toolContentTop.style.color = '#fff';
  toolContentTop.style.backgroundImage = 'url(/images/tooltip/top.jpg)';
  toolContentTop.onclick = function() {
                              window.document.body.removeChild(this.parentNode)
                           };
  toolContentTop.innerHTML = 'FAQ-ID: '+id+' | zum Schlie&szlig;en hier klicken X';
  

  //DIV mit Inhalt
  var toolContentMiddle = document.createElement("div");
  toolContentMiddle.style.textAlign = 'justify';
  toolContentMiddle.style.padding = '10px 15px 10px 15px';
  toolContentMiddle.style.backgroundImage = 'url(/images/tooltip/middle.jpg)';
  //AJAX-Request losschicken und Antwort darstellen
  sendData(id,toolContentMiddle);
  
  //DIV unten
  var toolContentBottom = document.createElement("div");
  toolContentBottom.style.height = '13px';  
  toolContentBottom.style.backgroundImage = 'url(/images/tooltip/bottom.jpg)';
  
  //Alles ertellen
  window.document.body.appendChild(newTooltip);
  newTooltip.appendChild(toolContentTop);
  newTooltip.appendChild(toolContentMiddle);
  newTooltip.appendChild(toolContentBottom);
}

function absLeft(el) {
  return (el.offsetParent)? el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;
}

function absTop(el) {
   return (el.offsetParent)? el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}

function getXMLRequester( ) {
	var req = null;
  try{
      req = new XMLHttpRequest();
  }
  catch (ms){
      try{
          req = new ActiveXObject("Msxml2.XMLHTTP");
      } 
      catch (nonms){
          try{
              req = new ActiveXObject("Microsoft.XMLHTTP");
          } 
          catch (failed){
              req = null;
          }
      }  
  }

  if (req == null)
        alert("Error creating request object!");
	return req ;
}

function sendData(id,content) {
	con = getXMLRequester();
  con.open("GET", '/ajax_tooltip.php?id='+id+'', true);
	con.onreadystatechange = function(){            
    switch(con.readyState) {
            case 4:
            if(con.status!=200) {
                alert("Fehler:"+con.status); 
            } else {
                content.innerHTML = con.responseText;
            }
            break;
    
            default:
              return false;
            break;     
        }
    };
    con.setRequestHeader("Content-Type","text/plain");
    con.send(null);
}

//wenn JS aktiviert ist ersetzt diese Funktion die statischen Links
//auf die FAQ durch den coolen Tooltip
function replaceForTooltip() {
			if(!document.getElementsByTagName) return;
			var anchors = document.getElementsByTagName("a");
			for(var i=0; i<anchors.length; i++)
				{
				var anchor = anchors[i];
				if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "tooltip") {
          anchor.removeAttribute("href");
          anchor.removeAttribute("target");
          anchor.style.cursor = 'pointer';
         }
				}
      }

// ************************************************************************ //

wmtt = null;
document.onmousemove = updateWMTT;
//Tooltip
function updateWMTT(e) {
	x = (document.all) ? window.event.x + window.document.documentElement.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + window.document.documentElement.scrollTop  : e.pageY;
	if (wmtt != null) {
		wmtt.style.left = (x + 20) + "px";
		wmtt.style.top 	= (y + 20) + "px";
	}
}

function showWMTT(id) {
	wmtt = document.getElementById(id);
	wmtt.style.display = "block"
}

function hideWMTT() {
	wmtt.style.display = "none";
}
// ************************************************************************ //

function sbShow(start) {
  var start_next = start + 19;
  
  for (var i = start; i <= start_next; i++)
    if(document.getElementById('sb-eintrag-'+i+'')) {
      document.getElementById('sb-eintrag-'+i+'').style.display = 'block';
    }

  for (var j = 1; j <= 60; j++)
    if (j > start_next || j < start)
      if(document.getElementById('sb-eintrag-'+j+'')) {
        document.getElementById('sb-eintrag-'+j+'').style.display = 'none';
      }
  
  if (start < 41)  
    document.getElementById('sb-link-vor').innerHTML = '<a href=\'#\' onclick=\'sbShow('+(start+20)+')\'>&auml;ltere Beitr&auml;ge anzeigen &raquo;</a>';  
  else
    document.getElementById('sb-link-vor').innerHTML = '';
  
  if (start > 1)  
    document.getElementById('sb-link-back').innerHTML = '<a href=\'#\' onclick=\'sbShow('+(start-20)+')\'>&laquo; j&uuml;ngere Beitr&auml;ge zeigen</a>';  
  else
    document.getElementById('sb-link-back').innerHTML = '';  

}
// ************************************************************************ //