preload = new Array();

function initialize() {
  var ul = desc(document.getElementById("hauptnav"))[0];
  var lis = desc(ul);
  for(var i=0; i<lis.length; i++) {
    var li = lis[i];
  		var img = desc(desc(lis[i])[0])[0];
		  addListener(li, "mouseover", show);
  		addListener(li, "mouseout", hide);
		  try {
   			var p1 = new Image();
			   p1.src = loSrc(img);
   			preload[preload.length] = p1;
   			var hi = hiSrc(img);
			   if(hi) {
   				 var p2 = new Image();
			   	 p2.src = hiSrc(img);
				    preload[preload.length] = p2;
		  	 }
			   var menuUl = desc(lis[i])[1];
      menuUl.style.left = ""+(lis[i].offsetLeft + 0)+"px";
		  }
		  catch(er) {
			   continue;
		  }
  }
}

function show(e) {
  var to = window.event ? this : e.currentTarget;
  var from = window.event ? window.event.fromElement : e.relatedTarget;
  if(to!=from && !doesContain(to, from)) {
    var img = desc(desc(to)[0])[0];
    hilite(img, 1);
		  try {
			    var ul = desc(to)[1];
			    ul.style.visibility = "visible";
		  }
		  catch(er) {}
  }
}

function hide(e) {
  var to = window.event ? window.event.toElement : e.relatedTarget;
  var from = window.event ? this : e.currentTarget;
  if(to==null || (to!=from && !doesContain(from, to)) ) {
    var img = desc(desc(from)[0])[0];
		  hilite(img, 0);
		  try {
			   var ul = desc(from)[1];
			   ul.style.visibility = "hidden";
		  }
		  catch(er) {}
  }
}

function tName(n) {
  return n.nodeName ? n.nodeName : n.tagName;
}

function desc(n) {
  if(n.childNodes) {
    var ns = n.childNodes;
    var r = new Array();
    for(var i=0; i<ns.length; i++) {
      if(ns[i].nodeName!="#text")
         r[r.length]=ns[i];
      }
      return r;
  }
  else
    return n.children;
}

function addListener(node, eventName, listener) {
  if(document.addEventListener)
    node.addEventListener(eventName, listener, true);
  else
    node["on"+eventName] = listener;
}

function doesContain(a, b) {
	 if(!a || !b) {
		  return false;
  }
  while (b.parentNode) {
    if((b = b.parentNode) == a) {
      return true;
				}
  }
  return false;
}

function saveLoSrc(img) {
  if(!img.loSrc) {
    img.loSrc = img.src;
  }
  if(!savedLoSrc[img.hiSrc]) {
    savedLoSrc[img.hiSrc] = img.src;
  }
}

function hilite(img, show) {
  if(hiSrc(img)) {
		  img.src = show==1? hiSrc(img) : loSrc(img);
		}
}

function hiSrc(img) {
  saveLoSrc(img);
		return img.getAttribute("hiSrc");
}

function loSrc(img) {
  saveLoSrc(img);
		return img.loSrc ? img.loSrc : savedLoSrc[img.hiSrc];
}

savedLoSrc = new Array();

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
		}
  if(!x && d.getElementById) {
		  x=d.getElementById(n);
				return x;
		}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) {
		  if ((obj=MM_findObj(args[i]))!=null) {
				  v=args[i+2];
      if (obj.style) {
						  obj=obj.style;
								v=(v=='show')?'visible':(v=='hide')?'hidden':v;
						}
      obj.visibility=v;
				}
		}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function hasClass(obj) {
  var result = false;
  if (obj.getAttributeNode("class") != null) {
    result = obj.getAttributeNode("class").value;
  }
  return result;
}
  
function stripe(id, skip) {
  var even = false;
  var table = document.getElementById(id);
  if (! table) {
    return;
    var trs = table.getElementsByTagName("tr");
    for (var i = 0; i < trs.length; i++) {
    	 if(!hasClass(trs[i])) {
      		trs[i].className = even ? "even" : "odd";
    		  i+=skip;
    		  even = !even;
    	 }
	   }
	 }
}

function surfto(querynav) {
  var myindex=querynav.ergebnisauswahl.selectedIndex
  if (querynav.ergebnisauswahl.options[myindex].value != "0") {
    location=querynav.ergebnisauswahl.options[myindex].value;
  }
}

function openWindow_bw(name) {
  window.open(name, 'popup' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=580,height=520');
}

function openWindow_struktur(name) {
  window.open(name, 'popup' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=620,height=370');
}

function openWindow_map(name) {
  window.open(name, 'popup' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=620,height=340');
}

function openWindow_kalender(name) {
  window.open(name, 'popup' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=485,height=649');
}

function openWindow_job(name) {
  window.open(name, 'popup' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=610,height=580');
}

function openWindow_product(name) {
  window.open(name, 'popup' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=700');
}

function centerPopUp( url, name, width, height, scrollbars ) {
  if( scrollbars == null ) { scrollbars = "0" }
  str  = "";
  str += "resizable=1,";
  str += "scrollbars=" + scrollbars + ",";
  str += "width=" + width + ",";
  str += "height=" + height + ",";
  if ( window.screen ) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    var xc = ( aw - width ) / 2;
    var yc = ( ah - height ) / 2;
    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  window.open( url, name, str );
}