﻿
    function onSilverlightError(sender, args) {
    }

    window.onload = function() {
        //$get(tooltipdiv).style.visibility = 'hidden';
    }


    function HideToolTip() {
        var control = $get(tooltipSL);
        if (control != null) {
            control.Content.SilverlightToolTip.Change("", "", "RB");
        }
        var ToolTip = $get(tooltipdiv);
        ToolTip.style.visibility = 'hidden';
    }

    var tooltipdiv = "divToolTip";
    var tooltipSL = "slToolTip";
    var toolTipheight = 100;

    function ShowToolTip(senderID, topOffset, leftOffset, title, content, loc) {
        try {

            var control = $get(tooltipSL);
            if (control == null)
                return;

            control.Content.SilverlightToolTip.Change(title, content, loc);

            control.Content.SilverlightToolTip.Resize();
            toolTipheight = control.height;
            var senderPos = GetTopLeft(document.getElementById(senderID));
            var ToolTip = $get(tooltipdiv);



            ToolTip.style.top = (senderPos.Top + topOffset - toolTipheight) + 'px';
            ToolTip.style.left = (senderPos.Left + leftOffset) + 'px';


            ToolTip.style.visibility = 'visible';
        }
        catch (e) { }
    }




    function GetTopLeft(elm) {

        var originElm = elm;
        var e = elm;
        var x, y, yy = 0;
        
        //set x to elm’s offsetLeft
        x = e.offsetLeft;

        //set y to elm’s offsetTop
        y = e.offsetTop;

        //set elm to its offsetParent
        e = e.offsetParent;

        //use while loop to check if elm is null
        // if not then add current elm’s offsetLeft to x
        //offsetTop to y and set elm to its offsetParent
        while (e != null && e.tagName.toUpperCase() != "HTML") {
            x = parseInt(x) + parseInt(e.offsetLeft);
            y = parseInt(y) + parseInt(e.offsetTop);

            e = e.offsetParent;
        }

        e = originElm.parentNode;
        while (e != null && e.tagName.toUpperCase() != "HTML") {
            if (e.tagName.toUpperCase() == "DIV")
                yy = yy + e.scrollTop;

            e = e.parentNode;
        }
        y = y - yy;
        
        return { Top: y, Left: x };
    }

               

               