/*Funktion zum testen, welche auswahl bei einem radio-button getroffen wurde*/

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

/* layer ein-/ausblenden */

function showHide(objId)
{ 
   var obj = (document.all) ? document.all[objId] : document.getElementById(objId);
   
   if( obj.style.display == 'block' ){
     obj.style.display = 'none';
   }
   else if( obj.style.display == 'none' ){
     obj.style.display = 'block';
  }
}

/* testen ob zahl */

function check(wert) {
	if (isNaN(wert)) {
    	return Number(0);
 	} else {
  		return wert;
 	}
}

/* fenster oeffnen */

var win=null;
function openwindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.availWidth)?Math.floor(Math.random()*(screen.availWidth-w)):50;TopPosition=(screen.availHeight)?Math.floor(Math.random()*((screen.availHeight-h)-75)):50;}
if(pos=="center"){LeftPosition=(screen.availWidth)?(screen.availWidth-w)/2:50;TopPosition=(screen.availHeight)?(screen.availHeight-h)/2:50;}
if(pos=="default"){LeftPosition=50;TopPosition=50}
else if((pos!="center" && pos!="random" && pos!="default") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
if(win.focus){win.focus();}}

/* upload testen */

function upload_check() {
	if (getCheckedValue(window.document.question.daten)=='Upload') {
    	window.document.getElementById("fileupload").style.display = 'block';
 	} else {
  		window.document.getElementById("fileupload").style.display = 'none';
 	}
}