function roomCheck(frm) {

  if (parseInt(frm.r0.value) == 0) {
    alert("Geben Sie bitte die Anzahl der Zimmer ein!");
    frm.r0.focus();
    return false;
  }
  return true;
}
function doCheckFormcurrency(frm) {

return true;
}

function checkStartDate(frm) {
  var day = parseInt(frm.sd_D.options[frm.sd_D.selectedIndex].value);
  var mon = frm.sd_M.options[frm.sd_M.selectedIndex].value;
  var yea = parseInt(frm.sd_Y.options[frm.sd_Y.selectedIndex].value);
  today = new Date();
  var daynow = today.getDate();
  var monthnow = today.getMonth();
  var yearnow = today.getYear();
  if (!compareDate(daynow, monthnow, yearnow, day, mon, yea, 1)) {
    frm.sd_D.focus();
    alert("Das angegebene Anreisedatum liegt in der Vergangenheit.");
    return false;
  }
  return true;
}
var disableMenu = false;
function checkDateRange(frm) {
  var sday = parseInt(frm.sd_D.options[frm.sd_D.selectedIndex].value);
  var smon = frm.sd_M.options[frm.sd_M.selectedIndex].value;
  var syea = parseInt(frm.sd_Y.options[frm.sd_Y.selectedIndex].value);
  var eday = parseInt(frm.ed_D.options[frm.ed_D.selectedIndex].value);
  var emon = frm.ed_M.options[frm.ed_M.selectedIndex].value;
  var eyea = parseInt(frm.ed_Y.options[frm.ed_Y.selectedIndex].value);
  if (!compareDate(sday, smon, syea, eday, emon, eyea, 1)) {
    frm.ed_D.focus();
    alert("Das angegebene Enddatum liegt vor dem Anreisedatum.");
    return false;
  }
  return true;
}

  function openNewExtWindow(url) {
  
     ExtLinkWindow =  window.open(url,"Extended","resizable=yes,location=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes");
     ExtLinkWindow.focus();
  
}

      
var visibleMenuBody = null;


function evlHideVisibleMenuBody(event) {
  var toElem = event.toElement;
  while((toElem!=null)&&(toElem.className!="mhead")&&(toElem.className!="mbody")) {
    toElem = toElem.parentNode;
  }
  if(toElem!=null) {
    event.cancelBubble = true;
    return false;
  }
  if(visibleMenuBody!=null) {
    visibleMenuBody.style.display = "none";
    fnUnHighlightMenuHead(visibleMenuBody.parentNode);
  }
}

function showMenuBody(event) {
  if(!document.all) {
    return false;
  }
  if(disableMenu) {
    return false;
  }
  if(visibleMenuBody!=null) {
    visibleMenuBody.style.display = "none";
    fnUnHighlightMenuHead(visibleMenuBody.parentNode);
  }
  var currentTarget = event.srcElement;
  while(currentTarget.className!="mhead") {
    currentTarget = currentTarget.parentNode;
  }
  currentTarget.attachEvent("onmouseout", evlHideVisibleMenuBody);
  var menuBody = currentTarget.firstChild.nextSibling;
  while((menuBody!=null) && (menuBody.className!="mbody")) {
    menuBody = menuBody.nextSibling;
  }
  if(menuBody!=null) {
    if(menuBody.getAttribute("done")==null) {
      menuBody.setAttribute("done", "true");
      menuBody.attachEvent("onmouseover", evlCancelEvent);
      menuBody.attachEvent("onmouseout", evlHideVisibleMenuBody);
      var entries = menuBody.childNodes;
      var i=0;
      for(i=0;i<entries.length;i++) {
        var menuEntry = entries[i];
        if(menuEntry.tagName=="A") {
          menuEntry.attachEvent("onmouseover", evlHighlightMenuEntry);
          menuEntry.attachEvent("onmouseout", evlUnHighlightMenuEntry);
          setMenuEntryStyles(currentTarget, menuEntry);
        }
      }
    }

    visibleMenuBody = menuBody;
    menuBody.style.display = "block";
    var boundingBox = currentTarget.getBoundingClientRect();
    menuBody.style.left = (boundingBox.left-2) + document.body.scrollLeft + "px";
    menuBody.style.top = (boundingBox.bottom-2) + document.body.scrollTop + "px";
  }
  fnHighlightMenuHead(currentTarget);
  return true;
}

function setMenuEntryStyles(menuHead, menuEntry) {
  var ebs = findAttribute(menuHead, "ebs");
  var ebc = findAttribute(menuHead, "ebc");
  var ebw = findAttribute(menuHead, "ebw");
  var ep = findAttribute(menuHead, "ep");
  var ebgcol = findAttribute(menuHead, "ebgcol");
  var ecol = findAttribute(menuHead, "ecol");
  var etd = findAttribute(menuHead, "etd");
  menuEntry.style.textDecoration = etd;
  menuEntry.style.backgroundColor = ebgcol;
  menuEntry.style.color = ecol;
  menuEntry.style.whiteSpace = "nowrap";
  //menuEntry.style.width = "100%";
  menuEntry.style.width = "129px";
  menuEntry.style.borderStyle = "none";
  menuEntry.style.borderBottomStyle = ebs;
  menuEntry.style.borderBottomColor = ebc;
  menuEntry.style.borderBottomWidth = ebw;
  menuEntry.style.padding = ep;
}

function setHighlightedMenuEntryStyles(menuHead, menuEntry) {
  var ebs = findAttribute(menuHead, "hebs");
  var ebc = findAttribute(menuHead, "hebc");
  var ebw = findAttribute(menuHead, "hebw");
  var ep = findAttribute(menuHead, "hep");
  var ebgcol = findAttribute(menuHead, "hebgcol");
  var ecol = findAttribute(menuHead, "hecol");
  var etd = findAttribute(menuHead, "hetd");
  menuEntry.style.textDecoration = etd;
  menuEntry.style.backgroundColor = ebgcol;
  menuEntry.style.color = ecol;
  menuEntry.style.whiteSpace = "nowrap";
  //menuEntry.style.width = "100%";
  menuEntry.style.width = "129px";
  menuEntry.style.borderStyle = "none";
  menuEntry.style.borderBottomStyle = ebs;
  menuEntry.style.borderBottomColor = ebc;
  menuEntry.style.borderBottomWidth = ebw;
  menuEntry.style.padding = ep;
}


function findAttribute(menuHead, attributeName) {
  var att = menuHead.getAttribute(attributeName);
  if(att==null) {
    att = document.getElementById(menuHead.getAttribute("tmpl")).getAttribute(attributeName);
  }
  return att;
}

function evlCancelEvent(event) {
  event.cancelBubble = true;
}

function fnHighlightMenuHead(menuHead) {
  var bgcol = menuHead.getAttribute("hhbgcol");
  if(bgcol==null) {
    bgcol = document.getElementById(menuHead.getAttribute("tmpl")).getAttribute("hhbgcol");
  }
  var col = menuHead.getAttribute("hhcol");
  if(col==null) {
    col = document.getElementById(menuHead.getAttribute("tmpl")).getAttribute("hhcol");
  }
  var firstChild = menuHead.firstChild;
  menuHead.style.backgroundColor = bgcol;
  menuHead.style.color = col;
  if(firstChild.style) {
    firstChild.style.color = col;
    firstChild.style.backgroundColor = bgcol;
  }
}

function evlUnHighlightMenuHeader(event) {
  if(!document.all) {
    return false;
  }
  if(disableMenu) {
    return false;
  }

/*
  if(event.srcElement.className!="mhead") {
    return false;
  }
*/
  var firstChild = event.srcElement.firstChild;
  var menuBody = null;
  if(firstChild!=null) {
    menuBody = firstChild.nextSibling;
  }
  if(menuBody!=null) {
    while((menuBody!=null) && (menuBody.className!="mbody")) {
      menuBody = menuBody.nextSibling;
    }
    if(menuBody!=null) {
      if(menuBody.style.display=="none") {
        fnUnHighlightMenuHead(event.srcElement);
      }
    } else {
      //fnUnHighlightMenuHead(event.srcElement.parentNode);
    }
  } else {
    if(event.srcElement.className!="mhead") {
      fnUnHighlightMenuHead(event.srcElement.parentNode);
    }
  }
  return true;
}

var rc = 0;

function fnUnHighlightMenuHead(menuHead) {
  var bgcol = menuHead.getAttribute("hbgcol");
  if(bgcol==null) {
    if(menuHead.getAttribute("tmpl")==null) {
      return;
    }
    if(document.getElementById(menuHead.getAttribute("tmpl"))==null) {
      return;
    }
    bgcol = document.getElementById(menuHead.getAttribute("tmpl")).getAttribute("hbgcol");
  }
  var col = menuHead.getAttribute("hcol");
  if(col==null) {
    col = document.getElementById(menuHead.getAttribute("tmpl")).getAttribute("hcol");
  }
  var firstChild = menuHead.firstChild;
  menuHead.style.backgroundColor = bgcol;
  menuHead.style.color = col;
  if(firstChild.style) {
    firstChild.style.color = col;
    firstChild.style.backgroundColor = bgcol;
  }
}

function evlHighlightMenuEntry(event) {
  var currentTarget = event.srcElement;
  /*
  while(currentTarget.tagName!="DIV") {
    currentTarget = currentTarget.parentNode;
  }
  */
  var menuHead = currentTarget.parentNode.parentNode;
  setHighlightedMenuEntryStyles(menuHead, currentTarget);
  event.cancelBubble = true;
}

function evlUnHighlightMenuEntry(event) {
  var currentTarget = event.srcElement;
  var menuHead = currentTarget.parentNode.parentNode;
  setMenuEntryStyles(menuHead, currentTarget);
  event.cancelBubble = true;

  var toElem = event.toElement;
  while((toElem!=null)&&(toElem.className!="mhead")&&(toElem.className!="mbody")) {
    toElem = toElem.parentNode;
  }
  if(toElem==null) {
    evlHideVisibleMenuBody(event);
  }
}

      function doCheckFormscout(frm) {
if(!checkDuration(frm.d)) { return false; }
if(!checkNumber(frm.d)) { return false; }
if(!checkValueRange(frm.d, "-999999.0", "999999.0", "true")) { return false; }
if(!checkNumber(frm.r0)) { return false; }
if(!checkValueRange(frm.r0, "-999999.0", "999999.0", "true")) { return false; }
if(!checkNumber(frm.a0)) { return false; }
if(!checkValueRange(frm.a0, "-999999.0", "999999.0", "true")) { return false; }
if(!checkStartDate(frm)) { return false; }
if(!setOnChangeDur(frm)) { return false; }
if(!roomCheck(frm)) { return false; }

return true;
}

  function openNewWindow(url) {
    ExtLinkWindow =  window.open(url,"Extended","resizable=yes,location=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes");
    ExtLinkWindow.focus();
  }

function setOnChangeDur(frm) {
  if (frm.d.value < 1) {
    frm.d.focus();
    frm.d.select();
    alert("Die Dauer muss größer als 0 sein.");
    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 replaceSpaceWithNbsp(strText) {
  if (strText == null) {
    return null;
  }
  var strBefore;
  var strAfter = strText;
  do {
    strBefore = strAfter;
    strAfter = strBefore.replace(" ", "&nbsp;");
  } while (strBefore != strAfter);
  return strAfter;
}

function checkDuration(frm) {
  var dur = parseInt(frm.value);
  if (dur > 50) {
    frm.focus();
    frm.select();
    alert("Bitte Urlaubsdauer < 50 eingeben");
    return false;
  }
  return true;
}
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 openExtWindow(url,target) {
  
     ExtLinkWindow =  window.open(url,target,"resizable=yes,location=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes");
     ExtLinkWindow.focus();
  
}

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 includeExtWindow(url) {
  
    window.open(url,"_top","resizable=yes,location=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes");
  
}

function doOnLoad() {

var loadingImage = document.getElementById("loadingImg");
if (loadingImage != null) {
  loadingImage.src = "/at/layoutimg/0.gif";
}

  if(navigator.userAgent.indexOf("MSIE 4")!=-1) {
    if(!disableMenu) { disableMenu = true; }
  }
  if(document.all) {
    if(!disableMenu) {
      document.attachEvent("onclick", evlHideVisibleMenuBody);
    }
  }
      
return true;
}

function doOnUnLoad() {

return true;
}