﻿


function GetOffsetX() {

    if (document.SavedOffsetX && document.SavedOffsetX != 0)

        return document.SavedOffsetX;

    if (document.SavedOffset)

        return document.SavedOffset;

    return 160;

}

function GetOffsetY() {

    if (document.SavedOffsetY && document.SavedOffsetY != 0)

        return document.SavedOffsetY;

    if (document.SavedTopOffset)

        return document.SavedTopOffset;

    return 0

}

function GetWidth() {

    if (document.SavedWidth && document.SavedWidth > 0)

        return document.SavedWidth;

    return 250;

}

function SetTopOffset(n) {

    document.SavedTopOffset = n;

}

function GetTooltip() {

    if (!document.SavedTooltip)

        document.SavedTooltip = document.getElementById("titanTooltip");

    return document.SavedTooltip;

}

function SetParent(el) {

    document.SavedParent = el;

}

function GetParent() {

    return document.SavedParent;

}

function SetMessage(msg) {

    document.SavedMessage = msg;

}

function GetMessage() {

    return document.SavedMessage;

}

function SetImage(image) {

    document.SavedImage = image;

}

function GetImage() {

    return document.SavedImage;

}

function SetHref(href) {

    document.SavedHref = href;

}

function GetHref() {

    return document.SavedHref;

}

function SetUrl(url) {

    document.SavedUrl = url;

}

function GetUrl() {

    return document.SavedUrl;

}

function Show(child, message, offsetX, offsetY, width, image, href, url) {



//    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);

//        SetParent(child);

//    }

//    else {

        SetParent(child.parentNode);

//    }

    SetMessage(message);

    SetImage(image);

    SetHref(href);

    SetUrl(url);

    if (image) document.cursor = "default";

    if (offsetX) document.SavedOffsetX = offsetX;

    if (offsetY) document.SavedOffsetY = offsetY;

    if (width) document.SavedWidth = width;

    if (document.HideTimeout) clearTimeout(document.HideTimeout);

    document.ShowTimeout = setTimeout("ShowTooltip()", 300);

}

function Hide() {

    if (document.ShowTimeout) clearTimeout(document.ShowTimeout);

    document.HideTimeout = setTimeout("HideTooltip()", 100);

}

function CancelHide() {

    if (document.HideTimeout) clearTimeout(document.HideTimeout);

}

function ShowTooltip() {

    CancelHide();

    var tooltip = GetTooltip();

    var parent = GetParent();

    var message = GetMessage();

    var tipdescription = document.getElementById("tipdescription");

    var tipimage = document.getElementById("tipimage");

    if (tooltip && tooltip.firstChild && parent && message) {

        if (tipdescription) {

            var html = message;

            if (GetHref() && GetUrl()) {

                var html = "Visit <a href=\"" + GetHref() + "\" target=\"_blank\">" + GetUrl() + "</a>";

                var noticeEl = document.getElementById("tipnotice");

                if (noticeEl) noticeEl.innerHTML = message;

            }

            tipdescription.innerHTML = html;

        }

        else

        { tooltip.firstChild.innerHTML = message; }

        if (tipimage) {

            var imageSrc = GetImage();

            if (imageSrc) { tipimage.src = imageSrc; }

        }

        tooltip.style.display = "block";
     //  document.getElementById("xCoord").innerHTML = findPosX(parent) 
  //    document.getElementById("yCoord").innerHTML = findPosY(parent) 

      // document.getElementById("xCoord2").innerHTML =  GetOffsetX()
    //   document.getElementById("yCoord2").innerHTML = GetOffsetY()
       // tooltip.style.left = findPosX(parent) + GetOffsetX() + "px";
        tooltip.style.left = findPosX(parent)  + GetOffsetX()+ "px";
        tooltip.style.top = findPosY(parent)  + GetOffsetY()+ "px";
       // tooltip.style.top = 0
        // document.getElementById("xCoord").innerHTML = tooltip.style.left
        //document.getElementById("yCoord").innerHTML = tooltip.style.top
        //alert("Tooltip left = " + tooltip.style.left + ", Tooltip top = " + tooltip.style.top);

        var howWide = GetWidth();

        if (howWide > 0) {

            tooltip.style.width = howWide + "px";

        }

    }

}

function HideTooltip() {

    var tooltip = GetTooltip();

    if (tooltip) {

        tooltip.style.display = "none";

    }

}



function findPosX(obj) {

    var curleft = 0;

    if (obj.offsetParent)

        while (1) {

        curleft += obj.offsetLeft;

        if (!obj.offsetParent)

            break;

        obj = obj.offsetParent;

    }

    else if (obj.x)

        curleft += obj.x;

    return curleft;

}



function findPosY(obj) {

    var curtop = 0;

    if (obj.offsetParent)

        while (1) {

        curtop += obj.offsetTop;

        if (!obj.offsetParent)

            break;

        obj = obj.offsetParent;

    }

    else if (obj.y)

        curtop += obj.y;

    return curtop;

}



function SubmitOnEnter(buttonID) {

    if (buttonID && window.event.keyCode == 13) {

        var button = document.getElementById(buttonID);

        if (button) button.click();

    }

}



function Preload(src) {

    var image = new Image(); image.src = src;

}





// notify atlas script has loaded

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

