(function(b){function c(u,w){var v=this,r=u.add(v),h=b(window),q,t,l,s=b.tools.expose&&(w.mask||w.expose),j=Math.random().toString().slice(10);if(s){if(typeof s=="string"){s={color:s}}s.closeOnClick=s.closeOnEsc=false}var a=w.target||u.attr("rel");t=a?b(a):u;if(!t.length){throw"Could not find Overlay: "+a}u&&u.index(t)==-1&&u.click(function(f){v.load(f);return f.preventDefault()});b.extend(v,{load:function(n){if(v.isOpened()){return v}var k=e[w.effect];if(!k){throw'Overlay: cannot find effect : "'+w.effect+'"'}w.oneInstance&&b.each(d,function(){this.close(n)});n=n||b.Event();n.type="onBeforeLoad";r.trigger(n);if(n.isDefaultPrevented()){return v}l=true;s&&b(t).expose(s);var i=w.top,m=w.left,g=t.outerWidth({margin:true}),f=t.outerHeight({margin:true});if(typeof i=="string"){i=i=="center"?Math.max((h.height()-f)/2,0):parseInt(i,10)/100*h.height()}if(m=="center"){m=Math.max((h.width()-g)/2,0)}k[0].call(v,{top:i,left:m},function(){if(l){n.type="onLoad";r.trigger(n)}});s&&w.closeOnClick&&b.mask.getMask().one("click",v.close);w.closeOnClick&&b(document).bind("click."+j,function(o){b(o.target).parents(t).length||v.close(o)});w.closeOnEsc&&b(document).bind("keydown."+j,function(o){o.keyCode==27&&v.close(o)});return v},close:function(f){if(!v.isOpened()){return v}f=f||b.Event();f.type="onBeforeClose";r.trigger(f);if(!f.isDefaultPrevented()){l=false;e[w.effect][1].call(v,function(){f.type="onClose";r.trigger(f)});b(document).unbind("click."+j).unbind("keydown."+j);s&&b.mask.close();return v}},getOverlay:function(){return t},getTrigger:function(){return u},getClosers:function(){return q},isOpened:function(){return l},getConf:function(){return w}});b.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(g,f){b.isFunction(w[f])&&b(v).bind(f,w[f]);v[f]=function(i){b(v).bind(f,i);return v}});q=t.find(w.close||".close");if(!q.length&&!w.close){q=b('<a class="close"></a>');t.prepend(q)}q.click(function(f){v.close(f)});w.load&&v.load()}b.tools=b.tools||{version:"1.2.3"};b.tools.overlay={addEffect:function(f,a,g){e[f]=[a,g]},conf:{close:null,closeOnClick:true,closeOnEsc:true,closeSpeed:"fast",effect:"default",fixed:!b.browser.msie||b.browser.version>6,left:"center",load:false,mask:null,oneInstance:true,speed:"normal",target:null,top:"10%"}};var d=[],e={};b.tools.overlay.addEffect("default",function(g,a){var h=this.getConf(),f=b(window);if(!h.fixed){g.top+=f.scrollTop();g.left+=f.scrollLeft()}g.position=h.fixed?"fixed":"absolute";this.getOverlay().css(g).fadeIn(h.speed,a)},function(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});b.fn.overlay=function(f){var a=this.data("overlay");if(a){return a}if(b.isFunction(f)){f={onBeforeLoad:f}}f=b.extend(true,{},b.tools.overlay.conf,f);this.each(function(){a=new c(b(this),f);d.push(a);b(this).data("overlay",a)});return f.api?a:this}})(jQuery);(function(c){function b(f){var h=f.offset();return{top:h.top+f.height()/2,left:h.left+f.width()/2}}var a=c.tools.overlay,d=c(window);c.extend(a.conf,{start:{top:null,left:null},fadeInSpeed:"fast",zIndex:9999});function g(s,q){var t=this.getOverlay(),r=this.getConf(),n=this.getTrigger(),f=this,j=t.outerWidth({margin:true}),k=t.data("img");if(!k){var p=t.css("backgroundImage");if(!p){throw"background-image CSS property not set for overlay"}p=p.slice(p.indexOf("(")+1,p.indexOf(")")).replace(/\"/g,"");t.css("backgroundImage","none");k=c('<img src="'+p+'"/>');k.css({border:0,display:"none"}).width(j);c("body").append(k);t.data("img",k)}p=r.start.top||Math.round(d.height()/2);var i=r.start.left||Math.round(d.width()/2);if(n){n=b(n);p=n.top;i=n.left}k.css({position:"absolute",top:p,left:i,width:0,zIndex:r.zIndex}).show();s.top+=d.scrollTop();s.left+=d.scrollLeft();s.position="absolute";t.css(s);k.animate({top:t.css("top"),left:t.css("left"),width:j},r.speed,function(){if(r.fixed){s.top-=d.scrollTop();s.left-=d.scrollLeft();s.position="fixed";k.add(t).css(s)}t.css("zIndex",r.zIndex+1).fadeIn(r.fadeInSpeed,function(){f.isOpened()&&!c(this).index(t)?q.call():t.hide()})})}function e(f){var j=this.getOverlay().hide(),h=this.getConf(),k=this.getTrigger();j=j.data("img");var i={top:h.start.top,left:h.start.left,width:0};k&&c.extend(i,b(k));h.fixed&&j.css({position:"absolute"}).animate({top:"+="+d.scrollTop(),left:"+="+d.scrollLeft()},0);j.animate(i,h.closeSpeed,f)}a.addEffect("apple",g,e)})(jQuery);
