function zeichen(textarea,anzeige,max) {
anz=document.getElementById(textarea).value.length+1;
document.getElementById(anzeige).value=max-anz;
if(anz>=max){
  alert("Mehr Zeichen sind nicht erlaubt");
  }
}
function qst(form) {
qst_=window.confirm("Bist du dir sicher, dass du diese Aktion ausführen willst?");
if(qst_==true)
  document.forms[form].submit();
}
function empty(form) {
if((document.forms[form].title.value=="")||(document.forms[form].txt.value==""))
  alert("Es sind nicht alle Felder ausgefüllt.");
else
  document.forms[form].submit();
}
function empty2(form) {
if((document.forms[form].title.value=="")||(document.forms[form].txt.value=="")||(document.forms[form].choose.value=="null"))
  alert("Es sind nicht alle Felder ausgefüllt.");
else
  document.forms[form].submit();
}
function empty3(form) {
if(document.forms[form].new_top_subject.value=="")
  alert("Der Kategoriename fehlt.");
else
  document.forms[form].submit();
}
function empty4(form) {
if(document.forms[form].name.value=="")
  alert("Der Gruppenname fehlt.");
else
  document.forms[form].submit();
}
function jump_up() {
high=(document.body.scrollHeight)*-1;
document.body.scrollTop=high;
}
function jump_down() {
high=document.body.scrollHeight;
document.body.scrollTop=high;
}
function jump(id) {
high=document.getElementById(id).offsetTop-20;
document.body.scrollTop=high;
}


var anz=16;
var r=18;
var yf=new Array(10,10,10,10,30,30,30,30,50,50,50,50,70,70,70,70);
var xf=new Array(10,30,50,70,10,30,50,70,10,30,50,70,10,30,50,70);
var color=new Array("#000000","#808080","#C0C0C0","#FFFFFF","#800000","#808000","#008000","#008080","#000080","#800080","#FF0000","#FFFF00","#00FF00","#00FFFF","#0000FF","#FF00FF");
var color_n=new Array("black","gray","silver","white","maroon","olive","green","teal","navy","purple","red","yellow","lime","aqua","blue","fuchsia");
var st_creat=new Array(false,false,false);
var st_on=new Array(-1,-1,-1);
var av=new Array(null,null,null);
function set_cl(id) {
if(st_creat[id]==false) {
for(i=15; i>-1; i--) {
  old=document.getElementById("cl"+id).innerHTML;
  new_=old+"<div id='"+id+""+i+"' style='width:"+r+"px; height:"+r+"px; position:absolute; top:"+(yf[i]-5)+"; left:"+(xf[i]-5)+"; background:"+color[i]+"; border:0;' onClick='click("+id+","+i+")' onMouseOver='hover("+id+","+i+")' onMouseOut='out("+id+","+i+")'></div>";
  document.getElementById("cl"+id).innerHTML=new_;
  }
st_creat[id]=true;
}
if(id!=0){document.getElementById("cl0").style.display="none"; st_on[0]=-1;}
if(id!=1){document.getElementById("cl1").style.display="none"; st_on[1]=-1;}
if(id!=2){document.getElementById("cl2").style.display="none"; st_on[2]=-1;}
if(st_on[id]==1)
  document.getElementById("cl"+id).style.display="none";
else
  document.getElementById("cl"+id).style.display="block";
st_on[id]*=-1;
}
function click(id,i) {
document.colors.elements["BG"+id].value="";
document.colors.elements["BG"+id].value=color[i];
document.colors.elements["B"+id].style.background=color[i];
document.colors.elements["B"+id].value=color_n[i];
document.getElementById(id+""+i).style.border="3px solid red";
if(av[id]!=null)document.getElementById(id+""+av[id]).style.border="0px";
document.colors.elements["ST"+id].checked=false;
av[id]=i;
}
function hover(id,i) {
document.getElementById(id+""+i).style.height="30px";
document.getElementById(id+""+i).style.width="30px";
}
function out(id,i) {
document.getElementById(id+""+i).style.height="18px";
document.getElementById(id+""+i).style.width="18px";
}
function change(id) {
document.colors.elements["BG"+id].value="";
document.colors.elements["BG"+id].value="null";
document.colors.elements["B"+id].style.background="none";
document.getElementById(id+""+av[id]).style.border="0px";
document.colors.elements["B"+id].value="wähle";
av[id]=null;
}


var fit_st=true;
var next=0;
function fit(all,max) {
var txt=document.getElementById("tx"+next).innerHTML;
var split0=txt.split(" ");
var sp0l=split0.length;
for(i=0; i<sp0l; i++) {
  var split1=split0[i].split("");
  var sp1l=split1.length;
  if(sp1l>max) {
    var anz=Math.floor(sp1l/max);
    for(t=1; t<sp1l; t++) {
       split1[t*max-2]=split1[t*max-2]+"-<br>";
      }
    split0[i]="";
    for(g=0; g<sp1l; g++) {
      split0[i]=split0[i]+""+split1[g];
      }
    }
  }
  txt="";
  for(h=0; h<sp0l; h++) {
    txt=txt+" "+split0[h];
    }
  document.getElementById("tx"+next).innerHTML=txt;
if(next<all) next++;
else fit_st=false;
}