﻿/* ================================================================ 
This copyright notice must be untouched at all times.
TopTip tooltips v1.0
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
/* <![CDATA[ */
$(document).ready(function () {

    offSetX = 3;
    offSetY = 3;

    $(".toptip").hover(function (e) {
        topTip = '#' + $(this).attr('class').split(' ').slice(-1);

        height = $(window).height();
        width = $(window).width();
        scrTop = $(window).scrollTop();
        scrLeft = $(window).scrollLeft();
        tipWidth = $(topTip).outerWidth();
        tipHeight = $(topTip).outerHeight();
        tipLeft = e.pageX + offSetX;
        tipTop = e.pageY + offSetY;

        if ((e.pageX - scrLeft + offSetX + tipWidth) > width) { tipLeft = e.pageX - offSetX - tipWidth; }
        if ((e.pageY - scrTop + offSetY + tipHeight) > height) { tipTop = e.pageY - offSetY - tipHeight; }

        if ($.browser.msie) {
            $(topTip)
			.css("top", tipTop + "px")
			.css("left", tipLeft + "px")
			.show();

        }
        else {
            $(topTip)
			.css("top", tipTop + "px")
			.css("left", tipLeft + "px")
			.stop(true, true)
			.fadeIn();

        }

    },
	function () {
	    $(topTip).hide();
	});

    $(".toptip").mousemove(function (e) {

        topTip = '#' + $(this).attr('class').split(' ').slice(-1);
        height = $(window).height();
        width = $(window).width();
        scrTop = $(window).scrollTop();
        scrLeft = $(window).scrollLeft();
        tipWidth = $(topTip).outerWidth();
        tipHeight = $(topTip).outerHeight();
        tipLeft = e.pageX + offSetX;
        tipTop = e.pageY + offSetY;

        if ((e.pageX - scrLeft + offSetX + tipWidth) > width) { tipLeft = e.pageX - offSetX - tipWidth; }
        if ((e.pageY - scrTop + offSetY + tipHeight) > height) { tipTop = e.pageY - offSetY - tipHeight; }

        $(topTip)
			.css("top", tipTop + "px")
			.css("left", tipLeft + "px");
    });


});

/* ]]> */


