
var d = null;

function initWin() {
    d = document.createElement('div');
    d.style.display = 'none';
    document.body.appendChild(d);


    d.style.position = 'fixed';
    d.style.background = '#9ccc9c';
    d.style.border = '1px solid black';
    d.style.align = 'left';
    d.style.padding = '5px';
}

function setPos(e){
	var posx = 0;
    var posy = 0;
    if (!e) var e = window.event;
    if (e.clientX || e.clientY) {
        posx = e.clientX;
        posy = e.clientY;
    }
    posx += 10;
    posy -= 210;
    d.style.left = posx + "px";
    d.style.top = posy + "px";
}

function showRozhlInfo(event) {
    var e = this;
    var img = document.createElement('img');
    img.src = 'http://rozhledny.kohl.cz/fotoRozhl.php?id=' + this.name;
    img.style.height = '200px';
    d.appendChild(img);
    d.style.display = 'block';
    setPos(event);
}

function hideRozhlInfo() {
    d.style.display = 'none';
    while (d.hasChildNodes()) {
        d.removeChild(d.firstChild);
    }
}

function moveRozhlInfo(e) {
    //d.style.display = 'block';
    setPos(e);
}


initWin();

var el = document.getElementsByTagName('a');

for (var i = 0; i < el.length; i++) {
    if (el[i].className == 'rozhledna') {
        el[i].onmouseover = showRozhlInfo;
        el[i].onmouseout = hideRozhlInfo;
        el[i].onmousemove = moveRozhlInfo;
    }
}