
var info = {
  popup: null,
  timer: null,
  
  init: function() {
    this.popup = document.createElement('DIV');
    this.popup.style.display = "none";
    this.popup.className = "popup";
    this.popup.onmouseover = this.stay;
    this.popup.onmouseout  = this.mouseout;
    document.body.appendChild(this.popup);
  
    var p = document.getElementById('page');
    var img = p.getElementsByTagName('IMG');
    var obj = this;
    for (var i=0; i<img.length; i++) {
      if (hasclass(img[i], "info")) {
        var qmark = img[i];
        img[i].onmouseover = this.mouseover;
        img[i].onmouseout  = this.mouseout;
      }
    }    
  },
  
  mouseover: function(e) {
    var qmark = getTarget(e);
    var add_up = 0;
    if (qmark.className == "info up")
      add_up = -300;
    info.popup.style.display = 'none';
    info.popup.style.left = qmark.parentNode.offsetLeft + 20 + "px";
    info.popup.style.top  = qmark.parentNode.offsetTop + add_up + "px";
    ajax.updater(info.popup, qmark.getAttribute('url'));
    clearTimeout(info.timer);
  },
  
  mouseout: function(e) {
    ajax.stop();
    info.timer = setTimeout("info.popup.style.display = 'none'", 500);
  },
  
  stay: function(e) {
    clearTimeout(info.timer);
  }
  
};

var xmlhttp = null;

var ajax = {
  stopped: false,
  
  init: function() {
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
      xmlhttp = new XMLHttpRequest();
    }
  },

  updater: function(container, url) {
    this.stopped = false;
    xmlhttp.open("GET", url);  /* synchron */
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && !ajax.stopped) {
        container.innerHTML = xmlhttp.responseText;
        container.style.display = "block";
      }
    }
    xmlhttp.send(null);
  },
  
  stop: function() {
    this.stopped = true;
  }
  
};

function initpopups() {
  ajax.init();
  info.init();
}

