(function(n){n.fn.modal=function(e){var f={overlay:50,overlayClass:"ektronModalOverlay",closeClass:"ektronModalClose",trigger:".ektronModal",ajax:k,ajaxText:"",target:k,modal:k,toTop:k,onShow:k,onHide:k,onLoad:k};return this.each(function(){if(this._modal){return c[this._modal].c=n.extend({},c[this._modal].c,e)}b++;this._modal=b;c[b]={c:n.extend(f,n.modal.params,e),a:k,w:n(this).addClass("modalID"+b),s:b};if(f.trigger){n(this).modalAddTrigger(f.trigger)}})};n.fn.modalAddClose=function(f){return o(this,f,"modalHide")};n.fn.modalAddTrigger=function(f){return o(this,f,"modalShow")};n.fn.modalShow=function(e){return this.each(function(){n.modal.open(this._modal,e)})};n.fn.modalHide=function(e){return this.each(function(){n.modal.close(this._modal,e)})};n.modal={hash:{},open:function(i,m){var v=c[i],A=v.c,f="."+A.closeClass,x=(parseInt(v.w.css("z-index"))),x=(x>0)?x:3000,w=n("<div></div>").css({height:"100%",width:"100%",position:"fixed",left:0,top:0,"z-index":x-1,opacity:A.overlay/100});if(v.a){return k}v.t=m;v.a=true;v.w.css("z-index",x);if(A.modal){if(!h[0]){g("bind")}h.push(i)}else{if(A.overlay>0){v.w.modalAddClose(w)}else{w=k}}v.o=(w)?w.addClass(A.overlayClass).prependTo("body"):k;if(d){n("html,body").css({height:"100%",width:"100%"});if(w){w=w.css({position:"absolute"})[0];for(var B in {Top:1,Left:1}){w.style.setExpression(B.toLowerCase(),"(_=(document.documentElement.scroll"+B+" || document.body.scroll"+B+"))+'px'")}}}if(A.ajax){var e=A.target||v.w,q=A.ajax,e=(typeof e=="string")?n(e,v.w):n(e),q=(q.substr(0,1)=="@")?n(m).attr(q.substring(1)):q;e.html(A.ajaxText).load(q,function(){if(A.onLoad){A.onLoad.call(this,v)}if(f){v.w.modalAddClose(n(f,v.w))}a(v)})}else{if(f){v.w.modalAddClose(n(f,v.w))}}if(A.toTop&&v.o){v.w.before('<span id="ektronModalP'+v.w[0]._modal+'"></span>').insertAfter(v.o)}(A.onShow)?A.onShow(v):v.w.show();a(v);return k},close:function(f){var e=c[f];if(!e||!e.a){return k}e.a=k;if(h[0]){h.pop();if(!h[0]){g("unbind")}}if(e.c.toTop&&e.o){n("#ektronModalP"+e.w[0]._modal).after(e.w).remove()}if(e.c.onHide){e.c.onHide(e)}else{e.w.hide();if(e.o){e.o.remove()}}return k},params:{}};var b=0,c=n.modal.hash,h=[],d=n.browser.msie&&(n.browser.version=="6.0"),k=false,j=n('<iframe src="javascript:false;document.write(\'\');" class="ektronModalIframe"></iframe>').css({opacity:0}),a=function(e){if(d){if(e.o){e.o.html('<p style="width:100%;height:100%"/>').prepend(j)}else{if(!n("iframe.ektronModalIframe",e.w)[0]){e.w.prepend(j)}}}p(e)},p=function(e){try{n(":input:visible",e.w).eq(0).focus()}catch(f){}},g=function(e){n()[e]("keypress",l)[e]("keydown",l)[e]("mousedown",l)},l=function(m){var f=c[h[h.length-1]],i=(!n(m.target).parents(".modalID"+f.s)[0]);if(i){p(f)}return !i},o=function(e,f,i){return e.each(function(){var m=this._modal;n(f).each(function(){if(!this[i]){this[i]=[];n(this).click(function(){for(var q in {modalShow:1,modalHide:1}){for(var r in this[q]){if(c[this[q][r]]){c[this[q][r]].w[q](this)}}}return k})}this[i].push(m)})})}})($ektron);

