 /*-----------------------------------------------------------------------------
| Alle Urheber- und Leistungsschutzrechte vorbehalten.                         |
| (c)opyright 2004, Matthias König                                             |
| Email: matthias.koenig@impuls-mb.com                                         |
------------------------------------------------------------------------------*/

// Fehlerkontrolle
window.onerror = catchError;
function catchError(Nachricht,Datei,Zeile) {
}

// Aktuelles-PopUp öffnen
function openAktuell() {
  openPopUp("aktuell.html", "PU_Aktuell", 400, 500);
}

// Sitemap-PopUp öffnen
function openSitemap() {
  openPopUp("sitemap.html", "PU_Sitemap", 575, 520);
}

// PopUp zentriert öffnen
function openPopUp(wurl, wname, wwidth, wheight) {
  wwidth = wwidth + 25;
  var wleft = Math.ceil( (window.screen.width  - wwidth) / 2 );
  var wtop  = Math.ceil( (window.screen.height - wheight) / 2 * 0.8 );
  PopUp = window.open(wurl, wname, "width=" + wwidth + ",height=" + wheight + ",left=" + wleft + ",top=" + wtop + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1");
}

// Layer-Id bestimmen
function getLayerId(lid) {
  // DOM
  if (document.getElementById) {
    return document.getElementById(lid);
  }
  // IE
  if (document.all) {
    return document.all[lid];
  }
  // NC
  if (document.layers) {
    return document[lid];
  }
}

// Layer anzeigen
function showLayer(id) {
  if (document.getElementById || document.all) {
    id.style.visibility = "visible";
  } else {
    id.visibility = "show";
  }
}

// Layer verstecken
function hideLayer(id) {
  if (document.getElementById || document.all) {
    id.style.visibility = "hidden";
  } else {
    id.visibility = "hide";
  }
}

// Menü initialisieren (nur IE)
window.onload=startList;
function startList() {
  if (document.all && document.getElementById && document.getElementById("mnav")) {
    navRoot = document.getElementById("mnav");
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName == "LI") {
        node.onmouseover = function() {
          this.className += " over";
        }
        node.onmouseout = function() {
          this.className = this.className.replace(" over", "");
        }
      }
    }
  }
}

// Suche per Enter starten
function startSearch() {
  var text;
  text = document.searchform.search.value;
  if (text == "") {
    alert("Bitte geben Sie einen Suchbegriff ein.");
    return false;
  }
  if (text == "@intern") {
    document.searchform.search.value = "";
    document.searchform.search.blur();
    window.location.href = "http://www.impuls-mb.com/intern/index.html";
    return false;
  } else if (text == "@mail") {
    document.searchform.search.value = "";
    document.searchform.search.blur();
//  window.location.href = "mail.html";
    window.open("https://webmailer.1und1.de");
    return false;
  }
  text = text.replace(/ä/, "&auml;");
  text = text.replace(/ö/, "&ouml;");
  text = text.replace(/ü/, "&uuml;");
  text = text.replace(/Ä/, "&Auml;");
  text = text.replace(/Ö/, "&Ouml;");
  text = text.replace(/Ü/, "&Uuml;");
  text = text.replace(/ß/, "&szlig;");
  document.searchform.search.value = text;
  document.searchform.submit()
}

// Suche per Mouseclick starten
function clickSearch() {
  startSearch();
}

// Seite drucken
function printPage() {
  var url;
  url = "druck.pl?f=" + window.location.href;
  window.location.href = url;
}

// Funktionen für Klapptexte
function FindObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FindObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function PosSnap() {
  var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,args=PosSnap.arguments;a=parseInt(a);
  for (k=0; k<(args.length-3); k+=4)
   if ((g=FindObj(args[k]))!=null) {
    el=eval(FindObj(args[k+1]));
    a=parseInt(args[k+2]);b=parseInt(args[k+3]);
    x=0;y=0;ox=0;oy=0;p="";tx=1;da="document.all['"+args[k]+"']";
    if(document.getElementById) {
     d="document.getElementsByName('"+args[k]+"')[0]";
     if(!eval(d)) {d="document.getElementById('"+args[k]+"')";if(!eval(d)) {d=da;}}
    }else if(document.all) {d=da;}
    if (document.all || document.getElementById) {
     while (tx==1) {p+=".offsetParent";
      if(eval(d+p)) {x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
      }else{tx=0;}}
     ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);var tw=x+ox+y+oy;
     if(tw==0 || (navigator.appVersion.indexOf("MSIE 4")>-1 && navigator.appVersion.indexOf("Mac")>-1)) {
      ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);
      }else{var w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;
      a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
      x=document.body.scrollLeft + event.clientX + bx;
      y=document.body.scrollTop + event.clientY;}}
   }else if (document.layers) {x=g.x;y=g.y;var q0=document.layers,dd="";
    for(var s=0;s<q0.length;s++) {dd='document.'+q0[s].name;
     if(dd.substr(0,19) == "document.rollupmain") {
       if(eval(dd+'.document.'+args[k])) {x+=eval(dd+'.left');y+=eval(dd+'.top');break;}}}}
   if(el) {e=(document.layers)?el:el.style;
   var xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
   if(navigator.appName=="Netscape" && parseInt(navigator.appVersion)>4){xx+="px";yy+="px";}
   if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
    xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);
    xx+="px";yy+="px";}e.left=xx;e.top=yy;}}
}
function AutoLayers() {
 var g,b,k,f,args=AutoLayers.arguments;
 var a = parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc) {p7c=new Array();document.p7setc=true;
  for (var u=0;u<10;u++) {p7c[u] = new Array();}}
 for(k=0; k<p7c[a].length; k++) {
  if((g=FindObj(p7c[a][k]))!=null) {
   b=(document.layers)?g:g.style;b.visibility="hidden";}}
 for(k=1; k<args.length; k++) {
  if((g=FindObj(args[k])) != null) {
   b=(document.layers)?g:g.style;b.visibility="visible";f=false;
   for(j=0;j<p7c[a].length;j++) {
    if(args[k]==p7c[a][j]) {f=true;}}
  if(!f) {p7c[a][p7c[a].length++]=args[k];}}}
}

