/* Copyright (c) 2008 Kean Loong Tan http://www.gimiti.com/kltan
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * Copyright notice and license must remain intact for legal use
 * jHelpertip
 * Version: 1.0 (Jun 2, 2008)
 * Modified: 24-10-2008 kc
 * Optional: hoverIntent r5
 * Requires: jQuery 1.2+
 */
(function(A){A.fn.jHelperTip=function(D){var F=A.extend({},A.fn.jHelperTip.defaults,D);if(A(F.ttC).length==0){A('<div id="'+F.ttC.slice(1)+'"></div>').appendTo("body")}if(A(F.dC).length==0){A('<div id="'+F.dC.slice(1)+'"></div>').appendTo("body")}if(A(F.aC).length==0){A('<div id="'+F.aC.slice(1)+'"></div>').appendTo("body")}A(F.ttC).add(F.aC).css({position:"absolute",display:"inline"}).hide();A(F.dC).hide();var G=function(){if(F.source=="attribute"){A(F.aC).hide().empty()}else{A(F.ttC).hide().empty()}};A(".jHelperTipClose").bind("click",G);A(F.ttC).bind("mouseover",function(){A(F.ttC).show();return false});var B=function(I,H){if(F.source=="ajax"){if(F.loadingImg!=null){A(F.ttC).html('<div><img src="'+F.loadingImg+'" /></div>').show()}if(F.urlSource!=null){F.url=A(I).attr(F.urlSource)}if(F.dataSource!=null){F.data=A(I).attr(F.dataSource)}A.ajax({type:F.type,url:F.url,data:F.data,success:function(J){A(F.ttC).html(J).show();A(".jHelperTipClose").unbind("click",G);A(".jHelperTipClose").bind("click",G)}})}else{if(F.source=="container"){A(F.ttC).show().empty();A(F.dC).clone(true).show().appendTo(F.ttC)}}if(F.source=="attribute"){A(F.aC).html(A(I).attr(F.attrName))}};var E=function(M){var L=M.pageY+F.topOff;var K=M.pageX+F.leftOff;if(F.width==null){if(F.source=="attribute"){var J=A(F.aC).width()}else{var J=A(F.ttC).width()}}else{J=F.width}if(F.height==null){if(F.source=="attribute"){var H=A(F.aC).height()}else{var H=A(F.ttC).height()}}else{H=F.height}var I=A(window).width();if(K-A(window).scrollLeft()+J>I){K=K-J-2*F.leftOff}var N=A(window).height();if(L-A(window).scrollTop()+H>N){L=L-H-2*F.topOff}if(F.source=="attribute"){A(F.aC).css({top:L,left:K,opacity:F.opacity})}else{A(F.ttC).css({top:L,left:K,opacity:F.opacity})}};if(F.trigger=="hover"){if(F.hoverIntent){A(this).bind("mousemove",function(H){E(H);return false});var C={sensitivity:F.hoverSensitivity,interval:F.hoverInterval,timeout:F.hoverTimeout,over:function(H){B(this,H);return false},out:function(H){if(F.source=="attribute"){A(F.aC).hide().empty()}else{A(F.ttC).hide().empty()}return false}};A(this).hoverIntent(C)}else{A(this).bind("mouseover",function(H){B(this,H);return false});A(this).bind("mousemove",function(H){E(H);return false});A(this).bind("mouseout",function(H){if(F.source=="attribute"){A(F.aC).hide().empty()}else{A(F.ttC).hide().empty()}return false})}}else{if(F.trigger=="click"){A(this).bind("click",function(H){B(this,H);E(H);A(document).bind("click",function(I){if(F.autoClose){if(F.source=="attribute"){A(F.aC).hide().empty()}else{A(F.ttC).hide().empty()}}});return false})}}};A.fn.jHelperTip.defaults={trigger:"hover",topOff:5,leftOff:15,width:null,height:null,source:"container",attrName:"",ttC:"#jHelperTipContainer",dC:"#jHelperTipDataContainer",aC:"#jHelperTipAttrContainer",opacity:1,loadingImg:null,loadingText:null,type:"GET",url:null,urlSource:null,data:null,dataSource:null,autoClose:true,hoverIntent:false,hoverSensitivity:7,hoverInterval:100,hoverTimeout:0}})(jQuery);