function changecolor(id, bgcolor, color) {
  if (bgcolor != '') { document.getElementById(id).style.backgroundColor = bgcolor; }
  if (color != '') { document.getElementById(id).style.color = color; }
}

function swap_content( span ) {
	displayType = ( document.getElementById( span ).style.display == 'none' ) ? 'block' : 'none';
	document.getElementById( span ).style.display = displayType;
}

// Alle selektieren/deselektieren
var check = false;

function checkedall() {
	if(check == true) {
		check = false;
		
		for(var i = 0; i < document.forms[0].elements.length; i++) {
			document.forms[0].elements[i].checked = false;
		}
	} else {
		check = true;
	
		for (var i = 0; i < document.forms[0].elements.length; i++) {
			document.forms[0].elements[i].checked = true;
		}
	}
}

// Open a new popup with the specific width and height
function openPopUp(url, width, height)
{
	// Open the new window
	newwindow = window.open(url, 'popup','height='+height+',width='+width+',scrollbars=yes');
	newwindow.focus()
	
	return false;
}


// Fix the position of the admin menu

function setPosition() {
 if((navigator.appName=="Netscape" &&
       parseInt(navigator.appVersion.substring(0,1))>=5) ||
    (navigator.appName=="Opera" &&
       parseInt(navigator.appVersion.substring(0,1))>=7)) {

  document.getElementById("adminmenu").style.position="fixed";
 }

 if(navigator.appName=="Microsoft Internet Explorer") {
  document.getElementById("adminmenu").style.top=document.body.scrollTop+0+"px";
  window.setTimeout("setPosition()",1);
 }

 if(navigator.appName=="Netscape" &&
    navigator.appVersion.substring(0,1)=="4") {

  document.menu.top=window.pageYOffset+0;
  window.setTimeout("setPosition()",1);
 }
}

// Count the digits in a form

function countDigits(){
	var maxDigits = 300;   //maximale Zeichenanzahl
	var areaString = document.forms[0].message.value;
	var currLength = areaString.length + 1;
	var restLength = maxDigits - currLength +1;
	if ( restLength <  0 ) {
		restLength = 0;
	}

	document.forms[0].counter.value = restLength;
	if (areaString.length  > maxDigits-1) {
		//die folgende Zeile entfernt alle Zeichen die  > maxDigits sind
		document.forms[0].message.value = document.forms[0].message.value.substring(0,maxDigits);
	}
}