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(C){var D=(C.element().id=="action_choose0")?0:1;var A=$("action_choose"+D);var B=$F(A);A.selectedIndex=0;if(B=="create_folder"){createMailbox()}else{if(B=="rebuild_tree"){submitAction(B)}else{if(!getChecked().size()){if(B!=""){alert(IMP.text.folders_select)}}else{if(B=="rename_folder"){renameMailbox()}else{if(B=="subscribe_folder"||B=="unsubscribe_folder"||B=="poll_folder"||B=="expunge_folder"||B=="nopoll_folder"||B=="mark_folder_seen"||B=="mark_folder_unseen"||B=="delete_folder_confirm"||B=="folders_empty_mailbox_confirm"||B=="mbox_size"){submitAction(B)}else{if(B=="download_folder"||B=="download_folder_zip"){downloadMailbox(B)}else{if(B=="import_mbox"){if(getChecked().length>1){alert(IMP.text.folders_oneselect)}else{submitAction(B)}}}}}}}}}function submitAction(A){$("actionID").setValue(A);$("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,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)}});