/* Funktionen zur Anzeige des Kalenders in der mittl. Spalte */

////////// Realisierung des Pulldown-Menüs für die Monatsauswahl ///////

var justHiding = false;
var opacity = 90;

function showMonths() {
  el = document.getElementById('cal_months');
  el.style.display = "block";
  if (el.style.setAttribute) el.style.setAttribute("filter", "Alpha(opacity=90)", "false");
    el.style.opacity = 0.9;

  if (justHiding) {
    clearTimeout(justHiding);
    justHiding = false;
    el.style.display = "none";
    el.style.height = "auto";
  }

  // left, top, right, bottom des Elements bestimmen (von linker, oberer Ecke des Fenster)
  par_left = 0;
  par_top = 0;
  par = el;

  while (par) {
    par_left += par.offsetLeft;
    par_top += par.offsetTop;
    par = par.offsetParent;
  }
  cal_months_left = par_left -10;
  cal_months_top = par_top -10;
  cal_months_right = cal_months_left + el.offsetWidth+20;
  cal_months_bottom = cal_months_top + el.offsetHeight+20;
}

function hideMonths() {
  el = document.getElementById("cal_months");
  el.style.overflow = "hidden";
  //el.style.height = (el.offsetHeight - 10) + "px";
  opacity -= 10;
  if (el.style.setAttribute) el.style.setAttribute("filter", "Alpha(opacity="+opacity+")", "false");
    else el.style.opacity = opacity/100;

  //if (el.offsetHeight >= 10) {
  if (opacity>=10) {
    justHiding = setTimeout("hideMonths()",10);
  } else {
    justHiding = false;
    el.style.display = "none";
    el.style.height = "auto";
    opacity = 90;
  }
}

function mouseMoving(ev) {
  if (!justHiding && document.getElementById("cal_months").style.display == "block") {
    ev_x = document.all ? window.event.clientX : ev.pageX;
    ev_y = document.all ? window.event.clientY : ev.pageY;
    if (ev_x < cal_months_left || ev_x > cal_months_right || ev_y < cal_months_top || ev_y > cal_months_bottom) hideMonths();
  }
}

document.onmousemove = mouseMoving;

////////// Akualisierung der Uhrzeit (hh:mm) ////////////////////////

function showTime() {
  var now = new Date();
  now_hours = now.getHours();
  now_hours = (now_hours<10) ? "0"+now_hours : now_hours;
  now_min = now.getMinutes();
  now_min = (now_min<10) ? "0"+now_min : now_min;
  document.getElementById('cal_time').innerHTML =  now_hours + ":" + now_min;
}

window.setInterval("showTime()",1000);
