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