// funktion im PsychSpider

/**/
function select_all(o,n,la){
 for (var i=0; i < o.form.elements["collection[]"].length ;i++){
	o.form.elements["collection[]"][i].checked = n;
 }
 /* button entfernen*/
	var oldParent = document.getElementById('selektieren');
	var oldTextField = document.getElementById('wechselmich');
	if (oldTextField != null){oldParent.removeChild(oldTextField);}
/*neuen einfuegen*/
 if(n==1){
 	var newTextField = document.createElement('input');
	newTextField.setAttribute('id','wechselmich');
	if(la==0){
	newTextField.setAttribute('onchange','select_all(this,0,0)');			
	newTextField.setAttribute('value','alle deselektieren');
	newTextField.setAttribute('onclick','select_all(this,0,0)');
	}
	else{
	newTextField.setAttribute('onchange','select_all(this,0,1)');			
	newTextField.setAttribute('value','deselect all');
	newTextField.setAttribute('onclick','select_all(this,0,1)');
	}
	newTextField.setAttribute('type','button');	document.getElementById('selektieren').appendChild(newTextField);
 }
 else {
 	var newTextField = document.createElement('input');
	newTextField.setAttribute('id','wechselmich');
	newTextField.setAttribute('type','button');
	if(la==0){
	newTextField.setAttribute('onchange','select_all(this,1,0)');			
	newTextField.setAttribute('value','alle selektieren');
	newTextField.setAttribute('onclick','select_all(this,1,0)');
	}
	else{
	newTextField.setAttribute('onchange','select_all(this,1,1)');			
	newTextField.setAttribute('value','select all');
	newTextField.setAttribute('onclick','select_all(this,1,1)');
	}
	document.getElementById('selektieren').appendChild(newTextField);
 }			

}

