$.fn.customTooltip = function(options)
{

        /* Setup the options for the tooltip that can be 
           accessed from outside the plugin              */
        var defaults = {
            speed: 200,
            delay: 300
        };

        var options = $.extend(defaults, options);

        /* Create a function that builds the tooltip 
           markup. Then, prepend the tooltip to the body */
        getTip = function() {
            var tTip = 
            "<div class='tip'>" +
                "<div class='tipMid'>"    +
                "</div>" +
                "<div class='tipBtm'></div>" +
            "</div>";
            return tTip;
        }
        $("body").prepend(getTip());

        /* Loops through each page element that is associated with the plugin (elements with the "tTip" class) and give each item the plugin the ability to call the tooltip    */
        $(this).each(function(){
            var $this = $(this);
            var tip = $('.tip');
            var tipInner = $('.tip .tipMid');
            
            var tTitle = (this.title);
            this.title = ""; /* so both versions of the title tag don't appear */
            
            var offset = $(this).offset();
            var tLeft = offset.left;
            var tTop = offset.top;
            var tWidth = $this.width();
            var tHeight = $this.height();
    
            /* Mouse over and out functions*/
            $this.hover(function() 
            {
            	var image1_offset = $(".jcarousel-item-1-horizontal").offset();
            	var diff = (image1_offset.left - initial_offset) * -1;
            	//display_pos = (((Math.round((image1_offset.left - 370) / 188)) + 0) * -1) - 1;
            	//alert(display_pos);
            	
            	 if(mouse_y < 170)
            	 {
            	 	 setTip(150, tLeft - diff);	 
					 }
					 else
					 {
					 	 setTip(90, tLeft - diff);	 
					 }
            	
                tipInner.html(tTitle);
                //setTip(tTop, tLeft);
               
                //setTip(80, tLeft); 
                setTimer();
            }, 
            function() {
                stopTimer();
                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(top, left){
            var topOffset = tip.height();
            var xTip = (left-30)+"px";
            var yTip = (top-topOffset-25)+"px";
            tip.css({'top' : yTip, 'left' : xTip});
        }
    
        /* This function stops the timer and creates the
           fade-in animation                          */
        showTip = function(){
            stopTimer();
            tip.animate({"top": "+=20px", "opacity": "toggle"}, defaults.speed);
        }
    });
};