this.acronym = function() {    
    this.xOffset = -10; // x distance from mouse
    this.yOffset = 20; // y distance from mouse       
    this.WindowWidth = $(window).width();
    
    $("acronym").unbind().hover(    
        function(e) {
            var trans = '';
            this.top = (e.pageY + yOffset); 
            this.left = (e.pageX + xOffset);
            this.PageX = e.pageX;
            this.MinWidth = 150;
            this.MaxWidth = 350;
            var obj = $(this);
            this.t = this.title;
            this.title = '';
            this.getTitle = function()
            {
                if (trans) return trans;
            }
            if(!$(this).hasClass("acronym")){
                $('body').append( '<span id="vtip"></span>' );
                $('#vtip').css("top", this.top+"px").css("left", this.left+"px").html('<img src="/images/themes/ajax-loader.gif" />').show();
                       
                $.ajax({  
			        type:'GET',
			        url: '/frontblocks/ajax/get_translation.aspx',
			        data: { mnemo: this.t },
			        async: false,
			        success: function(data){
			            trans = data;
			            
			            if (obj.hasClass("vhtml")) $('#vtip').html(data);
                        else $('#vtip').text(data);
                        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;
                        }
                        $(obj).addClass("acronym");
                        $('#vtip').css("top", this.top+"px").css("left", this.left+"px").css("width", VtipWidth+"px");
			        }  
			    });
            }
            else{
                trans = this.t;
                $('body').append( '<span id="vtip"></span>' );
                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");
            }
        },
        function() {
            this.title = this.getTitle();
            $("#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($){acronym();}) 