jQuery(function(a){a(".ecpEdit").live("click",function(){var d=a(this),b=d.attr("href"),c=a.extend({},d.metadata());a.jsonRpc(foswiki.getPreference("SCRIPTURL")+"/jsonrpc",{namespace:"EditChapterPlugin",method:"lock",params:{topic:c.web+"."+c.topic},success:function(){a.get(b,function(f){var e=a(f);e.hide();a("body").append(e);e.data("autoOpen",true)})},error:function(e,g,f){alert(e.error.message)}});return false});a(".ecpForm:not(.ecpInitedForm)").livequery(function(){var d=a(this),b=d.find("input[name='topic']").val(),c=d.parent();c.bind("cancel",function(){a.jsonRpc(foswiki.getPreference("SCRIPTURL")+"/jsonrpc",{namespace:"EditChapterPlugin",method:"unlock",params:{topic:b},error:function(e,g,f){}});c.dialog("close")});d.addClass("ecpInitedForm").submit(function(){var h=d.find("[name=beforetext]"),j=d.find("[name=aftertext]"),e=d.find("[name=chapter]"),i=d.find("[name=text]"),g,f;if(!h.length||!j.length||!e.length){return false}g=e.val();f=g.substr(g.length-1,1);if(f!="\n"){g+="\n"}i.val(h.val()+g+j.val())})});a(".foswikiToc .ecpHeading").addClass("ecpDisabled");if(a.browser.msie){a(".ecpHeading:not(.ecpDisabled)").hover(function(b){a(this).addClass("ecpHover");b.stopPropagation()},function(b){a(this).removeClass("ecpHover");b.stopPropagation()})}else{a(".ecpHeading:not(.ecpDisabled)").hoverIntent({timeout:500,over:function(b){a(this).addClass("ecpHover");b.stopPropagation()},out:function(b){a(this).removeClass("ecpHover");b.stopPropagation()}})}});
