(function($){
	$.fn.bubbleup = function(options) {
		
		//Extend the default options of plugin
		var opts = $.extend({}, $.fn.bubbleup.defaults, options);
        var tip = null;

		var desc = null;

    	return this.each(function() {   
    	
    		//Set the option value passed here
            var $tooltip = opts.tooltips; 

			$('.div-pop').hide();
			

  			$(this).mouseover(
							  
  	  			function () {
            		
            		if($tooltip) {
            		
						var num = $(this).attr('title');
						
						tip = $('<div></div>');
						
                		tip.css({
							fontFamily: 'Helvetica, Arial, sans-serif',
                			color: '#cfcfcf', 
                			fontSize: 12, 
							position: 'absolute',
                			zIndex: 1,
							background: '#ffffff',
							height: '170px',
							width: '135px',
							padding: '2px'
						});
            			
            			tip.remove().css({
            				top: 0, left: 0, 
            				visibility: 'hidden', 
            				display: 'block'
						}).appendTo(document.body);
            
            			//Get the width and height of current image item
            			var position = $.extend({}, $(this).offset(), {
            				width: this.offsetWidth, 
            				height: this.offsetHeight
            			});
            			
            			
            			//Get the width and height of the tip element 
            			//var tipWidth = tip[0].offsetWidth, tipHeight = tip[0].offsetHeight;
            			
            			
            			//Set position for the tip to display correctly
    					//Postion: top and center of image     
						
						/*tip.stop().css({
            				top: position.top - tipHeight+145, 
            				left: position.left + position.width / 2 - tipWidth / 2, 
            				visibility: 'visible'
            			});
            			
						tip.animate({
        					top: "-=10"
						}, 'fast'); */
        			}     			
        			
					$("#pop"+num).css({'display':'block','z-index':50});
					
					$(this).stop();
					
					$(this).css({'z-index' : 100, 'top' : 0, 'left' : 0, 'width' : 103}).animate({
        				left: "-=8",
        				top: "-=12",
                		width: 125,
						height: 125
					}, 'fast' );
        		}

				
				
  			).mouseout(
  	  
    			
				function () {
  			
           			/*if($tooltip) {
                    	tip.remove();
                    }*/			
    				
					$(this).css({'z-index' : 10});
					var num = $(this).attr('title');
					$("#pop"+num).hide();
					
					$(this).stop();
        			$(this).animate({
        				left: 0,
        				top: 0,
                		width: 103,
						height: 103
        			}, 'fast', function() {
        					tip.css({zIndex: 1});
						}
        			);
    			}

  			);

    	});
    	
 	};
 	
 	$.fn.bubbleup.defaults = {
		tooltips: false
	}


})(jQuery);
