function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++) {
		if (x[i].getAttribute('maxlength')) {
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength){
		this.value.length = maxLength;
		//this.relatedElement.firstChild.setAttribute = currentLength;
		//this.relatedElement.firstChild.nodeValue = 1;
	}else{
		this.relatedElement.className = '';
		this.relatedElement.firstChild.nodeValue = currentLength;
	}
	//this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}


function showCreateEntry(text){
	document.getElementById('create_div').innerHTML=text;
}

function openExturl(url) {
 fenster=window.open(url, "fenster1", "width=800,height=500,status=yes,scrollbars=yes,resizable=yes,left=10,top=60");
 fenster.focus();
 return false;
}

function countBack(){
	var link = document.getElementById('back').innerHTML;
	var suche = /(\d+)/;
  	var ergebnis = suche.exec(link);
	var number = Number(ergebnis[1]);
	number++;
	var newlink = link.replace(/\d+/, number);
	document.getElementById('back').innerHTML = newlink;
}

function ShowHide(id) {
    obj = document.getElementsByTagName("td");
    if (obj[id].style.visibility == 'visible'){
    obj[id].style.visibility = 'hidden';
    }
    else {
    obj[id].style.visibility = 'visible';
    }
}
function sortListLoad(){
	for (i = 0; i < document.sortListForm.sortListSelect.length; ++i){
   	if (document.sortListForm.sortListSelect.options[i].selected == true){
	      window.location = document.sortListForm.sortListSelect.options[i].value;
	   }
	}
}

