// (c) Daniel Rudigier, medienhaus.com

  var allowredirect = true;
  
  // special browser detection
  var browser = navigator.appName.toLowerCase();
  if (browser.indexOf(" ") != -1)
    browser = browser.substring(0,browser.indexOf(" "));
    
  var dispmode;
  var dispmode1;
  
  if (browser == "microsoft") // IE
  {
    dispmode = "inline";
    dispmode1 = "block";
  }
  else
  {
    dispmode = "table-row";
    dispmode1 = "table";
  }
  
  function noredirect()
  {
    allowredirect = false;
  }
  
  function redirect(page)
  {
    if (allowredirect)
      document.location.href=page;
    else
      allowredirect = true;
  }
  
  function goCommit(action)
  {
    var mainForm = document.getElementById('mainForm');
    
    if (mainForm.commit)
      mainForm.commit.value = action;
    mainForm.submit();
  }

  
  /* rollover & klick */
  
  function rollover(el)
  {
    if (el.className == "tdline1")
      el.className = "tdline1hover";
    if (el.className == "tdline2")
      el.className = "tdline2hover";
    if (el.className == "tdactive")
      el.className = "tdactivehover";
  }
  
  function rollout(el)
  {
    if (el.className == "tdline1hover")
      el.className = "tdline1";
    if (el.className == "tdline2hover")
      el.className = "tdline2";
    if (el.className == "tdactivehover")
      el.className = "tdactive";
  }
  
  function areaover(el)
  {
    el.className = 'areaover';
  }
  function areaout(el)
  {
    el.className = 'areaout';
  }
  
  function setFocus()
  {
  	mainForm = document.getElementById('mainForm');
    if (mainForm)
      mainForm.focus();
  }
  
  
  function reloadparent(theform,closeme)
  {
    if (window.opener && !window.opener.closed)
    {
      parentForm = window.opener.document.getElementById(theform);
      parentForm.submit();
      if (closeme)
        window.close();
    }
  }
  
  function idpopup(id,extra,root)
  {
    if (!root)
      root = "";
    if (extra)
      idwindow = open_window(root+'big.php?id='+id+extra,'big',20,20);
    else
      idwindow = open_window(root+'big.php?id='+id,'big',20,20);
  }
  
  function resize()
  {
    var sx = document.images[0].width + 40;
    var sy = document.images[0].height + 80;
    
    window.moveTo((screen.width - sx )/ 2,0);
    
    window.resizeTo(sx,sy);    
  }
  
  function printit()
  {
    window.print();
  }

  function open_window(target,name,width,height,posx,posy,windowoptions,init_target)
  {
    var it, wo, px, py, new_window;

    it = target;
    wo = "location=no,toolbar=no,status=no,statusbar=no,scrollbars=no,resizable=no,dependent=yes";
    
    w = width;
    h = height;
    px = (screen.width - w )/ 2;
    py = 0;//(screen.height - h )/ 2;

    if (typeof posx != "undefined") px = posx;
    if (typeof posy != "undefined") py = posy;
    if ((typeof windowoptions != "undefined") && (windowoptions != "")) wo = windowoptions;
    if (typeof init_target != "undefined") it = init_target;

    if (new_window)
      new_window.close();
    
    //alert(windowoptions);
    if (new_window = window.open(it,name,"width=" + width + ",height=" + height + "," + wo))
    {
      new_window.moveTo(px,py);
      new_window.location.replace(target);
      new_window.focus();
    }
    return new_window;
  }
  
  function increase(id,id_sum)
  {
    var el = document.getElementById(id);
    var sum = document.getElementById(id_sum);
    
    if (el)
    {
      el.value++;    
      if (sum)
        sum.innerHTML++;
    }
  }
  function decrease(id,id_sum)
  {
    var el = document.getElementById(id);
    var sum = document.getElementById(id_sum);
    
    if (el && el.value > 0)
    {
      el.value--;
      if (sum)
        sum.innerHTML--;
    }
  }
  
  function resetform()
  {
    var mainForm = document.getElementById('mainForm');
    mainForm.reset();
  }
  
  function idswitch(id, what)
  {
    var el = document.getElementById(id);
    if (el)
    {
      if (what)
      {
        if (browser == "microsoft")
          el.style.display = 'inline';
        else
          el.style.display = 'table-row';
      }
      else
        el.style.display = 'none';
    }
  }
  
  function visi(nr)
  {
  	if (document.layers)
  	{
  		vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'hide'
  		document.layers[nr].visibility = vista;
      document.forms[1].visible.value=vista;
  	}
  	else if (document.all)
  	{
  		vista = (document.all[nr].style.visibility == 'hidden') ? 'visible'	: 'hidden';
  		document.all[nr].style.visibility = vista;
      document.forms[1].visible.value=vista;
  	}
  	else if (document.getElementById)
  	{
  		vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'hidden';
  		document.getElementById(nr).style.visibility = vista;
      document.forms[1].visible.value=vista;
  	}
    return false;
  }
  
  var alt;  
  function updateBlocks(id, prefix, stay)
  {
    if (!prefix)
      prefix = 'block';
    block = prefix + '_' + id;
    //alert(block);
    el = document.getElementById(block);
    
    if (!stay && alt)
      alt.style.display = "none";
    else
      if (alt && alt.name != stay)
        alt.style.display = "none";
    
    if (el)
    {
      el.style.display = dispmode;
      alt = el;
    }
  }
  
  var alt2;  
  function updateBlocks2(id, prefix, stay)
  {    
    if (!prefix)
      prefix = 'block';
    block = prefix + '_' + id;
    //alert(block);
    el = document.getElementById(block);
    
    if (!stay && alt2)
      alt2.style.display = "none";
    else
      if (alt2 && alt2.name != stay)
        alt2.style.display = "none";
    
    if (el)
    {
      el.style.display = dispmode;
      alt2 = el;
    }
  }
  
  function updateChild(node,id,child)
  {
    if (node && id)
    {
      subid = node + '_' + id;
      if (subselect = document.getElementById(subid) )
        updateBlocks2(subselect.value, child, subid);
    }
  }