// ACHTUNG!!!
// ATENTIONE!!!
// CAUTION!!!
// POZOR!!!
// DOCTYPE hlavvneho dokumentu musi byt takyto : 
// <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
// inak NEBUDE fungovat document.body.scrollTop !!!!

var fw_posx = 0;
var fw_posy = 0;

var fw_onlink = 0;
var fw_ondiv  = 0;
var fw_t;

var fw_content;
var fw_pWord = 0;
var fw_pLink = 1;
var fw_pBody = 2;

var fw_time_to_show=300;
var fw_time_to_hide=1300;
/*
function fw_replace(nr) {
	var fw_kw_re = '' + fw_data[nr][fw_pWord].replace(' ', '[\\s]+') + '';
	eval('var p=/([\\s,.>()]+)(' + fw_kw_re + ')([\\s,.<()]+)/i;');
	fw_content = fw_content.replace(p, '$1<a class="fw-link" href="'+ fw_data[nr][fw_pLink] +'" target="_blank" onmouseover="fw_onover('+ nr +');" onmouseout="fw_onout('+ nr +');">$2</a>$3');
}
*/

function fw_gener(nr) {
	var fw_word_count  = fw_data.length -1;
	fw_content = document.getElementById('fw_content').innerHTML;
	for (var i = 0; i <= fw_word_count; i++){
		fw_replace(i);
	}
  document.getElementById('fw_content').innerHTML = fw_content;
 // alert(fw_content);
}

function fw_onover(text, show, hide)
{
//	alert('over:'+ text);
	//show+"" ==="undefined"
	if (show === undefined)
	{
		show=300;
		hide=1300;
//		alert('show:'+ show + ", hide:"+hide);
	}
	fw_time_to_show=show;
	fw_time_to_hide=hide;

    clearTimeout(fw_t);
    fw_timedCount(1,text);
    fw_onlink = 1;

}
function fw_onout()
{
    clearTimeout(fw_t);
    fw_timedCount(-1);
    fw_onlink = 0;

}

function fw_pw() {
    if (window.innerWidth != null) return window.innerWidth;
    if (document.body.clientWidth != null) return document.body.clientWidth; 
    return (null);
}    

function fw_show_div(text) {

    el = document.getElementById('fw');
    if (el.style.visibility != 'hidden')
        el.style.visibility = 'hidden';

    el.innerHTML = text;

    var wp = fw_pw(); 

    st = el.style.visibility;
    tv = 0;
           
     if (el.offsetWidth) ew = el.offsetWidth; 
     else if (el.clip.width) ew = el.clip.width; 
     
     if (st != "visible" && st != "show") { 
     	//DOCTYPE 4.01 in IE6 requires document.documentElement.scrollTop ine document.body.scrollTop
        tv = fw_posy + 12 + document.documentElement.scrollTop;
        lv = fw_posx - (ew/4) + document.documentElement.scrollLeft;

//        tv = fw_posy + 12 + document.body.scrollTop;
//        lv = fw_posx - (ew/4) + document.body.scrollLeft;

        if (lv < 2) lv = 2; 
        else if (lv + ew > wp) lv -= ew/2;
            
        lv += 'px';
        tv += 'px';
            
        el.style.left = lv; 
        el.style.top = tv;
        el.style.visibility = "visible";
    }
    
}

function fw_hide_div() {
    if (fw_onlink == 0 && fw_ondiv == 0) 
        document.getElementById('fw').style.visibility = 'hidden';
}


function fw_timedCount(idd, text) {
    if (idd == -1){
        fw_t = setTimeout("fw_hide_div()", fw_time_to_hide);
    }
    else{
        fw_t = setTimeout("fw_show_div('"+text+"')", fw_time_to_show);
    }
}

function fw_getMousePos(e) {
    if (document.all) 
        e = event;
    fw_posx = e.clientX;
    fw_posy = e.clientY;
}

function fw_over_div(obj) {
    clearTimeout(fw_t);
    obj.className = 'fw-overtip';
    fw_ondiv = 1;
}

function out_div(obj) {
    fw_ondiv = 0;
    obj.className = 'fw-tip';
    fw_timedCount(-1);
}

document.onmousemove = fw_getMousePos;