(function(a){a.tools=a.tools||{version:{}};a.tools.version.expose="1.0.3";function c(){var e=a(window).width();if(a.browser.mozilla){return e}var d;if(window.innerHeight&&window.scrollMaxY){d=window.innerWidth+window.scrollMaxX}else{if(document.body.scrollHeight>document.body.offsetHeight){d=document.body.scrollWidth}else{d=document.body.offsetWidth}}return d<e?d+20:e}function b(j,g){var e=this,d=null,h=false,i=0;function f(k,l){a(e).bind(k,function(n,m){if(l&&l.call(this)===false&&m){m.proceed=false}});return e}a.each(g,function(k,l){if(a.isFunction(l)){f(k,l)}});a(window).bind("resize.expose",function(){if(d){d.css({width:c(),height:a(document).height()})}});a.extend(this,{getMask:function(){return d},getExposed:function(){return j},getConf:function(){return g},isLoaded:function(){return h},load:function(){if(h){return e}i=j.eq(0).css("zIndex");if(g.maskId){d=a("#"+g.maskId)}if(!d||!d.length){d=a("<div/>").css({position:"absolute",top:0,left:0,width:c(),height:a(document).height(),display:"none",opacity:0,zIndex:g.zIndex});if(g.maskId){d.attr("id",g.maskId)}a("body").append(d);var k=d.css("backgroundColor");if(!k||k=="transparent"||k=="rgba(0, 0, 0, 0)"){d.css("backgroundColor",g.color)}if(g.closeOnEsc){a(document).bind("keydown.unexpose",function(n){if(n.keyCode==27){e.close()}})}if(g.closeOnClick){d.bind("click.unexpose",function(){e.close()})}}var m={proceed:true};a(e).trigger("onBeforeLoad",m);if(!m.proceed){return e}a.each(j,function(){var n=a(this);if(!/relative|absolute|fixed/i.test(n.css("position"))){n.css("position","relative")}});j.css({zIndex:g.zIndex+1});var l=d.height();if(!this.isLoaded()){d.css({opacity:0,display:"block"}).fadeTo(g.loadSpeed,g.opacity,function(){if(d.height()!=l){d.css("height",l)}a(e).trigger("onLoad")})}h=true;return e},close:function(){if(!h){return e}var k={proceed:true};a(e).trigger("onBeforeClose",k);if(k.proceed===false){return e}d.fadeOut(g.closeSpeed,function(){a(e).trigger("onClose");j.css({zIndex:a.browser.msie?i:null})});h=false;return e},onBeforeLoad:function(k){return f("onBeforeLoad",k)},onLoad:function(k){return f("onLoad",k)},onBeforeClose:function(k){return f("onBeforeClose",k)},onClose:function(k){return f("onClose",k)}})}a.fn.expose=function(e){var f=this.eq(typeof e=="number"?e:0).data("expose");if(f){return f}var d={maskId:null,loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,color:"#456",api:false};if(typeof e=="string"){e={color:e}}a.extend(d,e);this.each(function(){f=new b(a(this),d);a(this).data("expose",f)});return d.api?f:this}})(jQuery);
