var activePulldown = null;
var activeTimer = null;


/* Bilder vorladen */

function preloadImages() {
  if (!document.imageArray) document.imageArray = new Array();
  var args = preloadImages.arguments;
  var i, j;
  for (i=0, j=document.imageArray.length; i<args.length; i++, j++) {
    document.imageArray[j] = new Image;
    document.imageArray[j].src = args[i];
  }
}



/* Rollover-Buttons */

function imgOver(img) {
  img.oSrc = img.src;
  img.src = img.src.substr(0, img.src.length - 4) + "_over.gif";
}  

function imgOut(img) {
  img.src = img.oSrc;
  img.oSrc = null;
}  



/* Menü ein-/ausblenden */

function btnOver(img) {
  hidePulldown();
  imgOver(img);
  if (activePulldown = getElement(img.id.substr(0, img.id.length - 3))) {
    activePulldown.style.visibility = "visible";
  }
}

function btnOut(img) {
  if (activePulldown) {
    menuMouseOut(activePulldown);
  }
  imgOut(img);
}

function menuMouseMove(div) {
  if (activeTimer) {
    window.clearTimeout(activeTimer);
    activeTimer = null;
  }
}

function menuMouseOut(div) {
  activeTimer = window.setTimeout("hidePulldown()", 100);
}

function hidePulldown() {
  if (activeTimer) {    /* if called directly, reset timer */
    window.clearTimeout(activeTimer);
    activeTimer = null;
  }
  if (activePulldown) {
    if (theImg = getElement(activePulldown.id + "Img")) {
      if (theImg.oSrc) theImg.src = theImg.oSrc;
    }
    activePulldown.style.visibility = "hidden";
    activePulldown = null;
  }
}



/* Formularfelder fokussieren */

function doFocus(obj) {
  obj.style.backgroundColor = 'white';
  obj.style.borderColor = '#444444';
}

function doBlur(obj) {
  obj.style.backgroundColor = 'transparent';
  obj.style.borderColor = '#888888';
}



/* Hilfsfunktionen */

function getElement(id) {
  if (document.all) {     /* support for MSIE4 */
    return document.all(id);
  } else {
    return document.getElementById(id);
  }
}
