String.prototype.trim = function () {
    return this.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function preLoad (id)
{
  var warteTxt = '<div class="preLoad" style="display: block;"><img src="/grafik/layout/preloader.gif" /></div>';
  document.getElementById(id).innerHTML = warteTxt;
}

/* Checkboxen markieren und demarkieren */

function markAllCheckbox( container_id , anzahl )
{
  var checkbox;
  var checkboxName;

  for ( var i = 1; i <= anzahl; i++ )
  {
    checkboxName = container_id + "-" + i;
    checkbox = document.getElementById( checkboxName );
    if ( checkbox && checkbox.type == 'checkbox' )
    {
      if ( checkbox.disabled == false )
      {
          checkbox.checked = true;
      }
    }
  }

  return true;
}

function demarkAllCheckbox( container_id , anzahl )
{
  var checkbox;
  var checkboxName;

  for ( var i = 1; i <= anzahl; i++ )
  {
    checkboxName = container_id + "-" + i;
    checkbox = document.getElementById( checkboxName );
    if ( checkbox && checkbox.type == 'checkbox' )
    {
      if ( checkbox.disabled == false )
      {
          checkbox.checked = false;
      }
    }
  }

  return true;
}

/*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;
		}
	}
}

/* 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();}}

/* testen ob zahl */
  function check(wert) {
  	if (isNaN(wert)) {
      	return Number(0);
   	} else {
    		return wert;
   	}
  }

/* layer ein-/ausblenden */
  function layerSee(idfld){
  	elem = document.getElementById( idfld );
  	if( elem.style.display == 'none' ){
  		elem.style.display = 'block';
  	}
  	else if( elem.style.display == 'block' ){
  		elem.style.display = 'none';
  	}
  }

/* weiterleiten */
  function goUrl(Ziel){
  	window.location.href = Ziel;
  }

/* weiterleiten mit ladebalken */
  function goToThisSite(field){
    document.getElementById("foo").style.display = "none";
    document.getElementById("load").style.display = "block";
    //loadLoader();
    //location.href=document.getElementById(field).value;
    document.getElementById(field).submit();
  }

/* nur ladebalken anzeigen */
  function loadData(field,field2){
    document.getElementById(field).style.display = "none";
    document.getElementById(field2).style.display = "block";
  }
  
/* zeit anhalten */
  function sleep(ms){
    var zeit=(new Date()).getTime();
    var stoppZeit=zeit+ms;
    while((new Date()).getTime()<stoppZeit){};
  } 

function preLoad (id)
{
  var warteTxt = '<div class="preLoad"><img src="/grafik/layout/preloader.gif" /></div>';
  document.getElementById(id).innerHTML = warteTxt;
}
