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