﻿

$(function () {
    $('.alert-box').hide();
    $('.alert-box').fadeIn(1300); // .slideDown(200); // 

    $('.tip_trigger').each(function () {
        var tip = $(this).find('.tip');

        $(this).hover(
            function () { tip.appendTo('body'); },
            function () { tip.appendTo(this); }
        ).mousemove(function (e) {
            var x = e.pageX + 20,
                y = e.pageY + 20,
                w = tip.width(),
                h = tip.height(),
                dx = $(window).width() - (x + w),
                dy = $(window).height() - (y + h);

            if (dx < 20) x = e.pageX - w - 20;
            if (dy < 20) y = e.pageY - h - 20;

            tip.css({ left: x, top: y });
        });
    });
});
