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