(function(d){var e;var a;var b;var f={};var c=function(h,m){if(!m){var i=f[h].fixedX||f[h].posX;var j=f[h].fixedY||f[h].posY;var l=i+f[h].calcWidth+f[h].mouseX-d(window).width()-d(window).scrollLeft()+f[h].overflowX;var k=j+f[h].calcHeight+f[h].mouseY-d(window).height()-d(window).scrollTop()+f[h].overflowY;d("#jg_hover").css({top:((k>0)?((j+f[h].mouseY-k)+"px"):(j+f[h].mouseY+"px")),left:((l>0)?(((f[h].fixed?f[h].offSet.left:i)-f[h].mouseX-f[h].calcWidth)+"px"):(i+f[h].mouseX+"px"))})}if(f[h].deltaWidth>=0){d("#jg_hover_content").css("left",0)}else{if(f[h].offSet&&f[h].deltaWidth){if(f[h].source.padding&&(f[h].posX-f[h].offSet.left<=f[h].source.padding)){d("#jg_hover_content").css("left",0)}else{if(f[h].source.padding&&(f[h].posX-f[h].offSet.left>=f[h].sourceWidth-f[h].source.padding)){d("#jg_hover_content").css("left",f[h].deltaWidth+"px")}else{d("#jg_hover_content").css("left",(((f[h].posX-f[h].offSet.left-f[h].source.padding)/(f[h].sourceWidth-2*-f[h].source.padding))*f[h].deltaWidth)+"px")}}}}if(f[h].deltaHeight>=0){d("#jg_hover_content").css("top",0)}else{if(f[h].offSet&&f[h].deltaHeight){if(f[h].source.padding&&(f[h].posY-f[h].offSet.top<=f[h].source.padding)){d("#jg_hover_content").css("top",0)}else{if(f[h].source.padding&&(f[h].posY-f[h].offSet.top>=f[h].sourceHeight-f[h].source.padding)){d("#jg_hover_content").css("top",f[h].deltaHeight+"px")}else{d("#jg_hover_content").css("top",(((f[h].posY-f[h].offSet.top-f[h].source.padding)/(f[h].sourceHeight-2*f[h].source.padding))*f[h].deltaHeight)+"px")}}}}};var g=function(h,i){a=window.setTimeout(function(){if(f[h].onMouseOut){f[h].onMouseOut=false;return}var k=f[h].width||d("#jg_hover_clone").outerWidth();var j=f[h].height||d("#jg_hover_clone").outerHeight();f[h].calcWidth=f[h].viewWidth||k;f[h].calcHeight=f[h].viewHeight||j;d("#jg_hover").width(f[h].calcWidth).height(f[h].calcHeight);f[h].deltaWidth=f[h].calcWidth-k;f[h].deltaHeight=f[h].calcHeight-j;if(i){c(h)}if(f[h].fadeIn){d("#jg_hover").fadeIn(f[h].fadeIn)}else{d("#jg_hover").show()}},f[h].delay)};d.fn.jeegoohover=function(j){var h=d(this);var i=h.selector;f[i]=d.extend({delay:300,zIndex:999,mouseX:10,mouseY:10,overflowX:10,overflowY:10,livequery:false},j||{});if(f[i].fixed){f[i].mouseX=f[i].mouseY=0}f[i].source=d.extend({padding:0,animate:500},j.source||{});if(f[i].source.scale||f[i].source.width||f[i].source.height){f[i].source.resize=true}h[f[i].livequery?"livequery":"bind"]("mouseover",function(m){window.clearTimeout(b);window.clearTimeout(a);f[i].onMouseOut=false;var l=this;var k=function(){if(f[i].onLoad){f[i].onLoad.apply(l,[f[i]])}var n=d(l);if(!e){d("body").append('<div id="jg_hover" style="position:absolute;display:none;overflow:hidden"><div id="jg_hover_content" style="position:absolute;left:0;top:0"></div></div><div id="jg_hover_clone" style="position:absolute;top:-100000px;left:-100000px"></div>');if(f[i].source.resize){d("body").append('<div id="jg_hover_source_clone" style="position:absolute;display:none"></div>');d("#jg_hover_source_clone").mouseout(function(o){window.clearTimeout(b);window.clearTimeout(a);f[i].onMouseOut=true;if(f[i].fadeOut){d("#jg_hover").fadeOut(f[i].fadeOut)}else{d("#jg_hover").hide()}d("#jg_hover_source_clone").hide()}).mousemove(function(o){f[i].posX=o.pageX;f[i].posY=o.pageY;c(i,f[i].fixed)})}e=true}d("#jg_hover_content, #jg_hover_clone").width(f[i].width||"auto");d("#jg_hover_content, #jg_hover_clone").height(f[i].height||"auto");d("#jg_hover").css("zIndex",f[i].zIndex);d("#jg_hover_source_clone").css("zIndex",f[i].zIndex-1);f[i].offSet=n.offset();f[i].posX=m.pageX;f[i].posY=m.pageY;if(f[i].source.scale){f[i].sourceWidth=n.outerWidth()*f[i].source.scale;f[i].sourceHeight=n.outerHeight()*f[i].source.scale}else{f[i].sourceWidth=f[i].source.width||n.outerWidth();f[i].sourceHeight=f[i].source.height||n.outerHeight()}if(f[i].fixed){f[i].fixedX=f[i].offSet.left+f[i].sourceWidth;f[i].fixedY=f[i].offSet.top}if(f[i].source.resize&&(n.attr("src")||f[i].source.altImgSrc)){d("#jg_hover_source_clone").css({left:f[i].offSet.left+"px",top:f[i].offSet.top+"px",width:n.outerWidth()+"px",height:n.outerHeight()+"px"}).html('<img src="'+(f[i].source.altImgSrc||n.attr("src"))+'" />').show().find(":first").css({width:n.outerWidth()+"px",height:n.outerHeight()+"px"}).animate({width:f[i].sourceWidth+"px",height:f[i].sourceHeight+"px"},f[i].source.animate)}d("#jg_hover_content, #jg_hover_clone").html("");if(f[i].html){d("#jg_hover_content, #jg_hover_clone").html(f[i].html)}else{if(f[i].url){d.postJSON(f[i].url,f[i].params||{},function(o){d("#jg_hover_content, #jg_hover_clone").html(o);g(i,true)});return}}g(i)};b=window.setTimeout(k,500)});if(!f[i].source.resize){h[f[i].livequery?"livequery":"bind"]("mouseout",function(k){window.clearTimeout(b);window.clearTimeout(a);f[i].onMouseOut=true;if(f[i].fadeOut){d("#jg_hover").fadeOut(f[i].fadeOut)}else{d("#jg_hover").hide()}})[f[i].livequery?"livequery":"bind"]("mousemove",function(k){f[i].posX=k.pageX;f[i].posY=k.pageY;c(i,f[i].fixed)})}else{h[f[i].livequery?"livequery":"bind"]("mouseout",function(k){window.clearTimeout(b)})}return h}})(jQuery);
