var body = null;
var tt_container = null;
var tt_last = null;
var tt_visible = false;
var tt_x = 0;
var tt_y = 0;

var tt_offset_x = 20;
var tt_offset_y = -50;

function updateWMTT(e){
    var scrTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
    var scrLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;

    tt_x = (document.all) ? window.event.x + scrLeft : e.pageX;
    tt_y = (document.all) ? window.event.y + scrTop : e.pageY;

    if (tt_container != null && tt_visible){
        tt_container.style.left = (tt_x + tt_offset_x) + "px";
        tt_container.style.top = (tt_y + tt_offset_y) + "px";
    }
}

function showWMTT(id){

    if (id != tt_last){
        body = document.getElementsByTagName('body')[0];

        if (body != null && tt_container != null){
            body.removeChild(tt_container);
        }

        var orig_node = document.getElementById(id);
        tt_container = orig_node.cloneNode(true);
        body.appendChild(tt_container);
        tt_last = id;

    }

    tt_visible = true;
    // 4 IE...
    tt_container.style.left = (tt_x + tt_offset_x) + "px";
    tt_container.style.top = (tt_y + tt_offset_y) + "px";
    tt_container.style.display = "block";
}

function hideWMTT() {
    tt_container.style.display = "none";
    tt_visible = false;
}
