/*globals $,document,screen,jQuery*/

jQuery.fn.easytooltip = function(id, options)
    {
    var nav = navigator.userAgent;
    if(nav.match(/iPad/i) != null || nav.match(/iPhone/i) != null || nav.match(/iPod/i) != null || nav.indexOf('Android') != -1)
    {
    $("#" + id).hide();
        return;
        }
        else
        
        {
        
    var Config = {event:'mousemove'};
    if(options)
        {jQuery.extend(Config, options);}
    if(!document.getElementById('tool_tip'))
        {
       $("body").append('<div id="tool_tip_action_' + id + '">&nbsp;</div>');
       $("#tool_tip_action_" + id).css(
            {"position":"absolute","z-index":"1001","display":"none"});}

    function brwstester()
    {return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;}

    $("#" + id).hide();
        $(this).bind(Config.event, function(e)
            {
            var lfts = 0;
            var tps = 0;
            if(screen.width <= (e.pageX + 40 + $("#tool_tip_action_" + id).width()))
                { lfts = e.pageX - $("#tool_tip_action_" + id).width() - 20; }
            else
                { lfts = e.pageX + 20; }
            if(brwstester().scrollTop < e.pageY - 20 - $("#tool_tip_action_" + id).height())
                { tps =  (e.pageY - $("#tool_tip_action_" + id).height() - 20);}
            else
                { tps = e.pageY + 20; }

            $("#tool_tip_action_" + id).html($("#" + id).html()).css({"left": lfts, "top" : tps}).show();
        });


       $(this).bind("mouseout", function()
       { $("#tool_tip_action_" + id).hide().css({"left": 0, "top" : 0}); });
     }
    };
