(function(b){window.CreateDirDialog={currentWin:b.WindowManager.find(window),init:function(){var f=this,a,e;a=b.extend({path:"{default}",visual_path:"/"},f.currentWin.getArgs());RPC.exec("im.getConfig",{path:a.path},function(c){var i=c.result,d=[],j;if(!RPC.handleError({message:"Get config error",visual_path:f.visualPath,response:c})){e=i["filesystem.clean_names"]=="true";b(i["filesystem.directory_templates"].split(/,/)).each(function(g,h){if(h){h=b.trim(h).split("=");d.push({name:/([^\/]+)$/.exec(h[0])[0],value:h[1]||h[0]})}});if(i["filesystem.force_directory_template"]=="true"){b("#template").html("");if(d.length==1){b("#templaterow").hide()}}if(d.length==0){b("#templaterow").hide()}j=b.templateFromScript("#template_template");b(d).each(function(g,h){b("#template").append(j,h)});b("#content").show();b("#createin").html(a.visual_path);b("form").submit(function(){var g=b("#template").val(),h=b("#dirname").val();if(e){h=b.cleanName(h)}if(!f.isDemo()){RPC.exec("im.createDirs",{path:a.path,name0:h,template0:g},function(n){var p=RPC.toArray(n.result),o=f.currentWin.getArgs();if(!RPC.handleError({message:"{#error.createdir_failed}",visual_path:a.visual_path,response:n})){if(o.oncreate){RPC.insertFile({relative_urls:o.relative_urls,document_base_url:o.document_base_url,default_base_url:o.default_base_url,no_host:o.remove_script_host||o.no_host,path:p[0].file,progress_message:b.translate("{#message.insert}"),insert_filter:o.insert_filter,oninsert:function(k){o.oncreate(k);f.currentWin.close()}})}}})}return false});b("#cancel").click(function(){f.currentWin.close()})}})},isDemo:function(){if(this.currentWin.getArgs().is_demo){b.WindowManager.info(b.translate("{#error.demo}"));return true}}};b(function(){CreateDirDialog.init()})})(jQuery);