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