function getChecked(){return getFolders().findAll(function(a){return a.checked})}function getFolders(){return $("fmanager").getInputs(null,"folder_list[]")}function selectedFoldersDisplay(){var a=0,b="";getFolders().each(function(c){if(c.checked){b+=displayNames[a]+"\n"}++a});if(b.endsWith("\n")){b=b.substring(0,b.length-1)}return b}function chooseAction(d){var f=(d.element().id=="action_choose0")?0:1;var b=$("action_choose"+f);var c=$F(b);b.selectedIndex=0;if(c=="create_folder"){createMailbox()}else{if(c=="rebuild_tree"){submitAction(c)}else{if(!getChecked().size()){if(c!=""){alert(IMP.text.folders_select)}}else{if(c=="rename_folder"){renameMailbox()}else{if(c=="subscribe_folder"||c=="unsubscribe_folder"||c=="poll_folder"||c=="expunge_folder"||c=="nopoll_folder"||c=="mark_folder_seen"||c=="mark_folder_unseen"||c=="delete_folder_confirm"||c=="folders_empty_mailbox_confirm"||c=="mbox_size"){submitAction(c)}else{if(c=="download_folder"||c=="download_folder_zip"){downloadMailbox(c)}else{if(c=="import_mbox"){if(getChecked().length>1){alert(IMP.text.folders_oneselect)}else{submitAction(c)}}}}}}}}}function submitAction(b){$("actionID").setValue(b);$("fmanager").submit()}function createMailbox(){var a=getChecked().size(),b;if(a>1){window.alert(IMP.text.folders_oneselect);return}if(a==1){b=window.prompt(IMP.text.folders_subfolder1+" "+selectedFoldersDisplay()+".\n"+IMP.text.folders_subfolder2+"\n","")}else{b=window.prompt(IMP.text.folders_toplevel,"")}if(b){$("new_mailbox").setValue(b);submitAction("create_folder")}}function downloadMailbox(a){if(window.confirm(IMP.text.folders_download1+"\n"+selectedFoldersDisplay()+"\n"+IMP.text.folders_download2)){submitAction(a)}}function renameMailbox(){var b="",c="",a=0;getFolders().each(function(e){if(e.checked){if(IMP.conf.fixed_folders.indexOf(displayNames[a])!=-1){window.alert(IMP.text.folders_no_rename+" "+displayNames[a])}else{var d=window.prompt(IMP.text.folders_rename1+" "+displayNames[a]+"\n"+IMP.text.folders_rename2,fullNames[a]?fullNames[a]:displayNames[a]);if(d){b+=d+"\n";c+=e.value+"\n"}}}++a});if(!b){return}if(b.endsWith("\n")){b=b.substring(0,b.length-1)}if(c.endsWith("\n")){c=c.substring(0,c.length-1)}$("new_names").setValue(b);$("old_names").setValue(c);submitAction("rename_folder");return true}function toggleSelection(){var c=getChecked().size(),a=getFolders();var b=(c!=a.size());a.each(function(d){d.checked=b})}document.observe("dom:loaded",function(){if($("checkAll0")){$("checkAll0").observe("click",toggleSelection);$("action_choose0").observe("change",chooseAction)}if($("checkAll1")){$("checkAll1").observe("click",toggleSelection);$("action_choose1").observe("change",chooseAction)}});