(function(a){foswiki.openDialog=function(e,d){a.log("SM: called openDialog data="+e);a("body").css("cursor","process");if(!d._origOnShow){d._origOnShow=d.onShow;d.onShow=function(f){if(a.isFunction(d._origOnShow)){d._origOnShow(f)}c(f,d)}}d.onOpen=function(f){a.log("SM: called onOpen");f.overlay.show();f.container.hide();f.data.show()};a(e).modal(d)};function c(d,e){a.log("SM: called init");a("body").css("cursor","auto");setTimeout(function(){a(window).trigger("resize.simplemodal");d.container.fadeIn()});d.container.find(".jqSimpleModalOK:not(.jqInitedSimpleModalOK)").each(function(){a(this).addClass("jqInitedSimpleModalOK").click(function(f){a.log("SM: clicked ok");a.modal.close();if(typeof(e.onSubmit)=="function"){e.onSubmit(d)}f.preventDefault();return false})});d.container.find(".jqSimpleModalCancel:not(.jqInitedSimpleModalCancel)").each(function(){a(this).addClass("jqInitedSimpleModalCancel").click(function(f){a.log("SM: clicked cancel");a.modal.close();if(typeof(e.onCancel)=="function"){e.onCancel(d)}f.preventDefault();return false})})}var b={persist:false,close:false,opacity:40};a(function(){a(".jqSimpleModal:not(.jqInitedSimpleModal)").livequery(function(){var d=a(this);d.addClass("jqInitedSimpleModal").click(function(g){var f=a.extend({},b,d.metadata());var h=d.attr("simple-modal-data")||f.data;if(f.url&&!h){a.get(f.url,function(i){var e=a(i);h=e.attr("id");if(!h){h=foswiki.getUniqueID();e.attr("id",h).hide();a("body").append(e)}d.attr("simple-modal-data","#"+h);foswiki.openDialog("#"+h,f)})}else{foswiki.openDialog(h,f)}g.preventDefault();return false})})})})(jQuery);