is = new BrowserCheck();
/* checks browser version v1 */
function BrowserCheck() {
  var browser = navigator.appName
  if (browser=="Netscape") this.browser = "ns"
  else if (browser=="Microsoft Internet Explorer") this.browser = "ie"
  else this.browser = browser
  this.v = navigator.appVersion
  this.version = parseInt(this.v)
  this.ns = (this.browser=="ns" && this.version>=4)
  this.ns4 = (this.browser=="ns" && this.version==4)
  this.ns5 = (this.browser=="ns" && this.version==5)
  this.ie = (this.browser=="ie" && this.version>=4)
  this.ie4 = (this.v.indexOf('MSIE 4')>0)
  this.ie5 = (this.v.indexOf('MSIE 5')>0)
  this.mac = (this.v.indexOf("Mac")>0)
  this.oldWin = (this.v.indexOf("3.1")>0)
  this.min = (this.ns||this.ie)
}

function popup( url, width, height, mode, name, scroll ) {
  if (width == null) { width = 100; }
  if (height == null) { height = 100; }
  if (mode == null) { mode = 1; }
  if (name == null) {name = Math.ceil(Math.random());}
  if (mode == 1) {
    if (!scroll) { scroll = 'auto'; }
    splashWin = window.open(url, name, 'left='+((screen.width/2)-(width/2))+',top='+((screen.height/2)-(height/2))
      +', scrollbars=' + scroll + ', resizable=no, width='+width+', height='+height);
  } else {
    splashWin = window.open(url, name, 'fullscreen=1, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=no, resizable=0' );
    splashWin.resizeTo(width, height);
  }
  if (parseInt(navigator.appVersion) >= 4) {
    splashWin.moveTo((screen.width/2)-(width/2),(screen.height/2)-(height/2));
  }
  splashWin.focus();
}

function toggle(divID) {
  if (document.layers) { // NN4+
    if (document.layers[divID].visibility == 'visible') {
      document.layers[divID].visibility = "hide";
      document.layers[divID].display = "none";
    } else {
      document.layers[divID].visibility = "show";
      document.layers[divID].display = "inline";
    }
  } else if (document.getElementById) { // gecko(NN6) + IE 5+
    for (var i = 0; i < document.getElementsByTagName("div").length; i++) {
      oID = document.getElementsByTagName("div")[i].id;
      if (oID != divID) {
        var obj = document.getElementById(oID);
        if (obj.style.visibility == 'visible') {
          obj.style.visibility = "hidden";
          obj.style.display = "none";
        }
      } else {
        var obj = document.getElementById(divID);
        if (obj.style.visibility == 'visible') {
          obj.style.visibility = "hidden";
          obj.style.display = "none";
        } else {
          obj.style.visibility = "visible";
          obj.style.display = "inline";
        }
      }
    }
  } else if (document.all) { // IE 4
    if (document.all[divID].style.visibility == 'visible') {
      document.all[divID].style.visibility = "hidden";
      document.all[divID].style.display = "none";
    } else {
      document.all[divID].style.visibility = "visible";
      document.all[divID].style.display = "inline";
    }
  }
}

function dsplSM(msg) {
  self.status=msg;
  return true;
}

function closeProgress() {
  win = window.open('', 'win');
  if (win) {win.close();}
}

function zoom() {
  wx = document.image.width; wy = document.image.height;
  window.focus();
  window.moveTo((screen.width/2)-(wx/2),(screen.height/2)-(wy/2));
  if (is.ie) { Grow = window.setInterval("window_resizerIE(15,15)",1) }
  else if (is.ns)  { Grow = window.setInterval("window_resizerNS(20, 20)",1) }
}

function window_resizerIE(x,y) {
  if (document.body.clientWidth < wx) {
    if ((wx-document.body.clientWidth) > x) {window.resizeBy(x,0);}
    else {window.resizeBy((wx-document.body.clientWidth),0);}
  } else if (document.body.clientHeight < wy) {
    if ((wy-document.body.clientHeight) > y) {window.resizeBy(0,y);}
    else {window.resizeBy(0,(wy-document.body.clientHeight));}
  } else {window.clearInterval(Grow);}
}

function window_resizerNS(x, y) {
  var ww = window.innerWidth;
  if (ww > window.outerWidth && ww > wx) { ww = window.outerWidth; }
  var wh = window.innerHeight;
  if (ww < wx || wh < wy) {
    if ((wx-ww) > x) { window.resizeBy(x,0); }
    else { window.resizeBy((wx-ww),0); }
    if ((wy-wh) > y) {window.resizeBy(0,y);}
    else {window.resizeBy(0,(wy-wh));}
  } else { window.clearInterval(Grow); }
}

function highlightAll(fname) {
  var mf = document.forms[fname];
  var len = mf.elements.length;
  for (var i = 0; i < len; i++) {
    var e = mf.elements[i];
    if ((e.type == "checkbox") && (e.name != "switcher")) {
      if (e.checked != mf.switcher.checked){
        e.checked = mf.switcher.checked;
        highlight(e, fname);
      }
    }
  }
}

function highlight(e, fname){
  var tr = null;
  if (e.parentNode.parentNode){tr = e.parentNode.parentNode;}
  else if (e.parentElement.parentElement){tr = e.parentElement.parentElement;}
  if (tr){
    if(e.checked){document.forms[fname].num_sel.value++;}
    else {document.forms[fname].num_sel.value--;}
  }
}

function hov(which, cls) {
  which.className = cls;
}


function conf(txt, loc, fname) {
  if (fname == null) { fname = 'multi'; }
  if (confirm(txt)) {
    if (loc) {parent.location=loc;}
      else {document.forms[fname].submit();}
    } else {
      return false;
    }
}

function mnbr(act) {
  if (act != 'logout') { document.forms['menubar'].submit(); }
  else {
    if (log_out() == true) { document.forms['menubar'].submit(); }
    else { return false; }
  }
}

function log_out() {
  ht = document.getElementsByTagName("body");
  ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
  if (confirm('Möchten Sie sich wirklich abmelden?')) { return true; }
  else {
    ht[0].style.filter = "";
    return false;
  }
}
