function writeEmail(email,doLink) {
    var a = 'globalsmi';
    var b = 'leindex.';
    var c = 'com';
    if (doLink) {
        document.write('<a href="mailto:' + email + '@' + a + b + c + '">' + email + '@' + a + b + c + '</a>');
    } else {
        document.write(email + '@' + a + b + c);
    }
}
$("body *").rightMouseUp(function(e) {
    if (getSelectedText()) {
        document.location = 'contact.aspx?subj=translation&text=' + encodeURIComponent(getSelectedText()) + '&page=' + document.URL;
    }
});

function getSelectedText() {
    if (window.getSelection) {
        return window.getSelection().toString();
    }
    else if (document.getSelection) {
        return document.getSelection();
    }
    else if (document.selection) {
        return document.selection.createRange().text;
    }
}

function showTooltip(x,y,contents) {
    $('<div id="tooltip">' + contents + '</div>').css({
        position: 'absolute',
        display: 'none',
        top: y - 25,
        left: x + 5,
        border: '1px solid #fdd',
        padding: '2px',
        'background-color': '#fee',
        opacity: 0.80
    }).appendTo("body").fadeIn(200);
}

var previousPoint = null;

function buildChart() {
    $("#placeholder").bind("plothover",function(event,pos,item) {
        $("#x").text(pos.x.toFixed(2));
        $("#y").text(pos.y.toFixed(2));

        if (item) {
            if (previousPoint != item.datapoint) {
                previousPoint = item.datapoint;

                $("#tooltip").remove();
                var x = item.datapoint[0].toFixed(2),
                        y = item.datapoint[1].toFixed(2);

                showTooltip(item.pageX,item.pageY,y);
            }
        }
        else {
            $("#tooltip").remove();
            previousPoint = null;
        }
    });
}

