(function(E){E.fn.jqm=function(F){var A={overlay:50,overlayClass:"jqmOverlay",closeClass:"jqmClose",trigger:".jqModal",ajax:O,ajaxText:"",target:O,modal:O,toTop:O,onShow:O,onHide:O,onLoad:O};return this.each(function(){if(this._jqm){return N[this._jqm].c=E.extend({},N[this._jqm].c,F)}P++;this._jqm=P;N[P]={c:E.extend(A,E.jqm.params,F),a:O,w:E(this).addClass("jqmID"+P),s:P};if(A.trigger){E(this).jqmAddTrigger(A.trigger)}})};E.fn.jqmAddClose=function(A){return M(this,A,"jqmHide")};E.fn.jqmAddTrigger=function(A){return M(this,A,"jqmShow")};E.fn.jqmShow=function(A){return this.each(function(){A=A||window.event;E.jqm.open(this._jqm,A)})};E.fn.jqmHide=function(A){return this.each(function(){A=A||window.event;E.jqm.close(this._jqm,A)})};E.jqm={hash:{},open:function(V,U){var L=N[V],Q=L.c,H="."+Q.closeClass,R=(parseInt(L.w.css("z-index"))),R=(R>0)?R:3000,F=E("<div></div>").css({height:"100%",width:"100%",position:"fixed",left:0,top:0,"z-index":R-1,opacity:Q.overlay/100});if(L.a){return O}L.t=U;L.a=true;L.w.css("z-index",R);if(Q.modal){if(!B[0]){K("bind")}B.push(V)}else{if(Q.overlay>0){L.w.jqmAddClose(F)}else{F=O}}L.o=(F)?F.addClass(Q.overlayClass).prependTo("body"):O;if(D){E("html,body").css({height:"100%",width:"100%"});if(F){F=F.css({position:"absolute"})[0];for(var S in {Top:1,Left:1}){F.style.setExpression(S.toLowerCase(),"(_=(document.documentElement.scroll"+S+" || document.body.scroll"+S+"))+'px'")}}}if(Q.ajax){var A=Q.target||L.w,T=Q.ajax,A=(typeof A=="string")?E(A,L.w):E(A),T=(T.substr(0,1)=="@")?E(U).attr(T.substring(1)):T;A.html(Q.ajaxText).load(T,function(){if(Q.onLoad){Q.onLoad.call(this,L)}if(H){L.w.jqmAddClose(E(H,L.w))}J(L)})}else{if(H){L.w.jqmAddClose(E(H,L.w))}}if(Q.toTop&&L.o){L.w.before('<span id="jqmP'+L.w[0]._jqm+'"></span>').insertAfter(L.o)}(Q.onShow)?Q.onShow(L):L.w.show();J(L);return O},close:function(F){var A=N[F];if(!A.a){return O}A.a=O;if(B[0]){B.pop();if(!B[0]){K("unbind")}}if(A.c.toTop&&A.o){E("#jqmP"+A.w[0]._jqm).after(A.w).remove()}if(A.c.onHide){A.c.onHide(A)}else{A.w.hide();if(A.o){A.o.remove()}}return O},params:{}};var P=0,N=E.jqm.hash,B=[],D=E.browser.msie&&(E.browser.version=="6.0"),O=false,G=E('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),J=function(A){if(D){if(A.o){A.o.html('<p style="width:100%;height:100%"/>').prepend(G)}else{if(!E("iframe.jqm",A.w)[0]){A.w.prepend(G)}}}I(A)},I=function(F){try{E(":input:visible",F.w)[0].focus()}catch(A){}},K=function(A){E()[A]("keypress",C)[A]("keydown",C)[A]("mousedown",C)},C=function(H){var A=N[B[B.length-1]],F=(!E(H.target).parents(".jqmID"+A.s)[0]);if(F){I(A)}return !F},M=function(A,F,H){return A.each(function(){var L=this._jqm;E(F).each(function(){if(!this[H]){this[H]=[];E(this).click(function(){for(var Q in {jqmShow:1,jqmHide:1}){for(var R in this[Q]){if(N[this[Q][R]]){N[this[Q][R]].w[Q](this)}}}return O})}this[H].push(L)})})}})(jQuery);