﻿//find the relative position of the element respect the ballon div parent
function findPosAbsolute(obj) {
    var yReturnValue = 0;
    var xReturnValue = 0;
    var ballon = document.getElementById('bubble_tooltip').parentNode;
    //alert(obj);
    while (obj != null && ballon != obj) {
        yReturnValue += obj.offsetTop;
        xReturnValue += obj.offsetLeft;
        obj = obj.offsetParent;
    }
    //alert(xReturnValue + '\n' + yReturnValue);
    return [xReturnValue, yReturnValue];
}


//displays the balloon tootip, with the specified text
function showToolTip(e, text, idToolTipped) {
    if (document.all) e = event;

    var topBubble = -75;
    var offsetRightBubble = 5;
//    if (navigator.userAgent.toLowerCase().indexOf('ie') >= 0) {
//        topBubble = -75;
//        offsetRightBubble = 5;
//    }
    var obj = document.getElementById('bubble_tooltip');
    var obj2 = document.getElementById('bubble_tooltip_content');
    var toolTipped = document.getElementById(idToolTipped);
    obj2.innerHTML = text;
    obj.style.display = 'block';

    var coord = findPosAbsolute(toolTipped);
    obj.style.left = toolTipped.offsetWidth + coord[0] + offsetRightBubble + 'px';
    obj.style.top = coord[1] + topBubble + 'px';
    
}


//hide the balloon
function hideToolTip() {
    document.getElementById('bubble_tooltip').style.display = 'none';

}

function showToolTipCitySug(e, text, idToolTipped) {
    if (document.all) e = event;

    var topBubble = -80;
    var offsetRightBubble = -265;
    if (navigator.userAgent.toLowerCase().indexOf('ie') >= 0) {
        
        offsetRightBubble = -250;
    }
    var obj = document.getElementById('bubble_tooltip_citySug');
    var obj2 = document.getElementById('bubble_tooltip_content_citySug');
    var toolTipped = document.getElementById(idToolTipped);
    obj2.innerHTML = text;
    obj.style.display = 'block';

    var coord = findPosAbsolute(toolTipped);
    obj.style.left = toolTipped.offsetWidth + coord[0] + offsetRightBubble + 'px';
    obj.style.top = coord[1] + topBubble + 'px';

}


//hide the balloon
function hideToolTipCitySug() {
    document.getElementById('bubble_tooltip_citySug').style.display = 'none';

}
