/**
Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/

this.vtip = function() {    
    this.xOffset = -10; // x distance from mouse
    this.yOffset = 20; // y distance from mouse       
    this.WindowWidth = $(window).width();
    $(".vtip").unbind().hover(    
        function(e) {
            this.t = this.title;
            this.title = '';
            this.top = (e.pageY + yOffset); 
            this.left = (e.pageX + xOffset);
            this.PageX = e.pageX;
            this.MinWidth = 150;
            this.MaxWidth = 350;
           
            //$('body').append( '<p id="vtip"><img id="vtipArrow" />' + this.t + '</p>' );
            $('body').append( '<span id="vtip"></span>' );

//            if(html) $('#vtip').html(this.t);
//            else $('#vtip').text(this.t);
            
            if ($(this).hasClass("vhtml")) $('#vtip').html(this.t);
            else $('#vtip').text(this.t);
            
            var VtipWidth = $("#vtip").width();
            
            if(this.PageX + VtipWidth > WindowWidth){
                if(VtipWidth > this.MaxWidth){
                    VtipWidth = this.MaxWidth;
                }
                if(VtipWidth < this.MinWidth){
                    VtipWidth = this.MinWidth;
                }
                this.left = this.left - VtipWidth;
            }
            
            $('#vtip').css("top", this.top+"px").css("left", this.left+"px").css("width", VtipWidth+"px").fadeIn("slow");
           
            //$('p#vtip #vtipArrow').attr("src", '/images/themes/vtip_arrow.gif');
            
        },
        function() {
            this.title = this.t;
            $("#vtip").fadeOut("slow").remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
            var VtipWidth = $("#vtip").width();
            if(this.PageX + VtipWidth > WindowWidth){
                this.left = this.left - VtipWidth;
            }
            
            $('#vtip').css("top", this.top+"px").css("left", this.left+"px");
        }
    );            
    
};

jQuery(document).ready(function($){vtip();}) 