(function($) {
	jQuery.fn.tooltip = function(settings){
		var settings = jQuery.extend({
			content:'',
			url:'',
			onShow: null, //
			onHide: null,
			css:''
		},settings);

		return this.each(function(){
			var t=this;
			
			
			
			t.tooltip_content = t.title;
			t.title = '';
			
			
			jQuery(this).hover(function(){
				
				
				if(this.timer){
                        clearTimeout(this.timer);
                        this.timer = null
                }
                this.timer = setTimeout(function() {
                        Show(t);
                }, 200);
				
			}, function(){
				
				if(this.timer){
                        clearTimeout(this.timer);
                        this.timer = null
                }
                this.timer = setTimeout(function() {
                        Hide(t);
                }, 200);
				
			});


			Show = function(t){

				if (!t.tooltip && !jQuery(t).hasClass('jquery-tooltip')){
					var content=t.tooltip_content;
					
					var reg=/^http:/i;
					if (reg.test(content)){
						url=content;
						
						content="<iframe class='ui-layout-center jquery-tooltip-iframe' rameborder='0' vspace='0' hspace='0' marginwidth='0' marginheight='0' width='100%' height='100%' scrolling='no' style='background-color:white;border:medium none;color:white;height:300px;overflow:auto;width:500px;' src='"+url+"'>";							
					}
					

					t.tooltip = jQuery("<div class='jquery-tooltip' >"+content+"</div>")
					.hide();
					//.hover(Show, Hide);
					
					jQuery(t).append(t.tooltip);
				}


				
				
				
				var tooltip = t.tooltip;

				if (tooltip.onShow)	tooltip.onShow(tooltip);
				tooltip.css('display', '');
				
				return false;
			}
			
			Hide = function(t){

				var tooltip = t.tooltip;
				if (!tooltip) return false;
				//if (tooltip.onHide)	tooltip.onHide(tooltip);

				tooltip.clearQueue().fadeOut('fast');
			}


		});
	};
})(jQuery);
