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