 $.fn.chiToolTip = function( options ){  
  
        /* Setup the options for the plugin */  
        var defaults = {  
            speed: 200,  
            delay: 300  
        };  
        var options = $.extend( defaults, options );  
  
        /* Builds the tooltip markup. Then, prepend the tooltip to the body */  
        getTip = function() {  
            var tTip =  
            '<div class="chiTip">' +  
                '<div class="tipTop"></div>' +  
                '<div class="tipMid">'    +  
                '</div>' +  
            '</div>';  
            return tTip;  
        }  
        $( 'body' ).prepend( getTip() );  
  
        /* Give each item with the class associated with 
           the plugin the ability to call the tooltip    */  
        $(this).each(function(){  
  
            var $this = $(this);  
            var tip = $('.chiTip');  
            var tipInner = $('.chiTip .tipMid');  
  
            var tTitle = ( this.title );  
            this.title = '';  
             
  
            /* Mouse over and out functions*/  
            $this.hover(function() {  
                var offset = $( this ).offset();  
                var tLeft = offset.left;  
                var tBottom = offset.top + 122;  
                var tWidth = $this.width();  
                var tHeight = $this.height();  
                tipInner.html( tTitle );  
                setTip( tBottom, tLeft );  
                tip.show();
            },  
            function() {  
                tip.hide();  
            }  
        );           
  
        /* Delay the fade-in animation of the tooltip */  
        setTimer = function() {  
            $this.showTipTimer = setInterval("showTip()", defaults.delay);  
        }  
  
        stopTimer = function() {  
            clearInterval($this.showTipTimer);  
        }  
  
        /* Position the tooltip relative to the class 
           associated with the tooltip                */  
        setTip = function(bottom, left){  
            var topOffset = tip.height();  
            var xTip = (left+10)+"px";  
            var yTip = (bottom-topOffset-10)+"px";  
            tip.css({'top' : yTip, 'left' : xTip});  
        }  
  
        /* This function stops the timer and creates the 
           fade-in animation                          */  
        showTip = function(){  
            stopTimer();  
            tip.animate({"top": "+=10px", "opacity": "toggle"}, defaults.speed);  
        }  
    });  
};  


