(function(h){h.tools=h.tools||{};h.tools.overlay={version:"1.1.2",addEffect:function(c,b,a){e[c]=[b,a]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var e={};h.tools.overlay.addEffect("default",function(a){this.getOverlay().fadeIn(this.getConf().speed,a)},function(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});var g=[];function f(t,p){var a=this,c=h(this),b=h(window),q,r,s,v=p.expose&&h.tools.expose.version;var u=p.target||t.attr("rel");r=u?h(u):null||t;if(!r.length){throw"Could not find Overlay: "+u}if(t&&t.index(r)==-1){t.click(function(i){a.load(i);return i.preventDefault()})}h.each(p,function(j,i){if(h.isFunction(i)){c.bind(j,i)}});h.extend(a,{load:function(i){if(a.isOpened()){return a}var l=e[p.effect];if(!l){throw'Overlay: cannot find effect : "'+p.effect+'"'}if(p.oneInstance){h.each(g,function(){this.close(i)})}i=i||h.Event();i.type="onBeforeLoad";c.trigger(i);if(i.isDefaultPrevented()){return a}s=true;if(v){r.expose().load(i)}var j=p.top;var k=p.left;var n=r.outerWidth({margin:true});var m=r.outerHeight({margin:true});if(typeof j=="string"){j=j=="center"?Math.max((b.height()-m)/2,0):parseInt(j,10)/100*b.height()}if(k=="center"){k=Math.max((b.width()-n)/2,0)}if(!p.absolute){j+=b.scrollTop();k+=b.scrollLeft()}r.css({top:j,left:k,position:"absolute"});i.type="onStart";c.trigger(i);l[0].call(a,function(){if(s){i.type="onLoad";c.trigger(i)}});if(p.closeOnClick){h(document).bind("click.overlay",function(o){if(!a.isOpened()){return}var x=h(o.target);if(x.parents(r).length>1){return}h.each(g,function(){this.close(o)})})}if(p.closeOnEsc){h(document).unbind("keydown.overlay").bind("keydown.overlay",function(o){if(o.keyCode==27){h.each(g,function(){this.close(o)})}})}return a},close:function(i){if(!a.isOpened()){return a}i=i||h.Event();i.type="onBeforeClose";c.trigger(i);if(i.isDefaultPrevented()){return}s=false;e[p.effect][1].call(a,function(){i.type="onClose";c.trigger(i)});var j=true;h.each(g,function(){if(this.isOpened()){j=false}});if(j){h(document).unbind("click.overlay").unbind("keydown.overlay")}return a},getContent:function(){return r},getOverlay:function(){return r},getTrigger:function(){return t},getClosers:function(){return q},isOpened:function(){return s},getConf:function(){return p},bind:function(j,i){c.bind(j,i);return a},unbind:function(i){c.unbind(i);return a}});h.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(j,i){a[i]=function(k){return a.bind(i,k)}});if(v){if(typeof p.expose=="string"){p.expose={color:p.expose}}h.extend(p.expose,{api:true,closeOnClick:p.closeOnClick,closeOnEsc:false});var d=r.expose(p.expose);d.onBeforeClose(function(i){a.close(i)});a.onClose(function(i){d.close(i)})}q=r.find(p.close||".close");if(!q.length&&!p.close){q=h('<div class="close"></div>');r.prepend(q)}q.click(function(i){a.close(i)})}h.fn.overlay=function(c){var b=this.eq(typeof c=="number"?c:0).data("overlay");if(b){return b}if(h.isFunction(c)){c={onBeforeLoad:c}}var a=h.extend({},h.tools.overlay.conf);c=h.extend(true,a,c);this.each(function(){b=new f(h(this),c);g.push(b);h(this).data("overlay",b)});return c.api?b:this}})(jQuery);(function(d){d.tools=d.tools||{};d.tools.expose={version:"1.0.5",conf:{maskId:null,loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,color:"#456",api:false}};function e(){if(d.browser.msie){var a=d(document).height(),b=d(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,a-b<20?b:a]}return[d(window).width(),d(document).height()]}function f(c,k){var m=this,a=d(this),n=null,l=false,b=0;d.each(k,function(h,g){if(d.isFunction(g)){a.bind(h,g)}});d(window).resize(function(){m.fit()});d.extend(this,{getMask:function(){return n},getExposed:function(){return c},getConf:function(){return k},isLoaded:function(){return l},load:function(j){if(l){return m}b=c.eq(0).css("zIndex");if(k.maskId){n=d("#"+k.maskId)}if(!n||!n.length){var h=e();n=d("<div/>").css({position:"absolute",top:0,left:0,width:h[0],height:h[1],display:"none",opacity:0,zIndex:k.zIndex});if(k.maskId){n.attr("id",k.maskId)}d("body").append(n);var i=n.css("backgroundColor");if(!i||i=="transparent"||i=="rgba(0, 0, 0, 0)"){n.css("backgroundColor",k.color)}if(k.closeOnEsc){d(document).bind("keydown.unexpose",function(p){if(p.keyCode==27){m.close()}})}if(k.closeOnClick){n.bind("click.unexpose",function(p){m.close(p)})}}j=j||d.Event();j.type="onBeforeLoad";a.trigger(j);if(j.isDefaultPrevented()){return m}d.each(c,function(){var p=d(this);if(!/relative|absolute|fixed/i.test(p.css("position"))){p.css("position","relative")}});c.css({zIndex:Math.max(k.zIndex+1,b=="auto"?0:b)});var g=n.height();if(!this.isLoaded()){n.css({opacity:0,display:"block"}).fadeTo(k.loadSpeed,k.opacity,function(){if(n.height()!=g){n.css("height",g)}j.type="onLoad";a.trigger(j)})}l=true;return m},close:function(g){if(!l){return m}g=g||d.Event();g.type="onBeforeClose";a.trigger(g);if(g.isDefaultPrevented()){return m}n.fadeOut(k.closeSpeed,function(){g.type="onClose";a.trigger(g);c.css({zIndex:d.browser.msie?b:null})});l=false;return m},fit:function(){if(n){var g=e();n.css({width:g[0],height:g[1]})}},bind:function(h,g){a.bind(h,g);return m},unbind:function(g){a.unbind(g);return m}});d.each("onBeforeLoad,onLoad,onBeforeClose,onClose".split(","),function(h,g){m[g]=function(i){return m.bind(g,i)}})}d.fn.expose=function(c){var b=this.eq(typeof c=="number"?c:0).data("expose");if(b){return b}if(typeof c=="string"){c={color:c}}var a=d.extend({},d.tools.expose.conf);c=d.extend(a,c);this.each(function(){b=new f(d(this),c);d(this).data("expose",b)});return c.api?b:this}})(jQuery);