cControlID = '';
nMaxItem = 5;
NameIndex = 0;
DefaultState = 1;
MouseOverState = 2;
MouseDownState = 3;
imgCounter = 0;
var ibehost="";
var doscrolltoview = true;
function setibehost(newhost){ ibehost=newhost; }
function setscrolltoview(newval){ doscrolltoview=newval;}
function scrolltoview(ele,top){
  try{
    if (doscrolltoview==true){
      ele.scrollIntoView(top);
    }
  }catch(e){}
} 

ImageList = new Array();
var formsubmitted = false;
function AddImageToImageList(name, Default, MouseOver, MouseDown){
	ImageList[imgCounter] = new Array(nMaxItem);
	ImageList[imgCounter][NameIndex] = name;
	ImageList[imgCounter][DefaultState] = new Image();
	ImageList[imgCounter][DefaultState].src = Default;
	if (MouseOver != "") {
		ImageList[imgCounter][MouseOverState] = new Image();
		ImageList[imgCounter][MouseOverState].src = MouseOver;
	}
	if (MouseDown != "") {
		ImageList[imgCounter][MouseDownState] = new Image();
		ImageList[imgCounter][MouseDownState].src = MouseDown;
	}

	imgCounter++;
}
function ReplaceImage(name, state)
{
	for (i = 0; i < imgCounter; i++) {
		if (document.images[ImageList[i][NameIndex]] != null) {
			if ((name == ImageList[i][NameIndex]) && (ImageList[i][state] != null))
				document.images[name].src = ImageList[i][state].src;
		}
	}
}
function doibesubmit(action){
  if (!formsubmitted){
    if (typeof action != 'undefined'){
      if (document.getElementById("action") != null) {
        document.getElementById("action").value = action;
      }
    }
    if (document.getElementsByName("publicibeanwahlActionForm").length>0){
      document.getElementsByName("publicibeanwahlActionForm")[0].submit();
    } else if (document.getElementsByName("publicibelistresultActionForm").length>0){
      document.getElementsByName("publicibelistresultActionForm")[0].submit();
    } else if (document.getElementsByName("publicibedetailsActionForm").length>0){
      document.getElementsByName("publicibedetailsActionForm")[0].submit();
    }
  }
  formsubmitted = true;
}
function doibesubmit2(action){
  if (!formsubmitted){
    if (typeof action != 'undefined'){
      if (document.getElementById("action") != null) {
        document.getElementById("action").value = action;
      }
      try{ 
        var xx = document.getElementsByName("action");
        for (var i = 0; i < xx.length; i++) { xx[i].value = action; }
      }catch(e2){}
    }    
    if (document.getElementsByName("publicibedetailsActionForm").length>0){
      document.getElementsByName("publicibedetailsActionForm")[0].submit();
    } else if (document.getElementsByName("publicibelistresultActionForm").length>0){
      document.getElementsByName("publicibelistresultActionForm")[0].submit();
    } else if (document.getElementsByName("publicibeanwahlActionForm").length>0){
      document.getElementsByName("publicibeanwahlActionForm")[0].submit();
    }
  }
  formsubmitted = true;
}
function setControlID(newid){
  cControlID = newid;
}
function dosearch(){
  try{
    try{user_onsearchaction();}catch(ee){};
    doSearchAction();
  }catch(e){}
  try{
    aktiviereHinweis();
  }catch(e){}
  try{
    disablebutton('btnsearch');
  }catch(e){}
  doibesubmit("search");
}
function doreset(){
  try{
    try{user_onresetaction();}catch(ee){};
    doResetAction();
  }catch(e){}
  try{
    disablebutton('btnreset');
  }catch(e){}
  doibesubmit("reset");
}
function doUpdateErw(){
  try{
    var erwval = document.getElementById("erw").value;
    if (erwval=="0"){
      document.getElementById("kids").style.display="none";
      document.getElementById("kidsage").style.display="none";
    } else {
      document.getElementById("kids").style.display="";
      doUpdateKids();
    }
  }catch(e){}
}
function doUpdateKids(){
  try{
    var kidval = document.getElementById("kinder").value;
    if (kidval=="0"){
      document.getElementById("kidsage").style.display="none";
      document.getElementById("kinderalter1").style.display="none";
      document.getElementById("kinderalter2").style.display="none";
      document.getElementById("kinderalter3").style.display="none";
    } else if (kidval=="1"){
      document.getElementById("kidsage").style.display="";
      document.getElementById("kinderalter1").style.display="";
      document.getElementById("kinderalter2").style.display="none";
      document.getElementById("kinderalter3").style.display="none";
    } else if (kidval=="2"){
      document.getElementById("kidsage").style.display="";
      document.getElementById("kinderalter1").style.display="";
      document.getElementById("kinderalter2").style.display="";
      document.getElementById("kinderalter3").style.display="none";
    } else if (kidval=="3"){
      document.getElementById("kidsage").style.display="";
      document.getElementById("kinderalter1").style.display="";
      document.getElementById("kinderalter2").style.display="";
      document.getElementById("kinderalter3").style.display="";
    }
  }catch(e){
  }
}
function anr_ch(cpref){
  if (!cpref) cpref = "";
  anrabrgueltig = false;
  var danr = ibechdate(cpref+'anr');
  if (danr){
    var nae = ibechint(cpref+'naechte',1,99);
    var dabr = addDays(danr,nae);
    document.getElementById(cpref+'abr').value = formatDate(dabr);
    ibechdate(cpref+'abr');
    anrabrgueltig = true;
  }
}
function nae_ch(cpref){
  if (!cpref) cpref = "";
  anrabrgueltig = false;
  var nae = ibechint(cpref+'naechte',1,99);
  var danr = ibechdate(cpref+'anr','anrl','danrl');
  if (danr){
    var dabr = addDays(danr,nae);
    document.getElementById(cpref+'abr').value = formatDate(dabr);
    if (document.getElementById(cpref+'darinnaechte').value!='') document.getElementById(cpref+'darinnaechte').value = nae;
    ibechdate(cpref+'abr');
    anrabrgueltig = true;
  }
}
function dnae_ch(cpref){
  if (!cpref) cpref = "";
  anrabrgueltig = false;
  var nae = ibechint(cpref+'naechte',1,99);
  if (document.getElementById(cpref+'darinnaechte').value=='0') document.getElementById(cpref+'darinnaechte').value = '';
  if (document.getElementById(cpref+'darinnaechte').value!=''){
    var dnae = document.getElementById(cpref+'darinnaechte').value;
    if (nae < dnae) {
      document.getElementById(cpref+'darinnaechte').value = nae;
    }
  }
}
function abr_ch(cpref){
  if (!cpref) cpref = "";
  anrabrgueltig = false;
  var dabr = ibechdate(cpref+'abr');
  if (dabr){
    var danr = ibechdate(cpref+'anr');
    var nae = ibechint(cpref+'naechte',1,99);
    if (!danr){
      danr = addDays(dabr, nae*(-1));
      document.getElementById(cpref+'anr').value = formatDate(danr);
      ibechdate(cpref+'anr');
    } else {
      if (dabr<=danr){
        nae = 1;
        danr = addDays(dabr, -1);
        document.getElementById(cpref+'naechte').value = nae;
        if (document.getElementById(cpref+'darinnaechte').value!='') document.getElementById(cpref+'darinnaechte').value = nae;
      } else {
        nae = deltaDays(danr, dabr);
        document.getElementById(cpref+'naechte').value = nae;
        if (document.getElementById(cpref+'darinnaechte').value!='') document.getElementById(cpref+'darinnaechte').value = nae;
        nae = chint(cpref+'naechte',1,99);
        danr = addDays(dabr, nae*(-1));
      }
      document.getElementById(cpref+'anr').value = formatDate(danr);
      ibechdate(cpref+'anr');
    }
    anrabrgueltig = true;
  }
}
function ibechdate(valid){
  var val = document.getElementById(valid).value;
  var date = checkDate(val);
  if (date == null){
    try{
      dochdate(valid,false);
    }catch(e){}
  } else {
    document.getElementById(valid).value = formatDate(date);
    try{
      dochdate(valid,true);
    }catch(e){}
  }
  return date;
}

function ibechint(valid, min, max){
  if (!min) min = 0;
  var val = parseInt(document.getElementById(valid).value,10);
  if (!val) val = min;
  if (val < min) val = min;
  if (max) {
    if (val > max) val = max;
  }
  document.getElementById(valid).value = val;
  try{
    dochint(valid,true);
  }catch(e){}
  return val;
}
function toggleimg(openimgid, closeimgid, displayid, effect){
  try{
    var openimg = document.getElementById(openimgid);
    var closeimg = document.getElementById(closeimgid);
    var ele = document.getElementById(displayid);
    var fele = document.getElementById("f"+displayid);

    if (ele != null){
      if (ele.style.display == "none"){
        openimg.style.display="none";
        closeimg.style.display="";
        if (fele) fele.value="1";
        if (effect != null){
          if (effect==1){
            $("#"+displayid).slideDown("normal");
          } else if (effect==2){
            $("#"+displayid).fadeIn("normal");
          } else if (effect==3){
            $("#"+displayid).show("normal");
          } else {
            ele.style.display = "";
          }  
        } else {
          ele.style.display = "";
        }
      } else {
        closeimg.style.display="none";
        openimg.style.display="";
        if (fele) fele.value="0";
        if (effect != null){
          if (effect==1){
            $("#"+displayid).slideUp("normal");
          } else if (effect==2){
            $("#"+displayid).fadeOut("normal");
          } else if (effect==3){
            $("#"+displayid).hide("normal");
          } else {
            ele.style.display = "none";
          }  
        } else {
          ele.style.display = "none";
        }  
      }
      try{ user_ondisplaychanged(displayid); } catch(ee){}
    }
  }catch(e){}
}
function goAnwahl(){
  doibesubmit2("goAnwahl");
}
function neueSuche(){
  doibesubmit2("neueSuche");
}
function gopage(newpage){
  document.getElementById('actionvalue').value = newpage;
  document.getElementById("pager.offset").value = newpage;
  doibesubmit2("gopage");
}
function dosort(sortnumber){
  document.getElementById('actionvalue').value = sortnumber;
  doibesubmit2("dosort");
}
function goHLAllgemein(ibedetailid,hlid){
  var url = "/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=allgemein&controlid="+cControlID;
  goredirect(url);
}
function openHLAllgemein(ibedetailid,hlid,xwidth,xheight){
  var url = ibehost+"/publicsoft/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=allgemein&controlid="+cControlID;
  opencenterwindow(url, 'ibedetails', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function dokreiter(nummer){
  document.getElementById('ractive').value = nummer;
  doibesubmit('');
}
function goHLBilder(ibedetailid,hlid){
  var url = "/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=bilder&controlid="+cControlID;
  goredirect(url);
}
function openHLBilder(ibedetailid,hlid,xwidth,xheight){
  var url = ibehost+"/publicsoft/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=bilder&controlid="+cControlID;
  opencenterwindow(url, 'ibedetails', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function goULAllgemein(ibedetailid,hlid,ulid){
  var url = "/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ulid="+ulid+"&forceul=1&ractive=leistungen&controlid="+cControlID;
  goredirect(url);
}
function openULAllgemein(ibedetailid,hlid,ulid,xwidth,xheight){
  var url = ibehost+"/publicsoft/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ulid="+ulid+"&forceul=1&ractive=leistungen&controlid="+cControlID;
  opencenterwindow(url, 'ibedetails', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function goHLKarte(ibedetailid,hlid){
  var url = "/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=karte&controlid="+cControlID;
  goredirect(url);
}
function openHLKarte(ibedetailid,hlid,xwidth,xheight){
  var url = ibehost+"/publicsoft/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=karte&controlid="+cControlID;
  opencenterwindow(url, 'ibedetails', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function goHLAnfrage(ibedetailid,hlid){
  var url = "/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=anfrage&controlid="+cControlID;
  goredirect(url);
}
function openHLAnfrage(ibedetailid,hlid,xwidth,xheight){
  var url = ibehost+"/publicsoft/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=anfrage&controlid="+cControlID;
  opencenterwindow(url, 'ibedetails', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function goULListe(ibedetailid,hlid){
  var url = "/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=ulliste&controlid="+cControlID;
  goredirect(url);
}
function openULListe(ibedetailid,hlid,xwidth,xheight){
  var url = ibehost+"/publicsoft/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=ulliste&controlid="+cControlID;
  opencenterwindow(url, 'ibedetails', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function goHLPrint(ibedetailid,hlid){
  var url = "/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=print&controlid="+cControlID;
  goredirect(url);
}
function openHLPrint(ibedetailid,hlid,xwidth,xheight){
  var url = ibehost+"/publicsoft/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=print&controlid="+cControlID;
  opencenterwindow(url, 'ibedetailsprintview', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function openHLBelKal(ibedetailid,hlid,xwidth,xheight){
  var url = ibehost+"/publicsoft/public/ibe/details.jsp?ibedetailid="+ibedetailid+"&hlid="+hlid+"&ractive=belkal&controlid="+cControlID;
  opencenterwindow(url, 'ibedetailsbelkal', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function goOnlineBooking(ibedetailid,url){
  url = url + "&ibedetailid="+ibedetailid+"&controlid="+cControlID;
  window.location = url;
}
function openOnlineBooking(ibedetailid,url,xwidth,xheight){
  url = url + "&ibedetailid="+ibedetailid+"&controlid="+cControlID;
  opencenterwindow(url, 'onlinbooking', 'resizable=yes,scrollbars=yes', xwidth, xheight);
}
function goResultList(page){
  if (typeof page == 'undefined') page = 1;
  var chlid = "";
  try{ chlid = document.getElementById('hlid').value;}catch(e){}
  var url = "/public/ibe/listresult.jsp?ibedetailid="+ibedetailid+"&pager.offset="+page+"&controlid="+cControlID+"#"+chlid; 
  goredirect(url);
}
function getPager(copyToId){
try{
  document.getElementById(copyToId).innerHTML = document.getElementById('pager').innerHTML;
}catch(e){}
}
var imglist = new Array();
var imgcnt = 0;
function addshowimage(imgid){
  imglist[imgcnt] = imgid;
  imgcnt++;
}
function doshowimages(){
  for (nlv=0;nlv<imgcnt;nlv++){
    document.getElementById(imglist[nlv]).src = ibehost+'/publicsoft/binout?mumeobjid='+imglist[nlv];
  }
}
function ibepopup(text, caption){
try{
  if (typeof text=='undefined') return;
  if (text.length<=1) return;
  if (typeof caption=='string'){
    var cmd = "overlib('"+escSglQuote(text)+"',CAPTION,'"+escSglQuote(caption)+"',DELAY,300";
    for (nlv = 2; nlv < arguments.length; nlv++){
      cmd += ","+arguments[nlv];
    }
    cmd += ");"
    eval(cmd);
  } else {
    var cmd = "overlib('"+escSglQuote(text)+"',DELAY,300";
    for (nlv = 1; nlv < arguments.length; nlv++){
      cmd += ","+arguments[nlv];
    }
    cmd += ");"
    eval(cmd);
  }
}catch(e){}
}
function goredirect(path){
  $("form").prepend("<input type=\"hidden\" name=\"redirectdest\" value=\""+path+"\"/>");
  doibesubmit("goredirect");
}
