/*!
 * 气泡提示插件：修改完善，支持title提示
 * www.JSPGen.com
 * @revise 1.0
 */
;(function($){$.fn.bubbleTips=function(options){var settings={id:parseInt(Math.random()*100000),position:"t",value:15,content:"",isClose:true};$.extend(settings,options);var cont='<i class="triangle-'+settings.position+'"></i>'+(settings.isClose?'<i class="close" title="关闭">关闭</i>':'')+'<div class="tl"><div class="inner"><div class="cont">'+settings.content+'</div></div></div><div class="tr"></div><div class="bl"></div>';var offset=$(this).offset();if($("#btips"+settings.id).length){$("#btips"+settings.id).html(cont);$("#btips"+settings.id).show();}else{$("body").prepend('<div class="bubble-tips" id="btips'+settings.id+'">'+cont+'</div>');}
var $btips=$("#btips"+settings.id);var $btipsClose=$btips.find(".close");var h=$(this).height();var w=$(this).width();switch(settings.position){case"t":$(".triangle-t").css('left',settings.value);$btips.css({"left":offset.left+w/2-settings.value,"top":offset.top+h+14});break;case"b":$(".triangle-b").css('left',settings.value);$btips.css({"left":offset.left+w/2-settings.value,"top":offset.top-h-7-$btips.height()});break;case"l":$(".triangle-l").css('top',settings.value);$btips.css({"left":offset.left+w+10,"top":offset.top+h/2-7-settings.value});break;case"r":$(".triangle-r").css('top',settings.value);$btips.css({"left":offset.left-w+25-$btips.width(),"top":offset.top+h/2-7-settings.value});break;}
$btipsClose.delegate(this,"click",function(e){$btips.hide();});}
$.fn.titleTips=function(options){this.each(function(){var $this=$(this);if($this.attr("title")!=undefined){title=$this.attr("title");$this.removeAttr("title");}else if($this.attr("alt")!=undefined){title=$this.attr("alt");$this.removeAttr("alt");}
if(title!=null&&title!='')$this.attr("tips",title);});var tips,id=parseInt(Math.random()*100000);this.each(function(){var $this=$(this);$this.hover(function(e){tips='';if($this.attr("tips")!=undefined)tips=$this.attr("tips");if(tips!=null&&tips!=''){var left=$this.offset().left+50;if(left<document.body.clientWidth){$this.bubbleTips({id:id,position:"l",value:10,content:tips,isClose:false});}else{$this.bubbleTips({id:id,position:"r",value:10,content:tips,isClose:false});}}},function(){if(tips!=null&&tips!=''){$("#btips"+id).hover(function(e){$("#btips"+id).show();},function(){$("#btips"+id).hide();});$("#btips"+id).hide();}});});}})(jQuery);