function form_absenden(programm){
document.f.action=programm;
document.f.target="_blank";
document.f.submit();
//return;
}

function MM_openBrWindow(theURL,winName,features) { 
window.open(theURL,winName,features);
}
function MM_openBrWindow1(theURL,winName,features) { 
fenster=window.open(theURL,winName,features);
fenster.focus();
}
function checkRadio(entry,meldung){

sch=0;
for (var i = 0; i < entry.length; i++) {
    if(entry[i].checked == true){sch++;}
  }
if(sch<1){
	entry[0].focus();
	alert("Bitte bei " +meldung+ " eine Auswahl treffen!");
	return false;}

return true;
}

function checkDatum(entry){
var val = entry.value + "";
if(val.length < 10 || val.lenght > 10){
	entry.focus();
     
      alert("Ungültiges Datum!");
      return false;}
if(val.substr(2,1) != "." || val.substr(5,1) != "."){
	entry.focus();
     
      alert("Ungültiges Datum!");
      return false;}
jj=val.substr(6,4);
mm=val.substr(3,2);
tt=val.substr(0,2);
 if (!validDate(tt, mm, jj)) {
	entry.focus();
     
      alert("Ungültiges Datum!");
      return false;}
return true;
}

function checkZeit(entry){
var val = entry.value + "";
if(val.length < 5 || val.lenght > 5){
	entry.focus();
     
      alert("Ungültige Eingabe!");
      return false;}
if(val.substr(2,1) != ":"){
	entry.focus();
     
      alert("Ungültige Eingabe!");
      return false;}
hh=val.substr(0,2);
mm=val.substr(3,2);


 if ((hh < "00")  || (hh > "24") || (hh == "NaN")) { 
	entry.focus();
     
      alert("Ungültige Eingabe!");
      return false;}
 if ((mm < "00")  || (mm > "59") || (mm == "NaN")) {entry.focus();
     
      alert("Ungültige Eingabe!");
      return false;}

return true;
}
function validDate(day, mon, year)   {

 // mon = mon + "";
  //year = year + "";
  //mon = mon.toUpperCase();


 

 if ((day < "01")  || (day > "31") || (day == "NaN")) { return 0;  }
 if ((mon < "01")  || (mon > "12") || (mon == "NaN")) { return 0;  }
  if ((year < 0)  || (year > 9999) || (year == "NaN") || (year == "---")) { return 0;  }
  if ((mon != "01") && (mon != "02") && (mon != "03") && (mon != "04") && (mon != "05") && (mon != "06") && (mon != "07") && (mon != "08") && (mon != "09") && (mon != "10") && (mon != "11") && (mon != "12"))  { return 0; }
  if ((mon== "01") || (mon== "03") || (mon== "05") || (mon== "07") || (mon== "08") || (mon== "10") || (mon== "12")) { return 1;
  } else {
    if ((mon== "04") || (mon== "06") ||   (mon== "09") || (mon== "11")) {
      if (day <= 30)  {   return 1; }    }
    else {
      if (mon == "02")   {
        if (((year % 4) == 0) && ((year % 100) != 0))  {
          if (day <= 29) {  return 1;  }
        }
        if ((year % 400) == 0) {
          if (day <= 29)   {  return 1;    }
        }
        if (day <= 28) {  return 1;    }
      } else {
        return 0;
      }
    }
  }
  return 0;
}



function checkAnzahl(entry) {
  var val = entry.value + "";         
  var maxDecimalPlaces; 
  if (entry.form[entry.name+"_decimalPlaces"] == null) { 
    maxDecimalPlaces = 0; 
  } else { 
    maxDecimalPlaces = parseInt(eval(entry.form[entry.name+"_decimalPlaces"].value));
  }
  var newVal = ""; 
  var decimalPoint=false;
  var decimalPlaces=0;
  var thousandFoundIndex = -1;
  var dotFoundIndex = -1;
  var invalidNumber = false;
  if (val.length == 1 && val.substring(0,1) =="-") {      
    invalidNumber = true;
  }
  for (var i=0;i<val.length;i++)   {      
    letter=val.substring(i,i+1);          
    if ( ((letter<"0" || "9"<letter)&&(letter!=",")&&(letter!="-") && (letter!="."))
         || ((letter==",")&&(decimalPoint==true)) ) {
      entry.focus();
      entry.select();
      alert("Bitte nur Zahlen eingeben!");
      return false;
    }
    if ((decimalPoint==true)&&(letter!="-")) { decimalPlaces++; }
    if (decimalPlaces>maxDecimalPlaces && letter!="0") {
      entry.focus();
      entry.select();
      alert("Maximal erlaubte Dezimalstellen: " +maxDecimalPlaces);
      return false;
    }
    if ((letter=="-") && i!=0) {
      entry.focus();
      entry.select();
      alert("Ungültige Zahl");
      return false;
    }
    if (letter==",") { decimalPoint=true; }
    if (letter==".") {
      if (dotFoundIndex >= 0) {
        invalidNumber = true;
      } else {
        thousandFoundIndex = i;
      }
    }
    if (letter==",") {
      dotFoundIndex = i;
    }
    if (dotFoundIndex == i && i == (val.length - 1))  {
      invalidNumber = true;
    }
    if (thousandFoundIndex >= 0 && dotFoundIndex == i && ((dotFoundIndex - thousandFoundIndex) != 4))  {
      invalidNumber = true;
    }
    if (thousandFoundIndex >= 0 && dotFoundIndex < 0 && (i == val.length - 1) && (i - thousandFoundIndex != 3 )){
      invalidNumber = true;
    }
    newVal = newVal + letter;
  }
  entry.value = newVal;
  if (invalidNumber) {
    alert("Ungültige Zahl");
    entry.focus();
    entry.select();
    return false;
  }
  return true;
}

function checkText(entry) {
  var val = entry.value + "";
  val = val.replace(/ */, "");
  if (val.length > 0)  { return true; }
  entry.focus();
  entry.select();
  alert("Dieses Feld darf nicht leer sein.");
  return false;
}


function checkDatumVonBis() {
von=document.f.beginn.value;
bis=document.f.ende.value;
vjj=von.substr(6,4);
vmm=von.substr(3,2);
vtt=von.substr(0,2);
von=vjj+vmm+vtt;
bjj=bis.substr(6,4);
bmm=bis.substr(3,2);
btt=bis.substr(0,2);
bis=bjj+bmm+btt;


  if (bis < von) {

alert("Bitte wählen Sie ein Ende-Datum, dass nach dem Beginn-Datum liegt.");
  document.f.ende.focus();
    return false;
  }
  return true;
}



function createXMLHttpRequest() {
var ua;
if(window.XMLHttpRequest) {
    try {
      ua = new XMLHttpRequest();
    } catch(e) {
      ua = false;
    }
  } else if(window.ActiveXObject) {
    try {
      ua = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
      ua = false;
    }
  }
  return ua;
}


function chngFrameself(dropdown) {

	var index = dropdown.selectedIndex;
	var chosen = dropdown.options[index].value;	
	//alert(chosen);
//return;
	//if (index > 0) {window.location = chosen;}
	window.location = chosen;
}
