function checkDatumOben(frm) {
  var day = parseInt(1, 10);
  var mon = parseInt(frm.amonat.options[frm.amonat.selectedIndex].value, 10);
  var yea = parseInt(frm.jahr.options[frm.jahr.selectedIndex].value, 10);
  if (!validDate(day, mon, yea)) {
    frm.amonat.focus();
    alert("Bitte wählen Sie ein gültiges Datum aus.");
    return false;
  }
  return true;
}
function checkStartDatumOben(frm) {
  var day=1;
  var mon = frm.amonat.options[frm.amonat.selectedIndex].value;
  var yea = parseInt(frm.jahr.options[frm.jahr.selectedIndex].value);
  var daynow = 1;
  var monthnow = parseInt(frm.sdac_MN.value);
  var yearnow = parseInt(frm.sdac_YN.value);
  if (!compareDate(daynow, monthnow, yearnow, day, mon, yea, 1)) {
    frm.amonat.focus();
    alert("Bitte wählen Sie ein Datum, das nicht in der Vergangenheit liegt.");
    return false;
  }
  return true;
}
function checkDatumAnreise(frm) {
  var day = parseInt(frm.Anreisetag.options[frm.Anreisetag.selectedIndex].value, 10);
  var mon = parseInt(frm.Anreisemonat.options[frm.Anreisemonat.selectedIndex].value, 10);
  var yea = parseInt(frm.Anreisejahr.options[frm.Anreisejahr.selectedIndex].value, 10);


  if (!validDate(day, mon, yea)) {
    frm.Anreisetag.focus();
    alert("Bitte wählen Sie ein gültiges Anreisedatum aus.");
    return false;
  }
  return true;
}
function checkDatumAbreise(frm) {
  var day = parseInt(frm.Abreisetag.options[frm.Abreisetag.selectedIndex].value, 10);
  var mon = parseInt(frm.Abreisemonat.options[frm.Abreisemonat.selectedIndex].value, 10);
  var yea = parseInt(frm.Abreisejahr.options[frm.Abreisejahr.selectedIndex].value, 10);

  if (!validDate(day, mon, yea)) {
    frm.Abreisetag.focus();
    alert("Bitte wählen Sie ein gültiges Abreisedatum aus.");
    return false;
  }
  return true;
}

function checkStartDatumAnreise(frm) {
  var day = parseInt(frm.Anreisetag.options[frm.Anreisetag.selectedIndex].value);
  var mon = frm.Anreisemonat.options[frm.Anreisemonat.selectedIndex].value;
  var yea = parseInt(frm.Anreisejahr.options[frm.Anreisejahr.selectedIndex].value);
  var daynow = parseInt(frm.sdac_DN.value);
  var monthnow = parseInt(frm.sdac_MN.value);
  var yearnow = parseInt(frm.sdac_YN.value);
  if (!compareDate(daynow, monthnow, yearnow, day, mon, yea, 1)) {
    frm.Anreisetag.focus();
    alert("Das angegebene Anreisedatum liegt in der Vergangenheit.");
    return false;
  }
  return true;
}

function checkStartDatumAbreise(frm) {
  var day = parseInt(frm.Abreisetag.options[frm.Abreisetag.selectedIndex].value);
  var mon = frm.Abreisemonat.options[frm.Abreisemonat.selectedIndex].value;
  var yea = parseInt(frm.Abreisejahr.options[frm.Abreisejahr.selectedIndex].value);
  var daynow = parseInt(frm.sdac_DN.value);
  var monthnow = parseInt(frm.sdac_MN.value);
  var yearnow = parseInt(frm.sdac_YN.value);
  if (!compareDate(daynow, monthnow, yearnow, day, mon, yea, 1)) {
    frm.Abreisetag.focus();
    alert("Das angegebene Abreisedatum liegt in der Vergangenheit.");
    return false;
  }
  return true;
}
function checkDatumAnreiseAbreise(frm) {
 var day = parseInt(frm.Anreisetag.options[frm.Anreisetag.selectedIndex].value);
  var mon = frm.Anreisemonat.options[frm.Anreisemonat.selectedIndex].value;
  var yea = parseInt(frm.Anreisejahr.options[frm.Anreisejahr.selectedIndex].value);
var anreise = yea;
if(mon<10){
	anreise=anreise+"0"+mon;}
else {
	anreise=anreise+mon;}
if(day<10){
	anreise=anreise+"0"+day;}
else {
	anreise=anreise+day;}

 var day = parseInt(frm.Abreisetag.options[frm.Abreisetag.selectedIndex].value);
  var mon = frm.Abreisemonat.options[frm.Abreisemonat.selectedIndex].value;
  var yea = parseInt(frm.Abreisejahr.options[frm.Abreisejahr.selectedIndex].value);
var abreise = yea;
if(mon<10){
	abreise=abreise+"0"+mon;}
else {
	abreise=abreise+mon;}
if(day<10){
	abreise=abreise+"0"+day;}
else {
	abreise=abreise+day;}


  if (abreise < anreise) {
    frm.Abreisetag.focus();
    alert("Das angegebene Abreisedatum liegt vor dem Anreisedatum.");
    return false;
  }
  return true;
}

function validDate(day, mon, year)   {

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


  if ((day < 1)  || (day > 31))  { return 0;  }
  if ((year < 0)  || (year > 9999) || (year == "NaN") || (year == "---")) { return 0;  }
  if ((mon != "1") && (mon != "2") && (mon != "3") && (mon != "4") && (mon != "5") && (mon != "6") && (mon != "7") && (mon != "8") && (mon != "9") && (mon != "10") && (mon != "11") && (mon != "12"))  { return 0; }
  if ((mon== "1") || (mon== "3") || (mon== "5") || (mon== "7") || (mon== "8") || (mon== "10") || (mon== "12")) { return 1;
  } else {
    if ((mon== "4") || (mon== "6") ||   (mon== "9") || (mon== "11")) {
      if (day <= 30)  {   return 1; }    }
    else {
      if (mon == "2")   {
        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 roomCheck(frm) {

  if (parseInt(frm.zimmer1.value) == 0) {
    alert("Geben Sie bitte die Anzahl der Zimmer ein!");
    frm.zimmer1.focus();
    return false;
  }
  return true;
}


function doCheckFormscout(frm) {
if(!checkDatumOben(frm)) { return false; }
if(!checkStartDatumOben(frm)) { return false; }
if(!checkDatumAnreise(frm)) { return false; }
if(!checkStartDatumAnreise(frm)) { return false; }
if(!checkDatumAbreise(frm)) { return false; }
if(!checkStartDatumAbreise(frm)) { return false; }
if(!checkDatumAnreiseAbreise(frm)) { return false; }
if(!checkText(frm.zimmer1)) { return false; }
if(!checkNumber(frm.zimmer1)) { return false; }
if(!checkValueRange(frm.zimmer1, "-999999.0", "999999.0", "false")) { return false; }
if(!checkText(frm.erw1)) { return false; }
if(!checkNumber(frm.erw1)) { return false; }
if(!checkValueRange(frm.erw1, "-999999.0", "999999.0", "false")) { return false; }
if(!checkText(frm.kind6_1)) { return false; }
if(!checkNumber(frm.kind6_1)) { return false; }
if(!checkValueRange(frm.kind6_1, "-999999.0", "999999.0", "false")) { return false; }
if(!checkText(frm.kind13_1)) { return false; }
if(!checkNumber(frm.kind13_1)) { return false; }
if(!checkValueRange(frm.kind13_1, "-999999.0", "999999.0", "false")) { return false; }


if(!roomCheck(frm)) { return false; }
var belegung1=frm.erw1.value+frm.kind6_1.value+frm.kind13_1.value;

if(belegung1 == 0 && parseInt(frm.zimmer1.value) > 0 ){
	alert("Geben Sie bitte die Anzahl der Erwachsenen und/oder der Kinder ein!");
   	 frm.erw1.focus();
   	 return false;
}




return true;
}


function compareDate(dayf, monthf, yearf, dayt, montht, yeart, equal) {
  if (parseInt(yeart) < parseInt(yearf)) {  return 0; }
  if (parseInt(yeart) > parseInt(yearf)) {  return 1; }
  if (parseInt(montht) < parseInt(monthf)) {  return 0; }
  if (parseInt(montht) > parseInt(monthf)) { return 1; }
  if (equal)   {
    if (parseInt(dayt) < parseInt(dayf))   {  return 0; }
	} else {
		if (parseInt(dayt) <= parseInt(dayf))   {  return 0; }
  }
  return 1;
}
function convertLocaleSpecificNumberToFloat(val) {
  var tempVal = ""; 
  for (var i=0;i<val.length;i++)   {      
   letter=val.substring(i,i+1);          
   if (letter != ".") {
     if (letter == ",") {
       tempVal = tempVal + "."; 
     } else {
       tempVal = tempVal + letter; 
     }
    }
  }
  return tempVal*1;
}



function checkNumber(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 checkValueRange(entry, min, max, empty) {
  if (entry.value.length==0 && empty) { return true; }
  var value=parseFloat(convertLocaleSpecificNumberToFloat(entry.value));
  if (value>parseFloat(max)) {
    alert("Größte erlaubte Eingabe: " + max );
    entry.focus();
    return false;
  } else if (value<parseFloat(min)) {
    alert("Kleinste erlaubte Eingabe: " + min );
    entry.focus();
    return false;
  } else {
    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 oeffnen_ortsplan(bild,breite,hoehe,titel) {
posLeft=250;
posTop=100;
tb=breite;
th=hoehe;
bb=breite;
bh=hoehe;
var w = (screen.width / 2) - (bb / 2);
posLeft=w;


	newWindow = window.open("","newWindow", "width="+bb+", height="+bh+", left="+posLeft+", top="+posTop+", toolbar=no,status=no,scrollbars=no,resizable=no,menubar=no");
	newWindow.document.open();
	newWindow.document.write('<html><title>'+titel+'</title><body style="margin:0;background-color:123D8F">'); 
	newWindow.document.write('<img src='+bild+' width='+breite+' height='+hoehe+' alt="Deutschkreutz">'); 
	
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}


function oeffnen_radfahren(bild,breite,hoehe,titel) {
posLeft=250;
posTop=10;
tb=breite;
th=hoehe;
bb=breite + 20;
//bh=hoehe + 20;
bh=480;
var w = (screen.width / 2) - (bb / 2);
posLeft=w;


	newWindow = window.open("","newWindow", "width="+bb+", height="+bh+", left="+posLeft+", top="+posTop+", toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
	newWindow.document.open();
	newWindow.document.write('<html><head><title>'+titel+'</title>');
	newWindow.document.write('<style>');
	newWindow.document.write('.tdb1 {background-color:#EEEEEE;border: solid; border-width: 1px 1px 1px 1px; border-color: #BBBBBB #BBBBBB #BBBBBB #BBBBBB;}');
	newWindow.document.write('.bild {background-color:#FFFFFF;border: solid; border-width: 1px 1px 1px 1px; border-color: #000066 #000066 #000066 #000066;}');
	newWindow.document.write('.small {color:#000066;font-size:11px;font-family:Verdana,Arial;}');
	newWindow.document.write('</style></head>');
	newWindow.document.write('<body bgcolor="darkblue" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">'); 
	newWindow.document.write('<table align="center" width='+tb+' height='+th+' class="tdb1x" cellpadding="0" cellspacing="0">');
	newWindow.document.write('<tr><td align="center"><img src='+bild+' width='+breite+' height='+hoehe+' ></td></tr>'); 
	newWindow.document.write('</table>'); 
	
	
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function check_kontakt(){
 if (document.f.Nachricht.value == "")       {
             alert ("Bitte geben Sie eine Nachricht  ein!");
             document.f.Nachricht.focus();
             return false;    }      
 if (document.f.Name.value == "")       {
             alert ("Bitte geben Sie Ihren Namen  ein!");
             document.f.Name.focus();
             return false;             }

if(document.f.Email.value ==""){
	alert ("Bitte geben Sie Ihre Mailadresse ein!");
		document.f.Email.focus();             
		return false;
             }
if(document.f.Email.value.indexOf('@') == -1) {
   alert("Bitte geben Sie eine gültige Mailadresse ein!");
   document.f.Email.focus();
   return false;
  }
        return true;
        }


function check_anfrage(){
hgtrans="transparent";
hgfarbe="#DBE1ED";
document.getElementById("Auswahl").style.backgroundColor = hgtrans;
if (document.f.Auswahl[0].checked == false&&document.f.Auswahl[1].checked == false) {
	alert ("Bitte Zimmeranfrage oder Reservierung auswählen!");
	document.getElementById("Auswahl").style.backgroundColor = hgfarbe;
	document.f.Auswahl[0].focus();
      return false;
}

document.getElementById("Anreise").style.backgroundColor = hgtrans;
document.getElementById("Abreise").style.backgroundColor = hgtrans;
if(!checkDatumAnreise(document.f)) { 
	document.getElementById("Anreise").style.backgroundColor = hgfarbe;
	return false; }
if(!checkStartDatumAnreise(document.f)) { 
	document.getElementById("Anreise").style.backgroundColor = hgfarbe;
	return false; }
if(!checkDatumAbreise(document.f)) { 
	document.getElementById("Abreise").style.backgroundColor = hgfarbe;
	return false; }
if(!checkStartDatumAbreise(document.f)) { 
	document.getElementById("Abreise").style.backgroundColor = hgfarbe;
	return false; }
if(!checkDatumAnreiseAbreise(document.f)) { 
	document.getElementById("Anreise").style.backgroundColor = hgfarbe;
	document.getElementById("Abreise").style.backgroundColor = hgfarbe;
	return false; }

document.getElementById("Zimmeranzahl").style.backgroundColor = hgtrans;
x=document.f.zimmerarten.value;
var sp = x.split("_");
za=0; 
for(i=0;i<sp.length;i++){
	x="zimmer_"+sp[i];
 	za=za+document.f[x].value;
}
if(za<1){ 
	document.getElementById("Zimmeranzahl").style.backgroundColor = hgfarbe;
 	alert ("Wählen Sie bitte eine Zimmeranzahl aus!");
	x="zimmer_"+sp[0];
	document.f[x].focus();
      return false;}

document.getElementById("Erwachseneanzahl").style.backgroundColor = hgtrans;
if(!checkText(document.f.Erwachsene)) { 
	document.getElementById("Erwachseneanzahl").style.backgroundColor = hgfarbe;
	return false; }
if(!checkNumber(document.f.Erwachsene)) { 
	document.getElementById("Erwachseneanzahl").style.backgroundColor = hgfarbe;
	return false; }
if(!checkValueRange(document.f.Erwachsene, "1", "999999.0", "false")) { 
	document.getElementById("Erwachseneanzahl").style.backgroundColor = hgfarbe;
	return false; }


document.getElementById("Kinderanzahl").style.backgroundColor = hgtrans;
if(!checkNumber(document.f.Kinder)) {
	document.getElementById("Kinderanzahl").style.backgroundColor = hgfarbe; 
	return false; }
if(!checkValueRange(document.f.Kinder, "0", "999999.0", "false")) { 
	document.getElementById("Kinderanzahl").style.backgroundColor = hgfarbe;
	return false; }

document.getElementById("Nachname").style.backgroundColor = hgtrans;
if (document.f.Nachname.value == ""){
		document.getElementById("Nachname").style.backgroundColor = hgfarbe;
            alert ("Bitte geben Sie Ihren Nachnamen ein!");
		document.f.Nachname.focus();
            return false;}

document.getElementById("Strasse").style.backgroundColor = hgtrans;
 if (document.f.Strasse.value == ""){
document.getElementById("Strasse").style.backgroundColor = hgfarbe;
            alert ("Bitte geben Sie Ihre Adresse ein!");
		document.f.Strasse.focus();
            return false;}

document.getElementById("Adresse").style.backgroundColor = hgtrans;
 if (document.f.PLZ.value == "")            {
		document.getElementById("Strasse").style.backgroundColor = hgfarbe;
            alert ("Bitte geben Sie Ihre Adresse ein!");
		document.f.PLZ.focus();
            return false;
             }
 if (document.f.Ort.value == "")            {
		document.getElementById("Strasse").style.backgroundColor = hgfarbe;
            alert ("Bitte geben Sie Ihre Adresse ein!");
		document.f.Ort.focus();
            return false;
             }

document.getElementById("Email").style.backgroundColor = hgtrans;

if(document.f.Email.value.indexOf('@') == -1) {
document.getElementById("Email").style.backgroundColor = hgfarbe;
   alert("Bitte geben Sie eine gültige Mailadresse ein!");
   document.f.Email.focus();
   return false;
  }

         
          

       return true;
 }
 
 
 
 function zoomen(bild) {
 window.location.href = "#top";
document.getElementById("bildg").src = bild;

}
function zeigen(){
document.getElementById("hauptbild").style.visibility = "visible";
}

