﻿/*

TitleBox (#qTitleBox, .qTitleBox)
MsgBox (#qMsgBox, .qMsgBox, .qMsgBoxContent)
Icon (.qIconHolder, .qIcon)
HighlightRows (.qHighlightRows, .qNoHighlight)

*/

function myQuery()
{
    //  TitleBox  //
    $(".qTitleBox").mouseover(function(e)
    {
        if (!$("#qTitleBox").lenght)
        {
            $("body").append("<div id=\"qTitleBox\"><div class=\"left\"></div><div class=\"mid\"></div><div class=\"right\"></div></div>");
        }

        $("#qTitleBox .mid").html($(this).attr("title"));
        $(this).attr("title", "");

        var x = getCords(e, "x");
        var y = getCords(e, "y");

        $("#qTitleBox").css({ top: y - 40, left: x - $("#qTitleBox .mid").width() / 2 - 7 }).show();
    });
    $(".qTitleBox").mousemove(function(e)
    {
        var x = getCords(e, "x");
        var y = getCords(e, "y");
        $("#qTitleBox").css({ top: y - 40, left: x - $("#qTitleBox .mid").width() / 2 - 7 });
    });
    $(".qTitleBox").mouseout(function()
    {
        $("#qTitleBox").hide();
        $(this).attr("title", $("#qTitleBox .mid").html());
    });


    //  MsgBox  //
    $(".qMsgBox").mouseover(function(e)
    {
        if (!$("#qMsgBox").lenght)
        {
            $("body").append("<div id=\"qMsgBox\"><div class=\"left\"><div class=\"nw\"></div><div class=\"w\"></div><div class=\"sw\"></div></div><div class=\"mid\"></div><div class=\"right\"><div class=\"ne\"></div><div class=\"e\"></div><div class=\"se\"></div></div></div>");
        }

        var box = $("#qMsgBox");

        $("#qMsgBox .mid").html($(this).nextAll(".qMsgBoxContent").html());

        var x = getCords(e, "x");
        var y = getCords(e, "y");
        box.css({ top: y - 20, left: x + 15 });

        if ($("#qMsgBox .mid").height() > 24)
        {
            $("#qMsgBox .w, #qMsgBox .e").height($("#qMsgBox .mid").height() - 24);
        }

        box.show();
    });
    $(".qMsgBox").mousemove(function(e)
    {
        var x = getCords(e, "x");
        var y = getCords(e, "y");
        $("#qMsgBox").css({ top: y - 20, left: x + 15 });
    });
    $(".qMsgBox").mouseout(function()
    {
        $("#qMsgBox").hide();
        $("#qMsgBox .w, #qMsgBox .e").height(0);
    });
    
    
    //  Icon  //
    $(".qIconHolder").mouseover(function(e)
    {
        $(this).children(".qIcon").show();
    });
    $(".qIconHolder").mouseout(function(e)
    {
        $(this).children(".qIcon").hide();
    });
    
    
    //  HighlightRows  //
    $("table.qHighlightRows tr").each(function (i) {
        if (!$(this).hasClass("qNoHighlight"))
        {
            if((i/2).toString().match(".5") != null)
            {
                $(this).addClass("highlight");
            }
        }
    });
    
    
    
    function getCords(e, type)
    {
        var x = 0;
        var y = 0;
        
        if (document.all) //IE
        {
            x = e.clientX + document.documentElement.scrollLeft;
            y = e.clientY + document.documentElement.scrollTop;
        }
        else
        {
            x = e.pageX;
            y = e.pageY;
        }
        
        return type == "x" ? x : y;
    }
}