var displayed = false;
var stage = 0.0;
var stagestep = 0.1;
var finalheight = 0;
var startheight = 0;
var lastheight = 0;
var timestep = 20; 
var deploy;

// Funkce konstruktoru pro zjištění prohlížeče.
function zj_prohlizec(){
this.ver=navigator.appVersion;
this.dom=document.getElementById ? 1:0;

this.ns4 = (document.layers && !this.dom) ? 1:0;
this.ns6 = (this.dom && parseInt(this.ver) >= 5) ?1:0; 
this.minIE4 = (document.all) ? 1 : 0;
}
prohlizec =new zj_prohlizec() //Nový objekt pro zjištění prohlížeče

var mysX = 0;
var mysY = 0;

// Nastavení zachytávání pro Netscape a Mozillu.

if (prohlizec.ns4 | prohlizec.ns6)
    document.captureEvents(Event.MOUSEMOVE);

function ietruebody() 
{ 
  return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body; 
}

function myska(e) 
{ 
if (!e) {var e=window.event} 
if (e.pageX || e.pageY) {
    mysX=e.pageX;
    mysY=e.pageY;
} 
else if (e.clientX || e.clientY) {
        mysX=e.clientX + ietruebody().scrollLeft;
        mysY=e.clientY + ietruebody().scrollTop;
    }  
} 

document.onmousemove = myska; 


function showComment(text) {
    cb = document.getElementById("comment_box");
    if (!displayed) {
        stage = 0.0;
        startheight = parseInt(cb.style.height);
        if (isNaN(startheight) || (startheight == "auto")) {
            startheight = parseInt(lastheight); 
            cb.style.height = lastheight;
        }
        finalheight = Math.ceil(text.length/25) * 16;
        cb.innerHTML = text;
        cb.style.visibility = "visible";    
        cb.style.overflow = "hidden";
        displayed = true;
        
        clearTimeout(deploy);
        deploy = setTimeout("f_deploy()",timestep);
    } else {
          
        cb.style.left = (mysX - 100) + "px";
        cb.style.top = (mysY + 20) + "px";    
    }
}

function hideComment() {
    cb = document.getElementById("comment_box");
    startheight = parseInt(lastheight);
    finalheight = 0;
    stage = 0.0;
    displayed = false;
    clearTimeout(deploy);
    deploy = setTimeout("f_deploy()",timestep);
}

function f_deploy() {
    cb = document.getElementById("comment_box");
    cb.style.height = Math.round(startheight + (finalheight-startheight)*stage) + "px";
    lastheight = cb.style.height;
    if (stage < 1.0) {
        stage = stage + stagestep;
        deploy = setTimeout("f_deploy()",timestep) ;
    } else {
        clearTimeout(deploy);
        cb.style.overflow = "visible";
        if (parseInt(cb.style.height) >= 16) {
            cb.style.height = "auto";
        }
    }
    if (parseInt(cb.style.height) <= 8) {
        cb.style.visibility = "hidden";
    } else {
        cb.style.visibility = "visible";    
    }
    
}

