function createXMLHttpRequest() {
  if (window.ActiveXObject) {
    xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if (window.XMLHttpRequest) {
    xmlHTTP = new XMLHttpRequest();
  }
  return xmlHTTP;
}

var timeOut;

function displayDay(date)
{
  timeOut = window.setTimeout('goDay(' + date + ');', 500);
}

function goDay(date)
{
  var xmlHttp = createXMLHttpRequest();
  var e = 'a' + date;
  xmlHttp.open('GET', '/calendar.php?action=zobrazAkce&den=' + date + '', true);
  xmlHttp.onreadystatechange = function() {
    if (xmlHttp.readyState==4) {
      goReq(xmlHttp, e);
    }
  }
  xmlHttp.send(null);
}

var prevParent;

function goReq(xmlHttp, e)
{
  var text = xmlHttp.responseText;
  var div;
  if (document.getElementById('hint') == null) {
    div = document.createElement('div');
  } else {
    prevParent.removeChild(document.getElementById('hint'));
    div = document.createElement('div');
  }
  var elem = document.getElementById(e);
  div.innerHTML = text;
  div.id = 'hint';
  div.style.position = 'absolute';
  div.style.background = "white";
  elem.appendChild(div);
  prevParent = elem;
  //alert(document.getElementById('kalendar_stred').offsetLeft);
  div.style.display = "block";
  cl = document.getElementById('kalendar_stred');
  var oTop = 0;
  var oLeft = 0;
  var oHeight = 200;
  do {
    oTop += cl.offsetTop;
    oLeft += cl.offsetLeft;
  } while(cl = cl.offsetParent);
  var width = 320;
  var height = div.offsetHeight + 30;
  if (oHeight < height) {
    div.style.height = oHeight + 'px';
    div.style.overflow = 'auto';
    div.style.overflowX = 'hidden';
    div.style.overflowY = 'scroll';
  } else if (oHeight > height) {
    div.style.height = height + 'px';
    oHeight = height;
  }
  div.style.width = width + 'px';
  div.onmouseover = function () {
    window.clearTimeout(timeOut);
  }
  div.onmouseout = function () {
    timeOut = window.setTimeout('prevParent.removeChild(document.getElementById(\'hint\'))', 500);
  }
  div.style.left = (PopupTempX - width)-20 + 'px';
  div.style.top = (PopupTempY - oHeight)-20 + 'px';
  //alert(text);*/
}

function deleteTimeOut()
{
  window.clearTimeout(timeOut);
  if (document.getElementById('hint') != null) {
    timeOut = window.setTimeout('prevParent.removeChild(document.getElementById(\'hint\'))', 1000);
  }
}

/*var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var PopupTempX = 0
var PopupTempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    PopupTempX = event.clientX + document.documentElement.scrollLeft;
    PopupTempY = event.clientY + document.documentElement.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    PopupTempX = e.pageX;
    PopupTempY = e.pageY
  }
  // catch possible negative values in NS4
  if (PopupTempX < 0){PopupTempX = 0}
  if (PopupTempY < 0){PopupTempY = 0}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //alert(PopupTempX);
  //alert(PopupTempY);
  return true
}*/
