(function(a){a.fn.imgdance=function(v){opt=jQuery.extend({speed:5000,wait:3000,fade:2000,reveal:500,easing:"easeInOutQuad",xOffset:45,yOffset:30,global:true},v);var b=new Array();var m=this,n,j,u=0,k,l=true,e=0,g=true,c=0,o=0,q=false,r=false;m.each(function(){m.children().each(function(){b[u]=new Array;b[u][0]=a(this).attr("src");b[u][1]=a(this).height();a(this).hide();u++});n=m.height();j=m.width();var i=a('<div id="idOverlay"></div>').css({position:"absolute",top:"0px",left:"0px",height:n+"px",width:j+"px"}).appendTo(m);m.css({backgroundImage:"url("+b[e][0]+")",backgroundPosition:"0px 0px"});imTooltip=a('<div id="tooltip"><p></p></div>').appendTo(document.body).hide();a(document.body).bind("mousemove",function(x){a("#tooltip").css({top:(x.pageY-opt.yOffset)+"px",left:(x.pageX-opt.xOffset)+"px"})});m.mouseenter(function(){q=true;d()}).mouseleave(function(){q=false;h()}).bind("click",w);f()});function f(){g=false;if(q==true){d()}k=setTimeout(t,opt.wait)}function t(){l==true?c=(n-b[e][1]):c=0;m.animate({backgroundPosition:"0px "+c+"px"},opt.speed,opt.easing,function(){p()})}function p(){g=true;h();l=!l;e==(b.length-1)?e=0:e++;l==true?o=0:o=(n-b[e][1]);a("#idOverlay").css("opacity","0").css({backgroundImage:"url("+b[e][0]+")",backgroundPosition:"0px "+o+"px"}).animate({opacity:1},opt.fade,"linear",function(){s()})}function s(){m.css("background-image","url("+b[e][0]+")").css("background-position","0px "+o+"px");a("#idOverlay").css("opacity","0");f()}function d(){if(!g&&!r){imTooltip.html("<p>click to expand</p>").show()}else{if(r){imTooltip.html("<p>click to close</p>").show()}}}function h(){imTooltip.hide()}function w(){if(!g&&!r){clearTimeout(k);imTooltip.html("<p>click to close</p>");m.stop();g=true;m.animate({height:b[e][1]+"px",backgroundPosition:"0px 0px"},opt.reveal,opt.easing,function(){r=true})}else{if(r){h();m.animate({height:n+"px",backgroundPosition:"0px 0px"},opt.reveal,opt.easing,function(){r=false;q=false;p()})}}}return this}})(jQuery);(function(b){if(!document.defaultView||!document.defaultView.getComputedStyle){var d=jQuery.curCSS;jQuery.curCSS=function(g,e,h){if(e==="background-position"){e="backgroundPosition"}if(e!=="backgroundPosition"||!g.currentStyle||g.currentStyle[e]){return d.apply(this,arguments)}var f=g.style;if(!h&&f&&f[e]){return f[e]}return d(g,"backgroundPositionX",h)+" "+d(g,"backgroundPositionY",h)}}var c=b.fn.animate;b.fn.animate=function(e){if("background-position" in e){e.backgroundPosition=e["background-position"];delete e["background-position"]}if("backgroundPosition" in e){e.backgroundPosition="("+e.backgroundPosition}return c.apply(this,arguments)};function a(f){f=f.replace(/left|top/g,"0px");f=f.replace(/right|bottom/g,"100%");f=f.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var e=f.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(e[1],10),e[2],parseFloat(e[3],10),e[4]]}b.fx.step.backgroundPosition=function(f){if(!f.bgPosReady){var h=b.curCSS(f.elem,"backgroundPosition");if(!h){h="0px 0px"}h=a(h);f.start=[h[0],h[2]];var e=a(f.options.curAnim.backgroundPosition);f.end=[e[0],e[2]];f.unit=[e[1],e[3]];f.bgPosReady=true}var g=[];g[0]=((f.end[0]-f.start[0])*f.pos)+f.start[0]+f.unit[0];g[1]=((f.end[1]-f.start[1])*f.pos)+f.start[1]+f.unit[1];f.elem.style.backgroundPosition=g[0]+" "+g[1]}})(jQuery);
