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

