var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers
function isIE(){
  return ie4;
}
function disablebutton(thisname){
try{
  window.setTimeout("dodisablebutton('"+thisname+"')",1);
}catch(e){}
}
function dodisablebutton(thisname){
try{
  document.getElementById(thisname).disabled = true;
}catch(e){}
}
function opencenterwindow(url, name, params, width, height){
  var left = (screen.width-width)/2;
  var top = (screen.height-height)/2;
  if (top<0) top = 0;
  if (left<0) left = 0;
  params += ",HEIGHT="+height+",WIDTH="+width+",LEFT="+left+",TOP="+top;
  w1 = window.open(url, name, params);
  if (w1 == null) {
    alert("Das Fenster konnte nicht geöffnet werden! Bitte deaktivieren Sie ihre Popup-Blocker-Einstellung!");
  }
  if (w1 != null) {
    w1.focus();
  }
}
function ipopup(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 slideinwindow(url, name, params, width, height, intervall) {
  var left = (screen.width-width)/2;
  var top = (screen.height-height)/2;
  var startpos = 0;
  var lDoSlide = true;
  if (isNaN(intervall) == true) {
    intervall = 10;
  } else if (intervall <= 0) {
    startpos = left;
    lDoSlide = false;
  }
  params += ",HEIGHT="+height+",WIDTH="+width+",LEFT="+startpos+",TOP="+top;
  w1 = window.open(url, name, params);
  w1.focus();
  if (lDoSlide) {
    for (posleft = startpos; posleft <= left ; posleft = posleft + parseInt(intervall)) {
      w1.moveTo(posleft, top)
    }
  }
}
function openstd(url, wname) {
  if (!wname){
    wname = "std_open";
  }
  opencenterwindow(url,wname,"resizable=no,scrollbars=1",810,550);
}
function opensmall(url) {
  opencenterwindow(url,"std_open_small","resizable=no,scrollbars=1",380,250);
}
function openadressverknuepfung(p1,p2){
  opencenterwindow(p1,p2,"resizable=yes,scrollbars=yes","850","700");
}
function openstammdatenverknuepfung(p1,p2){
  opencenterwindow(p1,p2,"resizable=yes,scrollbars=yes","950","720");
}
function opendownload(p1,p2){
  opencenterwindow(p1,p2,"resizable=yes,scrollbars=yes","700","700");
}
function clearadresse(param1){
  document.getElementById(param1).value = '';
  dosubmit();
}
function showhelp(url){
  opencenterwindow(url,"help","resizable=yes,scrollbars=yes",800,600);
}
function opencalc(){
  opencenterwindow("/publicsoft/utils/calc.jsp","calc","resizable=yes,scrollbars=0",310,450);
}
function showbasket() {
  openstd("/publicsoft/utils/redirect.do?forward=basketlist", "basketlist");
}
function openbelkal(url){
  opencenterwindow(url,"belkal","resizable=yes,scrollbars=yes",650,550);
}
function opencolorpicker(){
  opencenterwindow("/publicsoft/utils/colorpicker.jsp","colpick","resizable=no,scrollbars=0",230,490);
}
function changeimage(img, url){
  img.src = url;
}
function ParentSiteLocation(NewURL) {
  if (parent != null){
    if (parent.topsite != null){showwait(parent.topsite.document);}
    parent.location = NewURL;
  }
}
function TopSiteLocation(NewURL) {
  if ((parent != null) && (parent.topsite != null)){
    showwait(parent.topsite.document);
    parent.topsite.location = NewURL;
  }
}
function BottomSiteLocation(NewURL) {
  if ((parent != null) && (parent.bottomsite != null)){
    showwait(parent.bottomsite.document);
    parent.bottomsite.location = NewURL;
  }
}
function RefreshTopSite() {
  parent.topsite.location.reload();
}
function RefreshBottomSite() {
  try{
  if (parent.bottomsite.document.forms[0]){
    parent.bottomsite.document.forms[0].submit();
  } else {
    parent.bottomsite.location.reload();
  }
  } catch (e){}
}
function ReloadBottomSite(url) {
  try{
    if ((parent != null) && (parent.bottomsite != null)) {
      if (parent.bottomsite.document.forms[0]){
        parent.bottomsite.document.location.href = url;
      } else {
        parent.bottomsite.location.href = url;
      }
    } else
      document.location.href = url;
  } catch (e){}
}
function dscbeleditload(vbmid){
  try{
    if ((parent != null) && (parent.topsite != null)) {
      if (parent.topsite.leftsite != null){
        try{
          parent.topsite.leftsite.showwait();
        } catch (ee){}
        parent.topsite.leftsite.location.href = '/publicsoft/dsc/belmeld/beleditssb.jsp?action=load&objectid='+vbmid;
      } else {
        try{
          parent.topsite.showwait();
        } catch (ee){}
        parent.topsite.location.href = '/publicsoft/templates/frames/dscbeleditframe.jsp?action=load&objectid='+vbmid;
      }
    }
  } catch (e){}
}
function parentgo(url){
  showwait(document);
  try{ parent.location.href=url;}
  catch(e){sorry();}
}
function parentorselfgo(url){
  showwait(document);
    if (parent.rechts){
      parent.rechts.location=url;
    } else {
      parent.location=url;
    }
}
function waitgo(url){
  showwait(document);
  try{ document.location.href=url;}
  catch(e){sorry();}
}
var context = "";
function setcontext(ctx){
  context = ctx;
}
function showprogresstimed(prgid){
try{
  window.setTimeout("showprogressdirect('"+prgid+"')",1500);
}catch(e){}
}
function showprogressdirect(prgid){
  opencenterwindow('/publicsoft/utils/redirect.do?forward=progress&idnr='+prgid,'progress',"resizable=no,scrollbars=yes","500","200");
}
function showprogress(prgid){
  opencenterwindow('/publicsoft/utils/redirect.do?forward=progress&idnr='+prgid+'&init=true','progress',"resizable=no,scrollbars=yes","500","200");
}

function getcontext(){
  return context;
}

function fmtPreis(cPreis){
  // erst in Zahl umwandeln
  var nWert = cPreis.replace(',',".") -0;
  // auf 2 Stellen runden und wieder Kommas setzen
  var cWert = nWert.toFixed(2).replace('.',",");
  return cWert;
}

var mess = new Array(2);
mess[0] = "Wirklich löschen?";
mess[1] = "Wirklich ausführen?";

function setMessage(nlv, me){
  mess[nlv] = me;
}

function dobsdel(action, messtext){
  var me = mess[0];
  if (messtext != null) me = messtext;
  if (!confirm(me)) return;
  if (!confirm("Sind Sie sicher???")) return;
  if (document.getElementById("action") != null) {
    document.getElementById("action").value = action;
  } else {
    alert("hidden field action nicht in Form");
  }
  dosubmit();
}

function dobs(action){
  if (action=="del") {
    dobsdel(action); return;
  }
  if (document.getElementById("action") != null) {
    document.getElementById("action").value = action;
  } else {
    alert("hidden field action nicht in Form");
  }
  dosubmit();
}

function doconfdbs(messnr, action){
  var me = mess[messnr];
  if (!confirm(me)) return;
  if (document.getElementById("action") != null) {
    document.getElementById("action").value = action;
  }
  dosubmit();
}

function doconfirmedbs(action){
  var me = mess[0];
  if (!confirm(me)) return;
  if (document.getElementById("action") != null) {
    document.getElementById("action").value = action;
  }
  dosubmit();
}

function doacknobs(action){
  var me = mess[1];
  if (!confirm(me)) return;
  if (document.getElementById("action") != null) {
    document.getElementById("action").value = action;
  }
  dosubmit();
}

function donavi(value){
  document.getElementById("activemode").value = value;
  dosubmit();
}

function resizelistframe(value){
  var f = parent.document.getElementById("fset");
  if (f!=null) f.rows=value;
}

function togglemenu(men){
  var ele = document.getElementById("t"+men);
  if (ele != null){
    var ele2 = document.getElementById("i"+men);
    if (ele.style.display == "none"){
      ele.style.display = "";
      if (ele2 != null) ele2.src = context+"/images/design/minus.gif";
    } else {
      ele.style.display = "none";
      if (ele2 != null) ele2.src = context+"/images/design/plus.gif";
    }
  }
}

function hidemenu(men){
  var ele = document.getElementById("t"+men);
  if (ele != null){
    var ele2 = document.getElementById("i"+men);
    ele.style.display = "none";
    if (ele2 != null) ele2.src = context+"/images/design/plus.gif";
  }
}

function showmenu(men){
  var ele = document.getElementById("t"+men);
  if (ele != null){
    var ele2 = document.getElementById("i"+men);
    ele.style.display = "";
    if (ele2 != null) ele2.src = context+"/images/design/minus.gif";
  }
}

var merkstyle;

function hl(entry) {
  dohl(entry, "dtrhl");
}

function nhl(entry) {
  dohl(entry, merkstyle);
}

function dohl(entry, mystyle) {
  var element = document.getElementById(entry);
  if (element != null){
    merkstyle = element.className;
    element.className = mystyle;
  }
  try{
    var element2 = document.getElementById(entry+'_2');
    if (element2 != null){
      element2.className = mystyle+'_2';
    }
  }catch(e){}
}

function showwait(p1){
  try{
    if (p1 == null) {p1 = document;}
    var md = p1.getElementById('masterdiv');
    if (md != null) md.style.position = "static";

    var tr = p1.getElementById('wctranse');
    if (tr != null) {
      tr.left = 0;
      tr.top = 0;
      tr.style.top = "0";
      tr.style.left = "0";
      tr.style.width = p1.body.clientWidth;
      tr.style.height = p1.body.clientHeight;
      tr.style.display = "";
    }
    
    var ele = p1.getElementById('wcwait');
    if (ele != null) {
      ele.style.width = p1.body.clientWidth;
      ele.style.height = p1.body.clientHeight;
      ele.style.display = "";
      ele.scrollIntoView();
    }
  } catch(e){}
}

function showwaitns(p1){
  try{
    if (p1 == null) {p1 = document;}
    var md = p1.getElementById('masterdiv');
    if (md != null) md.style.position = "static";
    var tr = p1.getElementById('wctranse');
    if (tr != null) {
      tr.left = 0;
      tr.top = 0;
      tr.style.top = "0";
      tr.style.left = "0";
      tr.style.width = p1.body.clientWidth;
      tr.style.height = p1.body.clientHeight;
      tr.style.display = "";
    }
    var ele = p1.getElementById('wcwait');
    if (ele != null) {
      ele.style.width = p1.body.clientWidth;
      ele.style.height = p1.body.clientHeight;
      ele.style.display = "";
    }
  } catch(e){}
}

function hidewait(p1){
  try{
    if (p1 == null) {p1 = document;}
    var md = p1.getElementById('masterdiv');
    if (md != null) md.style.position = "absolute";
    var tr = p1.getElementById('wctranse');
    if (tr != null) {
      tr.style.display = "none";
    }
    var ele = p1.getElementById('wcwait');
    if (ele != null) {
      ele.style.display = "none";
    }
  } catch(e){}
}

function dosubmit(p1){
  try{
    if (p1 == null) {p1 = document.forms[0];}
    showwait(document);
    try{ formsubmit(p1); }catch(e){};
    p1.submit();
  } catch(e){}
}

function dosortup(field){
  document.getElementById("list.sortfield").value = field;
  document.getElementById("list.sortorder").value = "true";
  dosubmit();
}
function dosortdown(field){
  document.getElementById("list.sortfield").value = field;
  document.getElementById("list.sortorder").value = "false";
  dosubmit();
}

function exportdata(nr){
  if (nr==null) {
    document.getElementById("df.export").value = "1";
    document.getElementById("showexport").style.visibility = "visible";
  } else {
    document.getElementById("df.export").value = nr;
  }
  dosubmit();
}

function dansicht(){
  document.getElementById("druckansicht").value = "1";
  dosubmit();
}

function clearfilter(){
  document.getElementById("df.recherche").value = "";
  if (document.getElementById("df.recherchefor") != null)
    document.getElementById("df.recherchefor").value = "";
  document.getElementById("df.clear").value = "true";
  doreiter('1');
}
function cleareigfilter(){
  document.getElementById("df.recherche").value = "";
  if (document.getElementById("df.recherchefor") != null)
    document.getElementById("df.recherchefor").value = "";
  document.getElementById("dfeig.clear").value = "true";
  doreiter('1');
}
function clearallfilter(){
  document.getElementById("df.recherche").value = "";
  if (document.getElementById("df.recherchefor") != null)
    document.getElementById("df.recherchefor").value = "";
  document.getElementById("df.clear").value = "true";
  document.getElementById("dfeig.clear").value = "true";
  doreiter('1');
}
function setfilter(){
  document.getElementById("df.recherche").value = "";
  if (document.getElementById("df.recherchefor") != null)
    document.getElementById("df.recherchefor").value = "";
  document.getElementById("pager.offset").value = "0";
  doreiter('1');
}

function setrecherche(){
  document.getElementById("df.recherche").value = "true";
  doreiter('1');
}
function clearrecherche(){
  document.getElementById("df.recherche").value = "";
  if (document.getElementById("df.recherchefor") != null)
    document.getElementById("df.recherchefor").value = "";
  doreiter('1');
}

function editfilter(){
  doreiter('2');
}

function doreiter(ap){
  document.getElementById("activepage").value = ap;
  dosubmit();
}

function dopager(offset, maxpage){
  document.getElementById("pager.offset").value = offset;
  document.getElementById("pager.maxPageItems").value = maxpage;
  dosubmit();
}

function openhtmleditor(elemname) {
  openstd("/publicsoft/utils/htmledit/htmledit.jsp?elemname="+elemname,"tedit");
}
function openhtmleditorForInnerHtml(elemname) {
  openstd("/publicsoft/utils/htmledit/htmledit.jsp?elemname="+elemname+"&mode=inner","tedit");
}
function mailto(id) {
  window.location.href = 'mailto:' + id;
}
function numformat(fid, len, filler){
  try{
    var ele = document.getElementById(fid);
    if (ele){
      var wert = ele.value;
      while (wert.charAt(0)==' '){
        wert = wert.substring(2,99);
      }
      for (var nlv=wert.length;nlv<len;nlv++){
        wert = filler+wert;
      }
      ele.value = wert;
    }
  }catch(e){}
}
function sorry(){
  alert('Diese Funktion steht derzeit noch nicht zur Verfügung!');
}
function bigtextarea(taid){
  document.getElementById(taid).rows=25;
  document.getElementById(taid).cols=150;
}
function smalltextarea(taid){
  document.getElementById(taid).rows=3;
  document.getElementById(taid).cols=60;
}
function smalltextarea2(taid){
  document.getElementById(taid).rows=6;
  document.getElementById(taid).cols=80;
}
function showpop(thisid, thisdate){
  overlib('<iframe src="/publicsoft/utils/redirect.do?forward=availkaldetail&mode=mini&svrid='+thisid+'&beldat='+thisdate+'" border="0" width="300px" height="200px" />',CAPTION,'Tagesdetails',LEFT,ABOVE,DELAY,400,STICKY,CLOSECLICK,HEIGHT,210,WIDTH,302);
}                   
var al_openurl = "";
var al_openurlpopup = "";
function al(thisurl){
  al_openurl = thisurl;
  nd();
  var cbild = '<img src="/publicsoft/images/prot/manuell.jpg" width="8px" border="0" />&nbsp;'
  var causwahl = '&nbsp;<a href="javascript:aldirect();">'+cbild+'in diesem Fenster öffnen</a><br>&nbsp;<a href="javascript:alpopup();">'+cbild+'in Popup-Fenster öffnen</a>';
  if (opener){
    if (opener.rechts){
      causwahl = causwahl + '<br>&nbsp;<a href="javascript:almain();">'+cbild+'in Hauptfenster öffnen</a>';
    }  
  }  
  overlib(causwahl,CAPTION,'Öffnen in ...',STICKY,NOCLOSE,DELAY,0);
} 
function al2(thisurl, urlpopup){
  al_openurl = thisurl;
  al_openurlpopup = urlpopup;
  nd();
  var cbild = '<img src="/publicsoft/images/prot/manuell.jpg" width="8px" border="0" />&nbsp;'
  var causwahl = "";
  if (opener) {
    causwahl = '&nbsp;<a href="javascript:alpopup2();">'+cbild+'in Popup-Fenster öffnen</a>';
  } else {  
    causwahl = '&nbsp;<a href="javascript:aldirect();">'+cbild+'in diesem Fenster öffnen</a><br>&nbsp;<a href="javascript:alpopup2();">'+cbild+'in Popup-Fenster öffnen</a>';
  }  
  if (opener){
    if (opener.rechts){
      causwahl = causwahl + '<br>&nbsp;<a href="javascript:almain();">'+cbild+'in Hauptfenster öffnen</a>';
    }  
  }  
  overlib(causwahl,CAPTION,'Öffnen in ...',STICKY,NOCLOSE,DELAY,0);
} 
function aldirect(){
  nd();
  location.href=al_openurl;
}
function alpopup(){
  nd();
  opencenterwindow(al_openurl,'al_popup',"resizable=no,scrollbars=1",910,650);
}
function alpopup2(){
  nd();
  opencenterwindow(al_openurlpopup,'al_popup',"resizable=no,scrollbars=1",910,650);
}
function almain(){
  nd();
  opener.rechts.location.href=al_openurl;
}
function domenu(cmd,target){
  if (target=='_blank') {
  } else {
    if ((target=='_parent') || (target=='_top') || (target=='top')){
      try{
        parent.showwait(parent.document);
      }catch(e){}
      parent.location=cmd;
    } else {
      try{
        parent.rechts.showwait(parent.rechts.document);
      }catch(e){}
      parent.rechts.location=cmd;
    }  
  }
}
function showdaycal(calid,start,ende,idvisible,idhidden){
  nlv = 0;
  var ele = document.getElementById(calid+idvisible);
  if (ele) ele.style.display='';
  ele = document.getElementById(calid+idhidden);
  if (ele) ele.style.display='none';
  while (nlv <= 23){
    ele = document.getElementById(calid+nlv);
    if (ele){
      if ((nlv>=start) && (nlv<ende)){
        ele.style.display='';
      } else {
        ele.style.display='none';
      }
    }
    nlv++;
  }
}
function mo(id){
  dscmeldopen(id);
}
function dscmeldopen(id){
  if ((id) && (id.length>=36)){
    var url = '/publicsoft/dsc/belmeld/beleditssb.jsp?action=load&extern=true&objectid='+id;
    openstd(url, 'belmeldshow');
  } else {
    alert('Buchungsvorgänge können nicht angezeigt werden. Es können nur Belegungsmeldung angezeigt werden. Diese erkennt man an dem Kürzel "VM" in der Spalte "Vorgangs-Nr."');
  }  
}
function dscanfrage(id){
  if ((id) && (id.length>=36)){
    var url = '/publicsoft/utils/redirect.do?forward=dscanfrage&action=load&objectid='+id;
    openstd(url, 'dscanfrage');
  }  
}
function UTF8Encode(inputString)                   
{                   
  var encodedInputString=escape(inputString);
  encodedInputString=encodedInputString.replace("+", "%2B");
  encodedInputString=encodedInputString.replace("/", "%2F");
  return encodedInputString;
}
function UTF8Decode(inputString)                   
{                   
  var encodedInputString=unescape(inputString);
  encodedInputString=encodedInputString.replace("%2B", "+");
  encodedInputString=encodedInputString.replace("%2F", "/");
  return encodedInputString;
}
function copyfromto(vonid, zuid){
  document.getElementById(zuid).value = document.getElementById(vonid).value; 
}
String.prototype.formatMoney = function(c, d, t){
    var n = this; n = n.replace(",","."); n = parseFloat(n);
	c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
var laktopenimg = false;
function doakt(x1, x2){
  if (laktopenimg==false) openstammdatenverknuepfung(x1,x2);
  laktopenimg = false;
}    
function loadvorgaenge(destid, vgparams){
  if (!$('#'+destid).attr('showed')){
    $('#'+destid).attr('showed','X');
    getPagewithparameters('/publicsoft/client/stammdaten/extra/gtbookingstatevglist.jsp', destid, 'get', vgparams);
  }
}    
function checkactioninput(){
  if ($('#action').val() && ($('#action').val()!='')){
    return true;
  } 
  return false;
}
function initinview(){
  $("[rel='inviewonce'][data]").live('inview', 
    function(event, visible, visiblePartX, visiblePartY){
      var $this = $(this);
      var data = $this.attr("data");
      $this.attr("data","");
      if (data && data.length>0){
        $this.html('<img height="8px" width="30px" src="/publicsoft/images/waitverlauf.gif" />');
        $this.load(data, {}, 
          function(response, status, xhr){
            if (status == "error") {  
              var msg = "Fehler beim Laden der Resource: ";  
              $this.html(msg + xhr.status + " " + xhr.statusText);
            }
          }          
        );
      };
    }
  );
}
 

