(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.4"};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(r){function d(){if(r.browser.msie){var b=r(document).height(),c=r(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,b-c<20?c:b]}return[r(document).width(),r(document).height()]}function n(b){if(b){return b.call(r.mask)}}r.tools=r.tools||{version:"1.2.4"};var a;a=r.tools.expose={conf:{maskId:"exposeMask",loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,startOpacity:0,color:"#fff",onLoad:null,onClose:null}};var q,m,p,o,f;r.mask={load:function(c,e){if(p){return this}if(typeof c=="string"){c={color:c}}c=c||o;o=c=r.extend(r.extend({},a.conf),c);q=r("#"+c.maskId);if(!q.length){q=r("<div/>").attr("id",c.maskId);r("body").append(q)}var b=d();q.css({position:"absolute",top:0,left:0,width:b[0],height:b[1],display:"none",opacity:c.startOpacity,zIndex:c.zIndex});c.color&&q.css("backgroundColor",c.color);if(n(c.onBeforeLoad)===false){return this}c.closeOnEsc&&r(document).bind("keydown.mask",function(g){g.keyCode==27&&r.mask.close(g)});c.closeOnClick&&q.bind("click.mask",function(g){r.mask.close(g)});r(window).bind("resize.mask",function(){r.mask.fit()});if(e&&e.length){f=e.eq(0).css("zIndex");r.each(e,function(){var g=r(this);/relative|absolute|fixed/i.test(g.css("position"))||g.css("position","relative")});m=e.css({zIndex:Math.max(c.zIndex+1,f=="auto"?0:f)})}q.css({display:"block"}).fadeTo(c.loadSpeed,c.opacity,function(){r.mask.fit();n(c.onLoad);p="full"});p=true;return this},close:function(){if(p){if(n(o.onBeforeClose)===false){return this}q.fadeOut(o.closeSpeed,function(){n(o.onClose);m&&m.css({zIndex:f});p=false});r(document).unbind("keydown.mask");q.unbind("click.mask");r(window).unbind("resize.mask")}return this},fit:function(){if(p){var b=d();q.css({width:b[0],height:b[1]})}},getMask:function(){return q},isLoaded:function(b){return b?p=="full":p},getConf:function(){return o},getExposed:function(){return m}};r.fn.mask=function(b){r.mask.load(b);return this};r.fn.expose=function(b){r.mask.load(b,this);return this}})(jQuery);(function(e){e.tools=e.tools||{version:"1.2.3"};e.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,position:["top","center"],offset:[0,0],relative:false,cancelDefault:true,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip",tipContent:".tooltip"},addEffect:function(f,h,g){d[f]=[h,g]}};var d={toggle:[function(f){var g=this.getConf(),h=this.getTip(),i=g.opacity;if(i<1){h.css({opacity:i})}h.show();f.call()},function(f){this.getTip().hide();f.call()}],fade:[function(f){var g=this.getConf();this.getTip().fadeTo(g.fadeInSpeed,g.opacity,f)},function(f){this.getTip().fadeOut(this.getConf().fadeOutSpeed,f)}]};function c(h,j,g){var l=g.relative?h.position().top:h.offset().top,k=g.relative?h.position().left:h.offset().left,m=g.position[0];l-=j.outerHeight()-g.offset[0];k+=h.outerWidth()+g.offset[1];var f=j.outerHeight()+h.outerHeight();if(m=="center"){l+=f/2}if(m=="bottom"){l+=f}m=g.position[1];var i=j.outerWidth()+h.outerWidth();if(m=="center"){k-=i/2}if(m=="left"){k-=i}return{top:l,left:k}}function b(j){var i=0,f=0;var l=document.createElement("div");document.body.appendChild(l);e(l).css({position:"absolute",left:-1000,top:-1000,display:"none"});e(l).html(e(j).html());var k=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];e(k).each(function(){var h=this.toString();e(l).css({s:e(j).css(h)})});i=e(l).outerHeight();f=e(l).outerWidth();e(l).remove();var g={height:i,width:f};return g}function a(i,j){var r=this,h=i.add(r),o,g=0,q=0,m=i.attr("title"),s=d[j.effect],n,l=i.is(":input"),f=l&&i.is(":checkbox, :radio, select, :button, :submit"),k=i.attr("type"),p=j.events[k]||j.events[l?(f?"widget":"input"):"def"];if(!s){throw'Nonexistent effect "'+j.effect+'"'}p=p.split(/,\s*/);if(p.length!=2){throw"Tooltip: bad events configuration for "+k}i.bind(p[0],function(t){clearTimeout(g);if(j.predelay){q=setTimeout(function(){r.show(t)},j.predelay)}else{r.show(t)}}).bind(p[1],function(t){clearTimeout(q);if(j.delay){g=setTimeout(function(){r.hide(t)},j.delay)}else{r.hide(t)}});if(m&&j.cancelDefault){i.removeAttr("title");i.data("title",m)}e.extend(r,{show:function(v){if(!o){if(m){o=e(j.layout).addClass(j.tipClass).appendTo(document.body).hide()}else{if(j.tip){o=e(j.tip).eq(0)}else{o=i.next();if(!o.length){o=i.parent().next()}}}if(!o.length){throw"Cannot find tooltip for "+i}}e(j.tipContent).html(m);if(r.isShown()){return r}o.stop(true,true);var w=c(i,o,j,v);v=v||e.Event();v.type="onBeforeShow";h.trigger(v,[w]);if(v.isDefaultPrevented()){return r}w=c(i,o,j);var u=b(j.tipContent);o.css({position:"absolute",top:w.top,left:w.left,width:u.width+24+"px"});o.children(".tooltip_bg").eq(0).css({width:u.width-5+"px"});i.bind("mousemove",function(x){if(o){mtop=Math.round(x.pageY-o.outerHeight()-12);mleft=Math.round(x.pageX-o.outerWidth()/2+7);o.css({position:"absolute",top:mtop+"px",left:mleft+"px"})}});n=true;s[0].call(r,function(){v.type="onShow";n="full";h.trigger(v)});var t=j.events.tooltip.split(/,\s*/);o.bind(t[0],function(){clearTimeout(g);clearTimeout(q)});if(t[1]&&!i.is("input:not(:checkbox, :radio), textarea")){o.bind(t[1],function(x){if(x.relatedTarget!=i[0]){i.trigger(p[1].split(" ")[0])}})}return r},hide:function(t){if(!o||!r.isShown()){return r}t=t||e.Event();t.type="onBeforeHide";h.trigger(t);if(t.isDefaultPrevented()){return}n=false;d[j.effect][1].call(r,function(){t.type="onHide";n=false;h.trigger(t)});return r},isShown:function(t){return t?n=="full":n},getConf:function(){return j},getTip:function(){return o},getTrigger:function(){return i}});e.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(u,t){if(e.isFunction(j[t])){e(r).bind(t,j[t])}r[t]=function(v){e(r).bind(t,v);return r}})}e.fn.tooltip=function(f){var g=this.data("tooltip");if(g){return g}f=e.extend(true,{},e.tools.tooltip.conf,f);if(typeof f.position=="string"){f.position=f.position.split(/,?\s/)}this.each(function(){g=new a(e(this),f);e(this).data("tooltip",g)});return f.api?g:this}})(jQuery);
