

var CSAg = window.navigator.userAgent;
var loaded=false;

// ------------------------------------------------

function isReallyNN() // js18.7.2002, hierherverlegt js7.8.2002
{  var d=document;
   var n=window.navigator;
   var ua=n.userAgent.toLowerCase();

   var nn =  !d.getElementById && !d.all &&
             window.top && d.layers && true;
   nn =nn && ua.substring(0,8)=='mozilla/' &&
             parseInt(ua.substring(8, ua.length )  ) < 5 &&
             n.appName.toLowerCase()=='netscape';
   nn =nn && ua.indexOf('spoofer')==-1 &&
             ua.indexOf('compatible')==-1 &&
             ua.indexOf('opera')==-1 &&
             ua.indexOf('gecko')==-1 &&
             ua.indexOf('webtv')==-1 &&
             ua.indexOf('hotjava')==-1;

  return nn;
};

function isIE()      // js7.8.2002
{ var d=document;
  var ua=window.navigator.userAgent;
  var ie=d.all && (ua.indexOf("MSIE") > 0);
  return ie;
}

function hasForms()  // js7.8.2002
{ var d=document;
  return d.forms.length;
}

// ------------------------------------------------

if(!window.saveInnerWidth)
{
  //window.onresize = ctlWidth; // statt resize;
  window.saveInnerWidth  = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}

/*** resize2reload ***/
function resize2reload()
{
  //if (window.saveInnerWidth  != window.innerWidth ||
  //    window.saveInnerHeight != window.innerHeight)
  //- geaendert,da das Problem auch auftritt wenn auf genau die
  //- alte Groesse geaedert wird!!!!
  if (window.saveInnerWidth && window.saveInnerHeight)
  { window.location.reload();
    //alert("should done!");
  }
  //alert("Peter unter N");
}


/*** layer2elem ***
js12.7.2002 ***/
function layer2elem(alayer)
{ var d=document;
  var e; // element

  if (d.getElementById)
    e=d.getElementById(alayer)
  else if (CSAg.indexOf("MSIE") > 0)
    e=d.all.tags('div')[alayer]
  else if (d.layers)
    e=d.layers[alayer]
  else
    e=d.getElementById(alayer)

  return e;
}


function hide(alayer)
{
  var e=layer2elem(alayer);

  if (!e) return; // der Layer wurde wahrscheinlich auskommentiert!!!

  if (e.style)  // IE, N6, ...
    e.style.visibility='hidden' /* enough even for IE6+7 bug */
  else if (e.visibility) // NN4x
    e.visibility='hide'
  // else: i dont know
}

/*** settop *** js8.4.2008 */
function settop(aelem,atop)
{
  if (typeof(atop)!='undefined')
  { if (aelem.style)
     { if (typeof aelem.style.top == 'number')
         aelem.style.top=atop
       else
       { aelem.style.top=atop+'px'; }
       // ^- korrekte Form
     }
     else if (aelem.top) { aelem.top=atop; }
  }

}

function show(alayer,atop)
{ /* IE is partly wrong by invisiblity, but opera
     but Opera (<8) does not support display change?! (forget NN4) */
  var e=layer2elem(alayer);

  if (!e) return; // der Layer wurde wahrscheinlich auskommentiert!!!
  settop(e,atop);

  if (e.style)  // IE, N6, ...
  { e.style.display='block'; /* '' doesnt work IE&Moz, but layer always block */
    e.style.visibility='visible';
  }
  else if (e.visibility) // NN4x
    e.visibility='show'
  // else: i dont know
  // alert('show: Elem='+e); // DEBUG
}



//------------------------------------------------------------------------

/*** ourActualWidth *** von setWidth() verwendet ***/
function ourActualWidth()
{ var d=document, w, k;
  if (window.innerWidth)
  { w=window.innerWidth; k=1;
    if (window.scrollbars && window.scrollbars.visible) { w-=16; k=2; }
  } //NN
  else if (d.width)       { w=d.width; k=3; }
  else if (d.offsetWidth) { w=d.offsetWidth; k=4; }
  else if (d.body && d.body.clientWidth) { w=d.body.clientWidth; k=5; }//IE
  else if (d.all)         { w=d.all.tags("body")[0].offsetWidth; k=6; }
  //alert("Width: "+w+" ("+k+")");
  return w;
}

function _setWidthTo(neww,oldw)
{ var err;
  try { window.resizeBy(neww-oldw,0); }
  catch (err)
  { try { window.innerWidth=neww; }
    catch (err)
    { try { document.body.offsetWidth=width=neww;
            document.width=neww;
          } catch (err)
            { /* forget IE7 if multiple Tabs, or
                 sillyness of IE after load. */
            }
    }
  }
}

var width_per_js=false;

/*** setWidth *** js15.8.2001, js19.6.2002 ***/
function setWidth(f)
{ var d=document,
      w=ourActualWidth(),
      s, x, err,
      minw=670, maxw=800;

  if (!width_per_js) return true; /* suppressed */

  if (screen.availWidth) s=screen.availWidth
  else s=screen.width-20;
  //alert("1.");
  if (window.screenX) x=window.screenX; // N6 & N4.7, IE?

  /* Breite veraendern */
  if (f=='fix' && s>maxw && w!=maxw) _setWidthTo(maxw,w)
  else if (s>minw && w<minw) _setWidthTo(minw,w)
  else if (w>maxw) _setWidthTo(maxw,w);

  /* Position falls bekannt, korrigieren */
  /* TODO: verschieben wenn n? */
  if (x+w>s) moveBy(s-x-w,0);


  // window.screenX/Y unter N6
  //alert("X:"+window.screenX+" "+d.screenX+" "+d.left+
  //      " "+window.left+d.body.left);
  loaded=true; /* setWidth wird aus onLoad aufgerufen, deshalb hier */
  return true;
}

function ctlWidth()
{ if (!width_per_js) return true; /* suppressed */

  setWidth();
  if (document.layers &&      // NN
      document.layer1 &&      // auf Peters Seiten
      window.saveInnerWidth)  // bereits definiert
    resize2reload();          // NN Problem Behebung
  return true;
}


//function ourSize()
//{ var d=document, dd,
//      w=Math.max(innerWidth, d.width);
//  if (d.body && d.body.clientWidth)
//      w=Math.max(d.body.clientWidth, w);
//  if (d.all) dd=d.all; else dd=d;
//  alert("Width: "+w);
//
//  if (w>805) return "800";
//  return "100%";
//}
//function width_ctl(o) // onResize="width_ctl(this)"
//{ var d=document, dd,
//      w=Math.max(innerWidth, d.width);
//  if (d.body && d.body.clientWidth)
//      w=Math.max(d.body.clientWidth, w);
//  if (d.all) dd=d.all; else dd=d;
//  alert("Width: "+w);
//
//  if (w>805)
//  { o.witdh=800;
//    if (o.style && o.style.width) o.style.width=800;
//  }
//}


/*function printPage_delayed()
{ var d=document;
  setTimer
}*/


/*** printPage_ ***
 ***/
function printPage_()
{ var d=document, unter;

  if (!loaded) { alert("zu frueh!"); }

  d.bgcolor="white";
  if (d.hellgelbeTabelle) unter=d.hellgelbeTabelle
  else if (d.M) unter=d.M
  else unter=d;
  with (unter)
  { if (bgcolor) bgcolor="white"
    else if (style) style.bgcolor="white";
  }

  if (!loaded) { alert("zu frueh!"); }

  self.focus();
  if (!loaded) { alert("zu frueh!"); }

  window.print(); // nur ab ns4 oder ie4n

  return false;
}

//function PrintSetup()
//{
//  var is = new Is();
//
//  self.focus()
//  //Druck
//  if (is.ns4 || is.ie4n) {
//     window.print()
//  }
//}

/*** saveWOData *** js27.11.2006 ***/
function saveDlg (ad, ignfile)
{ if (typeof ad == 'undefined' || !ad) ad=document;
  if (typeof ignfile == 'undefined')   ignfile=0;

  if (ignfile && ad.URL.indexOf('file:') >= 0) { return true; }
  /* ^- falls schon auf Platte dann nicht nochmal ... */

  if (typeof ad.saveAs == 'function')
    { ad.saveAs(); }
  else if (ad.execCommand)
    { ad.execCommand("SaveAs",false, ".htm"); } /* IE 4+ */
  else if (ad.doCommand)
    { ad.doCommand("SaveAs"); }
  else if (typeof ad.saveDialog == 'function')
    { ad.saveDialog(); }
  else if (typeof ad.dialogs == 'object')
    { ad.dialogs.saveAs(); }
    /* ^- und was auch immer man sonst noch versuchen muesste */
  else { return false; }    /* still ignorieren */
  return true;
}

//------------------------------------------------------------------------

/*** MimeTypeList *** js25.7.2002 ***/
function MimeTypeList_asString()
{ var str='', m=navigator.mimeTypes;

  for(var i=0,e; i < m.length; ++i)
  { e=m[i];
    str += e.type +'{';
    for (var j in e)
    { str += j + ': ' + e[j] + ' ';
    }
    str += '}';
    if (i<m.length-1) str += ', ';
  }

  return str;
}

function tryToFakeMimeTypeList()
{ // ...
}

//------------------------------------------------------------------------
loaded=true;

