-d=[],e="";if(this.env.cid)d.push(this.env.cid);else{for(var f=0;f<a.length;f++){b=a[f];d.push(b);this.contact_list.remove_row(b,f==a.length-1)}a.length==1&&this.show_contentframe(false)}if(this.env.search_request)e+="&_search="+this.env.search_request;this.http_post("delete","_cid="+urlencode(d.join(","))+"&_source="+urlencode(this.env.source)+"&_from="+(this.env.action?this.env.action:"")+e);return true}};this.update_contact_row=function(a,b,d){var e;if(this.contact_list.rows[a]&&(e=this.contact_list.rows[a].obj)){for(var f=
-0;f<b.length;f++)e.cells[f]&&$(e.cells[f]).html(b[f]);if(d){e.id="rcmrow"+d;this.contact_list.remove_row(a);this.contact_list.init_row(e);this.contact_list.selection[0]=d;e.style.display=""}return true}return false};this.add_contact_row=function(a,b){if(!this.gui_objects.contactslist||!this.gui_objects.contactslist.tBodies[0])return false;var d=this.gui_objects.contactslist.tBodies[0].rows.length%2,e=document.createElement("tr");e.id="rcmrow"+a;e.className="contact "+(d?"even":"odd");if(this.contact_list.in_selection(a))e.className+=
-" selected";for(var f in b){col=document.createElement("td");col.className=String(f).toLowerCase();col.innerHTML=b[f];e.appendChild(col)}this.contact_list.insert_row(e);this.enable_command("export",this.contact_list.rowcount>0)};this.group_create=function(){if(this.gui_objects.folderlist&&this.env.address_sources[this.env.source].groups){if(!this.name_input){this.name_input=$("<input>").attr("type","text");this.name_input.bind("keydown",function(a){return rcmail.add_input_keydown(a)});this.name_input_li=
-$("<li>").addClass("contactgroup").append(this.name_input);this.name_input_li.insertAfter(this.get_folder_li(this.env.source))}this.name_input.select().focus()}};this.group_rename=function(){if(this.env.group&&this.gui_objects.folderlist){if(!this.name_input){this.enable_command("list","listgroup",false);this.name_input=$("<input>").attr("type","text").val(this.env.contactgroups["G"+this.env.source+this.env.group].name);this.name_input.bind("keydown",function(d){return rcmail.add_input_keydown(d)});
-this.env.group_renaming=true;var a,b=this.get_folder_li(this.env.source+this.env.group,"rcmliG");if(b&&(a=b.firstChild))$(a).hide().before(this.name_input)}this.name_input.select().focus()}};this.group_delete=function(){this.env.group&&this.http_post("group-delete","_source="+urlencode(this.env.source)+"&_gid="+urlencode(this.env.group),true)};this.remove_group_item=function(a){var b,d="G"+a.source+a.id;if(b=this.get_folder_li(d)){this.triggerEvent("group_delete",{source:a.source,id:a.id,li:b});b.parentNode.removeChild(b);
-delete this.env.contactfolders[d];delete this.env.contactgroups[d]}this.list_contacts(a.source,0)};this.add_input_keydown=function(a){a=rcube_event.get_keycode(a);if(a==13){if(a=this.name_input.val()){var b=this.set_busy(true,"loading");this.env.group_renaming?this.http_post("group-rename","_source="+urlencode(this.env.source)+"&_gid="+urlencode(this.env.group)+"&_name="+urlencode(a),b):this.http_post("group-create","_source="+urlencode(this.env.source)+"&_name="+urlencode(a),b)}return false}else a==
-27&&this.reset_add_input();return true};this.reset_add_input=function(){if(this.name_input){if(this.env.group_renaming){this.name_input.parent().children().last().show();this.env.group_renaming=false}this.name_input.remove();this.name_input_li&&this.name_input_li.remove();this.name_input=this.name_input_li=null}this.enable_command("list","listgroup",true)};this.insert_contact_group=function(a){this.reset_add_input();a.type="group";var b="G"+a.source+a.id;this.env.contactfolders[b]=this.env.contactgroups[b]=
-a;var d=$("<a>").attr("href","#").bind("click",function(){return rcmail.command("listgroup",a,this)}).html(a.name);b=$("<li>").attr("id","rcmli"+b).addClass("contactgroup").append(d).insertAfter(this.get_folder_li(a.source));this.triggerEvent("group_insert",{id:a.id,source:a.source,name:a.name,li:b[0]})};this.update_contact_group=function(a){this.reset_add_input();var b="G"+a.source+a.id,d,e=this.get_folder_li(b);if(e&&(d=e.firstChild)&&d.tagName.toLowerCase()=="a")d.innerHTML=a.name;this.env.contactfolders[b].name=
-this.env.contactgroups[b].name=a.name;this.triggerEvent("group_update",{id:a.id,source:a.source,name:a.name,li:e[0]})};this.init_subscription_list=function(){var a=this;this.subscription_list=new rcube_list_widget(this.gui_objects.subscriptionlist,{multiselect:false,draggable:true,keyboard:false,toggleselect:true});this.subscription_list.addEventListener("select",function(b){a.subscription_select(b)});this.subscription_list.addEventListener("dragstart",function(){a.drag_active=true});this.subscription_list.addEventListener("dragend",
-function(b){a.subscription_move_folder(b)});this.subscription_list.row_init=function(b){b.obj.onmouseover=function(){a.focus_subscription(b.id)};b.obj.onmouseout=function(){a.unfocus_subscription(b.id)}};this.subscription_list.init()};this.section_select=function(a){if(a=a.get_single_selection()){var b="",d=window;this.set_busy(true);if(this.env.contentframe&&window.frames&&window.frames[this.env.contentframe]){b="&_framed=1";d=window.frames[this.env.contentframe]}d.location.href=this.env.comm_path+
-"&_action=edit-prefs&_section="+a+b}return true};this.identity_select=function(a){if(a=a.get_single_selection())this.load_identity(a,"edit-identity")};this.load_identity=function(a,b){if(b=="edit-identity"&&(!a||a==this.env.iid))return false;var d="",e=window;if(this.env.contentframe&&window.frames&&window.frames[this.env.contentframe]){d="&_framed=1";e=window.frames[this.env.contentframe];document.getElementById(this.env.contentframe).style.visibility="inherit"}if(b&&(a||b=="add-identity")){this.set_busy(true);
-e.location.href=this.env.comm_path+"&_action="+b+"&_iid="+a+d}return true};this.delete_identity=function(a){var b=this.identity_list.get_selection();if(b.length||this.env.iid){a||(a=this.env.iid?this.env.iid:b[0]);this.goto_url("delete-identity","_iid="+a+"&_token="+this.env.request_token,true);return true}};this.focus_subscription=function(a){var b,d,e=RegExp.escape(this.env.delimiter),f=RegExp("["+e+"]?[^"+e+"]+$");if(this.drag_active&&this.env.mailbox&&(b=document.getElementById(a)))if(this.env.subscriptionrows[a]&&
-(d=this.env.subscriptionrows[a][0])){if(this.check_droptarget(d)&&!this.env.subscriptionrows[this.get_folder_row_id(this.env.mailbox)][2]&&d!=this.env.mailbox.replace(f,"")&&!d.match(RegExp("^"+RegExp.escape(this.env.mailbox+this.env.delimiter)))){this.set_env("dstfolder",d);$(b).addClass("droptarget")}}else if(this.env.mailbox.match(RegExp(e))){this.set_env("dstfolder",this.env.delimiter);$(this.subscription_list.frame).addClass("droptarget")}};this.unfocus_subscription=function(a){var b=$("#"+a);
-this.set_env("dstfolder",null);this.env.subscriptionrows[a]&&b[0]?b.removeClass("droptarget"):$(this.subscription_list.frame).removeClass("droptarget")};this.subscription_select=function(a){var b,d;if(a&&(b=a.get_single_selection())&&(d=this.env.subscriptionrows["rcmrow"+b])){this.set_env("mailbox",d[0]);this.show_folder(d[0]);this.enable_command("delete-folder",!d[2])}else{this.env.mailbox=null;this.show_contentframe(false);this.enable_command("delete-folder","purge",false)}};this.subscription_move_folder=
-function(){var a=RegExp.escape(this.env.delimiter),b=RegExp("["+a+"]?[^"+a+"]+$");if(this.env.mailbox&&this.env.dstfolder&&this.env.dstfolder!=this.env.mailbox&&this.env.dstfolder!=this.env.mailbox.replace(b,"")){b=RegExp("[^"+a+"]*["+a+"]","g");a=this.set_busy(true,"foldermoving");b=this.env.mailbox.replace(b,"");b=this.env.dstfolder==this.env.delimiter?b:this.env.dstfolder+this.env.delimiter+b;this.http_post("rename-folder","_folder_oldname="+urlencode(this.env.mailbox)+"&_folder_newname="+urlencode(b),
-a)}this.drag_active=false;this.unfocus_subscription(this.get_folder_row_id(this.env.dstfolder))};this.create_folder=function(){this.show_folder("",this.env.mailbox)};this.delete_folder=function(a){if((a=this.env.subscriptionrows[this.get_folder_row_id(a?a:this.env.mailbox)][0])&&confirm(this.get_label("deletefolderconfirm"))){var b=this.set_busy(true,"folderdeleting");this.http_post("delete-folder","_mbox="+urlencode(a),b)}};this.add_folder_row=function(a,b,d,e){if(!this.gui_objects.subscriptionlist)return false;
-var f,g;for(g in this.env.subscriptionrows)if(this.env.subscriptionrows[g]!=null&&!this.env.subscriptionrows[g][2]){f=g;break}var h;g=this.gui_objects.subscriptionlist.tBodies[0];var k="rcmrow"+(g.childNodes.length+1),j=this.subscription_list.get_single_selection();if(d&&d.id)f=k=d.id;if(!k||!f||!(h=document.getElementById(f))){this.goto_url("folders");return false}f=this.clone_table_row(h);f.id=k;e&&(e=this.get_folder_row_id(e))?g.insertBefore(f,document.getElementById(e)):g.appendChild(f);d&&g.removeChild(d);
-this.env.subscriptionrows[f.id]=[a,b,0];f.cells[0].innerHTML=b;if(!d){f.cells[1].innerHTML="*";$('input[name="_subscribed[]"]',f).val(a).attr("checked",true)}this.init_subscription_list();j&&document.getElementById("rcmrow"+j)&&this.subscription_list.select_row(j);document.getElementById(k).scrollIntoView&&document.getElementById(k).scrollIntoView()};this.replace_folder_row=function(a,b,d,e){a=this.get_folder_row_id(a);a=document.getElementById(a);this.add_folder_row(b,d,a,e)};this.remove_folder_row=
-function(a){var b;if((a=this.get_folder_row_id(a))&&(b=document.getElementById(a)))b.style.display="none"};this.subscribe=function(a){if(a){var b=this.display_message(this.get_label("foldersubscribing"),"loading");this.http_post("subscribe","_mbox="+urlencode(a),b)}};this.unsubscribe=function(a){if(a){var b=this.display_message(this.get_label("folderunsubscribing"),"loading");this.http_post("unsubscribe","_mbox="+urlencode(a),b)}};this.get_folder_row_id=function(a){for(var b in this.env.subscriptionrows)if(this.env.subscriptionrows[b]&&
-this.env.subscriptionrows[b][0]==a)break;return b};this.clone_table_row=function(a){for(var b,d,e=document.createElement("tr"),f=0;f<a.cells.length;f++){b=a.cells[f];d=document.createElement("td");if(b.className)d.className=b.className;b.align&&d.setAttribute("align",b.align);d.innerHTML=b.innerHTML;e.appendChild(d)}return e};this.show_folder=function(a,b,d){var e=window;a="&_action=edit-folder&_mbox="+urlencode(a);if(b)a+="&_path="+urlencode(b);if(this.env.contentframe&&window.frames&&window.frames[this.env.contentframe]){e=
-window.frames[this.env.contentframe];a+="&_framed=1"}if(String(e.location.href).indexOf(a)>=0&&!d)this.show_contentframe(true);else{if(!this.env.frame_lock)(parent.rcmail?parent.rcmail:this).env.frame_lock=this.set_busy(true,"loading");e.location.href=this.env.comm_path+a}};this.folder_size=function(a){var b=this.set_busy(true,"loading");this.http_post("folder-size","_mbox="+urlencode(a),b)};this.folder_size_update=function(a){$("#folder-size").replaceWith(a)};this.set_page_buttons=function(){this.enable_command("nextpage",
-"lastpage",this.env.pagecount>this.env.current_page);this.enable_command("previouspage","firstpage",this.env.current_page>1)};this.init_buttons=function(){for(var a in this.buttons)if(typeof a=="string")for(var b=0;b<this.buttons[a].length;b++){var d=this.buttons[a][b],e=document.getElementById(d.id);if(e){var f=false;if(d.type=="image"){e=e.parentNode;f=true}e._command=a;e._id=d.id;if(d.sel){e.onmousedown=function(){return rcmail.button_sel(this._command,this._id)};e.onmouseup=function(){return rcmail.button_out(this._command,
-this._id)};if(f)(new Image).src=d.sel}if(d.over){e.onmouseover=function(){return rcmail.button_over(this._command,this._id)};e.onmouseout=function(){return rcmail.button_out(this._command,this._id)};if(f)(new Image).src=d.over}}}};this.set_button=function(a,b){var d,e,f=this.buttons[a];if(!f||!f.length)return false;for(var g=0;g<f.length;g++){d=f[g];if((e=document.getElementById(d.id))&&d.type=="image"&&!d.status){d.pas=e._original_src?e._original_src:e.src;if(e.runtimeStyle&&e.runtimeStyle.filter&&
-e.runtimeStyle.filter.match(/src=['"]([^'"]+)['"]/))d.pas=RegExp.$1}else if(e&&!d.status)d.pas=String(e.className);if(e&&d.type=="image"&&d[b]){d.status=b;e.src=d[b]}else if(e&&typeof d[b]!="undefined"){d.status=b;e.className=d[b]}if(e&&d.type=="input"){d.status=b;e.disabled=!b}}};this.set_alttext=function(a,b){if(this.buttons[a]&&this.buttons[a].length)for(var d,e,f,g=0;g<this.buttons[a].length;g++){d=this.buttons[a][g];e=document.getElementById(d.id);if(d.type=="image"&&e){e.setAttribute("alt",
-this.get_label(b));if((f=e.parentNode)&&f.tagName.toLowerCase()=="a")f.setAttribute("title",this.get_label(b))}else e&&e.setAttribute("title",this.get_label(b))}};this.button_over=function(a,b){var d,e,f=this.buttons[a];if(!f||!f.length)return false;for(var g=0;g<f.length;g++){d=f[g];if(d.id==b&&d.status=="act")if((e=document.getElementById(d.id))&&d.over)if(d.type=="image")e.src=d.over;else e.className=d.over}};this.button_sel=function(a,b){var d,e,f=this.buttons[a];if(f&&f.length)for(var g=0;g<
-f.length;g++){d=f[g];if(d.id==b&&d.status=="act"){if((e=document.getElementById(d.id))&&d.sel)if(d.type=="image")e.src=d.sel;else e.className=d.sel;this.buttons_sel[b]=a}}};this.button_out=function(a,b){var d,e,f=this.buttons[a];if(f&&f.length)for(var g=0;g<f.length;g++){d=f[g];if(d.id==b&&d.status=="act")if((e=document.getElementById(d.id))&&d.act)if(d.type=="image")e.src=d.act;else e.className=d.act}};this.set_pagetitle=function(a){if(a&&document.title)document.title=a};this.display_message=function(a,
-b){if(this.is_framed())return parent.rcmail.display_message(a,b);if(!this.gui_objects.message){if(b!="loading")this.pending_message=[a,b];return false}b=b?b:"notice";var d=this,e=a,f=b+(new Date).getTime(),g=this.message_time*(b=="error"||b=="warning"?2:1);if(b=="loading"){e="loading";g=this.env.request_timeout*1E3;a||(a=this.get_label("loading"))}if(this.messages[e]){this.messages[e].obj&&this.messages[e].obj.html(a);b=="loading"&&this.messages[e].labels.push({id:f,msg:a});this.messages[e].elements.push(f);
-window.setTimeout(function(){d.hide_message(f,b=="loading")},g);return f}var h=$("<div>").addClass(b).html(a).data("key",e);$(this.gui_objects.message).append(h).show();this.messages[e]={obj:h,elements:[f]};if(b=="loading")this.messages[e].labels=[{id:f,msg:a}];else h.click(function(){return d.hide_message(h)});window.setTimeout(function(){d.hide_message(f,b=="loading")},g);return f};this.hide_message=function(a,b){if(this.is_framed())return parent.rcmail.hide_message(a,b);var d,e,f,g,h=this.messages;
-if(typeof a=="object"){$(a)[b?"fadeOut":"hide"]();g=$(a).data("key");this.messages[g]&&delete this.messages[g]}else for(d in h)for(e in h[d].elements)if(h[d]&&h[d].elements[e]==a){h[d].elements.splice(e,1);if(h[d].elements.length){if(d=="loading")for(f in h[d].labels){if(h[d].labels[f].id==a)delete h[d].labels[f];else g=h[d].labels[f].msg;h[d].obj.html(g)}}else{h[d].obj[b?"fadeOut":"hide"]();delete h[d]}}};this.select_folder=function(a,b,d){if(this.gui_objects.folderlist){var e;if(e=this.get_folder_li(b,
-d))$(e).removeClass("selected").removeClass("unfocused");if(e=this.get_folder_li(a,d))$(e).removeClass("unfocused").addClass("selected");this.triggerEvent("selectfolder",{folder:a,old:b,prefix:d})}};this.get_folder_li=function(a,b){b||(b="rcmli");if(this.gui_objects.folderlist){a=String(a).replace(this.identifier_expr,"_");return document.getElementById(b+a)}return null};this.set_message_coltypes=function(a,b){this.env.coltypes=a;var d=this.gui_objects.messagelist?this.gui_objects.messagelist.tHead:
-null,e,f,g,h;if(d){if(b){f=document.createElement("thead");g=document.createElement("tr");c=0;for(h=b.length;c<h;c++){e=document.createElement("td");e.innerHTML=b[c].html;if(b[c].id)e.id=b[c].id;if(b[c].className)e.className=b[c].className;g.appendChild(e)}f.appendChild(g);d.parentNode.replaceChild(f,d)}g=0;for(h=this.env.coltypes.length;g<h;g++){f=this.env.coltypes[g];if((e=d.rows[0].cells[g])&&(f=="from"||f=="to")){e.id="rcm"+f;if(e.firstChild&&e.firstChild.tagName.toLowerCase()=="a"){e=e.firstChild;
-e.onclick=function(){return rcmail.command("sort",this.__col,this)};e.__col=f}e.innerHTML=this.get_label(f)}}}this.env.subject_col=null;this.env.flagged_col=null;this.env.status_col=null;if((g=$.inArray("subject",this.env.coltypes))>=0){this.set_env("subject_col",g);if(this.message_list)this.message_list.subject_col=g}if((g=$.inArray("flag",this.env.coltypes))>=0)this.set_env("flagged_col",g);if((g=$.inArray("status",this.env.coltypes))>=0)this.set_env("status_col",g);this.message_list.init_header()};
-this.set_rowcount=function(a){$(this.gui_objects.countdisplay).html(a);this.set_page_buttons()};this.set_mailboxname=function(a){if(this.gui_objects.mailboxname&&a)this.gui_objects.mailboxname.innerHTML=a};this.set_quota=function(a){if(a&&this.gui_objects.quotadisplay)typeof a=="object"&&a.type=="image"?this.percent_indicator(this.gui_objects.quotadisplay,a):$(this.gui_objects.quotadisplay).html(a)};this.set_unread_count=function(a,b,d){if(!this.gui_objects.mailboxlist)return false;this.env.unread_counts[a]=
-b;this.set_unread_count_display(a,d)};this.set_unread_count_display=function(a,b){var d,e,f,g,h,k;if(f=this.get_folder_li(a)){g=this.env.unread_counts[a]?this.env.unread_counts[a]:0;e=f.getElementsByTagName("a")[0];d=/\s+\([0-9]+\)$/i;h=0;if((k=f.getElementsByTagName("div")[0])&&k.className.match(/collapsed/))for(var j in this.env.unread_counts)if(j.indexOf(a+this.env.delimiter)==0)h+=this.env.unread_counts[j];if(g&&e.innerHTML.match(d))e.innerHTML=e.innerHTML.replace(d," ("+g+")");else if(g)e.innerHTML+=
-" ("+g+")";else e.innerHTML=e.innerHTML.replace(d,"");d=RegExp(RegExp.escape(this.env.delimiter)+"[^"+RegExp.escape(this.env.delimiter)+"]+$");a.match(d)&&this.set_unread_count_display(a.replace(d,""),false);g+h>0?$(f).addClass("unread"):$(f).removeClass("unread")}d=/^\([0-9]+\)\s+/i;if(b&&document.title){e="";e=String(document.title);e=g&&e.match(d)?e.replace(d,"("+g+") "):g?"("+g+") "+e:e.replace(d,"");this.set_pagetitle(e)}};this.new_message_focus=function(){this.env.framed&&window.parent?window.parent.focus():
-window.focus()};this.toggle_prefer_html=function(a){var b;if(b=document.getElementById("rcmfd_addrbook_show_images"))b.disabled=!a.checked};this.toggle_preview_pane=function(a){var b;if(b=document.getElementById("rcmfd_preview_pane_mark_read"))b.disabled=!a.checked};this.set_headers=function(a){this.gui_objects.all_headers_row&&this.gui_objects.all_headers_box&&a&&$(this.gui_objects.all_headers_box).html(a).show()};this.load_headers=function(a){if(!(!this.gui_objects.all_headers_row||!this.gui_objects.all_headers_box||
-!this.env.uid)){$(a).removeClass("show-headers").addClass("hide-headers");$(this.gui_objects.all_headers_row).show();a.onclick=function(){rcmail.hide_headers(a)};this.gui_objects.all_headers_box.innerHTML||this.http_post("headers","_uid="+this.env.uid,this.display_message(this.get_label("loading"),"loading"))}};this.hide_headers=function(a){if(this.gui_objects.all_headers_row&&this.gui_objects.all_headers_box){$(a).removeClass("hide-headers").addClass("show-headers");$(this.gui_objects.all_headers_row).hide();
-a.onclick=function(){rcmail.load_headers(a)}}};this.percent_indicator=function(a,b){if(!b||!a)return false;var d=b.width?b.width:this.env.indicator_width?this.env.indicator_width:100,e=b.height?b.height:this.env.indicator_height?this.env.indicator_height:14,f=b.percent?Math.abs(parseInt(b.percent)):0,g=parseInt(f/100*d),h=$(a).position();h.top=Math.max(0,h.top);this.env.indicator_width=d;this.env.indicator_height=e;if(g>d){g=d;f=100}if(b.title)b.title=this.get_label("quota")+": "+b.title;var k=$("<div>");
-k.css({position:"absolute",top:h.top,left:h.left,width:d+"px",height:e+"px",zIndex:100,lineHeight:e+"px"}).attr("title",b.title).addClass("quota_text").html(f+"%");var j=$("<div>");j.css({position:"absolute",top:h.top+1,left:h.left+1,width:g+"px",height:e+"px",zIndex:99});g=$("<div>");g.css({position:"absolute",top:h.top+1,left:h.left+1,width:d+"px",height:e+"px",zIndex:98}).addClass("quota_bg");if(f>=80){k.addClass(" quota_text_high");j.addClass("quota_high")}else if(f>=55){k.addClass(" quota_text_mid");
-j.addClass("quota_mid")}else{k.addClass(" quota_text_normal");j.addClass("quota_low")}$(a).html("").append(j).append(g).append(k);$("#quotaimg").attr("title",b.title)};this.html2plain=function(a,b){var d=this,e=this.set_busy(true,"converting");console.log("HTTP POST: ?_task=utils&_action=html2text");$.ajax({type:"POST",url:"?_task=utils&_action=html2text",data:a,contentType:"application/octet-stream",error:function(f,g,h){d.http_error(f,g,h,e)},success:function(f){d.set_busy(false,null,e);$(document.getElementById(b)).val(f);
-console.log(f)}})};this.plain2html=function(a,b){var d=this.set_busy(true,"converting");$(document.getElementById(b)).val("<pre>"+a+"</pre>");this.set_busy(false,null,d)};this.redirect=function(a,b){if(b||b===null)this.set_busy(true);if(this.env.framed&&window.parent)parent.location.href=a;else location.href=a};this.goto_url=function(a,b,d){var e=this.env.comm_path;b=b?"&"+b:"";if(a.match(/([a-z]+)\/([a-z-_]+)/)){a=RegExp.$2;e=e.replace(/\_task=[a-z]+/,"_task="+RegExp.$1)}this.redirect(e+"&_action="+
-a+b,d)};this.http_request=function(a,b,d){var e=this.env.comm_path;if(a.match(/([a-z]+)\/([a-z-_]+)/)){a=RegExp.$2;e=e.replace(/\_task=[a-z]+/,"_task="+RegExp.$1)}var f=this.triggerEvent("request"+a,b);if(typeof f!="undefined")if(f===false)return false;else b=f;e+="&_remote=1&_action="+a+(b?"&":"")+b;console.log("HTTP GET: "+e);$.ajax({type:"GET",url:e,data:{_unlock:d?d:0},dataType:"json",success:function(g){l.http_response(g)},error:function(g,h,k){rcmail.http_error(g,h,k,d)}})};this.http_post=function(a,
-b,d){var e=this.env.comm_path;if(a.match(/([a-z]+)\/([a-z-_]+)/)){a=RegExp.$2;e=e.replace(/\_task=[a-z]+/,"_task="+RegExp.$1)}e+="&_action="+a;if(b&&typeof b=="object"){b._remote=1;b._unlock=d?d:0}else b+=(b?"&":"")+"_remote=1"+(d?"&_unlock="+d:"");a=this.triggerEvent("request"+a,b);if(typeof a!="undefined")if(a===false)return false;else b=a;console.log("HTTP POST: "+e);$.ajax({type:"POST",url:e,data:b,dataType:"json",success:function(f){l.http_response(f)},error:function(f,g,h){rcmail.http_error(f,
-g,h,d)}})};this.http_response=function(a){if(a){a.unlock&&this.set_busy(false);this.triggerEvent("responsebefore",{response:a});this.triggerEvent("responsebefore"+a.action,{response:a});a.env&&this.set_env(a.env);if(typeof a.texts=="object")for(var b in a.texts)typeof a.texts[b]=="string"&&this.add_label(b,a.texts[b]);if(a.exec){console.log(a.exec);eval(a.exec)}if(a.callbacks&&a.callbacks.length)for(b=0;b<a.callbacks.length;b++)this.triggerEvent(a.callbacks[b][0],a.callbacks[b][1]);switch(a.action){case "delete":if(this.task==
-"addressbook"){b=this.contact_list.get_selection();this.enable_command("compose",b&&this.contact_list.rows[b]);this.enable_command("delete","edit",b&&this.contact_list.rows[b]&&this.env.address_sources&&!this.env.address_sources[this.env.source].readonly);this.enable_command("export",this.contact_list&&this.contact_list.rowcount>0)}case "moveto":if(this.env.action=="show"){this.enable_command(this.env.message_commands,true);this.env.list_post||this.enable_command("reply-list",false)}else this.task==
-"addressbook"&&this.triggerEvent("listupdate",{folder:this.env.source,rowcount:this.contact_list.rowcount});case "purge":case "expunge":if(this.task=="mail"){if(!this.env.messagecount){this.env.contentframe&&this.show_contentframe(false);this.enable_command(this.env.message_commands,"purge","expunge","select-all","select-none","sort","expand-all","expand-unread","collapse-all",false)}this.message_list&&this.triggerEvent("listupdate",{folder:this.env.mailbox,rowcount:this.message_list.rowcount})}break;
-case "check-recent":case "getunread":case "search":case "list":if(this.task=="mail"){this.enable_command("show","expunge","select-all","select-none","sort",this.env.messagecount>0);this.enable_command("purge",this.purge_mailbox_test());this.enable_command("expand-all","expand-unread","collapse-all",this.env.threading&&this.env.messagecount);if(a.action=="list"||a.action=="search"){this.msglist_select(this.message_list);this.triggerEvent("listupdate",{folder:this.env.mailbox,rowcount:this.message_list.rowcount})}}else if(this.task==
-"addressbook"){this.enable_command("export",this.contact_list&&this.contact_list.rowcount>0);if(a.action=="list"||a.action=="search"){this.enable_command("group-create",this.env.address_sources[this.env.source].groups&&!this.env.address_sources[this.env.source].readonly);this.enable_command("group-rename","group-delete",this.env.address_sources[this.env.source].groups&&this.env.group&&!this.env.address_sources[this.env.source].readonly);this.triggerEvent("listupdate",{folder:this.env.source,rowcount:this.contact_list.rowcount})}}}a.unlock&&
-this.hide_message(a.unlock);this.triggerEvent("responseafter",{response:a});this.triggerEvent("responseafter"+a.action,{response:a})}};this.http_error=function(a,b,d,e){b=a.statusText;this.set_busy(false,null,e);a.abort();b&&this.display_message(this.get_label("servererror")+" ("+b+")","error")};this.start_keepalive=function(){this._int&&clearInterval(this._int);if(this.env.keep_alive&&!this.env.framed&&this.task=="mail"&&this.gui_objects.mailboxlist)this._int=setInterval(function(){l.check_for_recent(false)},
-this.env.keep_alive*1E3);else if(this.env.keep_alive&&!this.env.framed&&this.task!="login"&&this.env.action!="print")this._int=setInterval(function(){l.send_keep_alive()},this.env.keep_alive*1E3)};this.send_keep_alive=function(){this.http_request("keep-alive","_t="+(new Date).getTime())};this.check_for_recent=function(a){if(!this.busy){var b,d="_t="+(new Date).getTime()+"&_mbox="+urlencode(this.env.mailbox);if(a){b=this.set_busy(true,"checkingmail");d+="&_refresh=1";this.start_keepalive()}if(this.gui_objects.messagelist)d+=
-"&_list=1";if(this.gui_objects.quotadisplay)d+="&_quota=1";if(this.env.search_request)d+="&_search="+this.env.search_request;this.http_request("check-recent",d,b)}};this.get_single_uid=function(){return this.env.uid?this.env.uid:this.message_list?this.message_list.get_single_selection():null};this.get_single_cid=function(){return this.env.cid?this.env.cid:this.contact_list?this.contact_list.get_single_selection():null};this.get_caret_pos=function(a){if(typeof a.selectionEnd!="undefined")return a.selectionEnd;
-else if(document.selection&&document.selection.createRange){var b=document.selection.createRange();if(b.parentElement()!=a)return 0;var d=b.duplicate();a.tagName=="TEXTAREA"?d.moveToElementText(a):d.expand("textedit");d.setEndPoint("EndToStart",b);b=d.text.length;return b<=a.value.length?b:-1}else return a.value.length};this.set_caret_pos=function(a,b){if(a.setSelectionRange)a.setSelectionRange(b,b);else if(a.createTextRange){var d=a.createTextRange();d.collapse(true);d.moveEnd("character",b);d.moveStart("character",
-b);d.select()}};this.lock_form=function(a,b){if(a&&a.elements){var d,e,f;if(b)this.disabled_form_elements=[];d=0;for(e=a.elements.length;d<e;d++){f=a.elements[d];if(f.type!="hidden")if(b&&f.disabled)this.disabled_form_elements.push(f);else if(b||$.inArray(f,this.disabled_form_elements)<0)f.disabled=b}}}}rcube_webmail.prototype.addEventListener=rcube_event_engine.prototype.addEventListener;rcube_webmail.prototype.removeEventListener=rcube_event_engine.prototype.removeEventListener;
+d=[],e="";if(this.env.cid)d.push(this.env.cid);else{for(var f=0;f<a.length;f++){b=a[f];d.push(b);this.contact_list.remove_row(b,f==a.length-1)}a.length==1&&this.show_contentframe(false)}if(this.env.group)e+="&_gid="+urlencode(this.env.group);if(this.env.search_request)e+="&_search="+this.env.search_request;this.http_post("delete","_cid="+urlencode(d.join(","))+"&_source="+urlencode(this.env.source)+"&_from="+(this.env.action?this.env.action:"")+e);return true}};this.update_contact_row=function(a,
+b,d){var e;if(this.contact_list.rows[a]&&(e=this.contact_list.rows[a].obj)){for(var f=0;f<b.length;f++)e.cells[f]&&$(e.cells[f]).html(b[f]);if(d){e.id="rcmrow"+d;this.contact_list.remove_row(a);this.contact_list.init_row(e);this.contact_list.selection[0]=d;e.style.display=""}return true}return false};this.add_contact_row=function(a,b){if(!this.gui_objects.contactslist||!this.gui_objects.contactslist.tBodies[0])return false;var d=this.gui_objects.contactslist.tBodies[0].rows.length%2,e=document.createElement("tr");
+e.id="rcmrow"+a;e.className="contact "+(d?"even":"odd");if(this.contact_list.in_selection(a))e.className+=" selected";for(var f in b){col=document.createElement("td");col.className=String(f).toLowerCase();col.innerHTML=b[f];e.appendChild(col)}this.contact_list.insert_row(e);this.enable_command("export",this.contact_list.rowcount>0)};this.group_create=function(){if(this.gui_objects.folderlist&&this.env.address_sources[this.env.source].groups){if(!this.name_input){this.name_input=$("<input>").attr("type",
+"text");this.name_input.bind("keydown",function(a){return rcmail.add_input_keydown(a)});this.name_input_li=$("<li>").addClass("contactgroup").append(this.name_input);this.name_input_li.insertAfter(this.get_folder_li(this.env.source))}this.name_input.select().focus()}};this.group_rename=function(){if(this.env.group&&this.gui_objects.folderlist){if(!this.name_input){this.enable_command("list","listgroup",false);this.name_input=$("<input>").attr("type","text").val(this.env.contactgroups["G"+this.env.source+
+this.env.group].name);this.name_input.bind("keydown",function(d){return rcmail.add_input_keydown(d)});this.env.group_renaming=true;var a,b=this.get_folder_li(this.env.source+this.env.group,"rcmliG");if(b&&(a=b.firstChild))$(a).hide().before(this.name_input)}this.name_input.select().focus()}};this.group_delete=function(){this.env.group&&this.http_post("group-delete","_source="+urlencode(this.env.source)+"&_gid="+urlencode(this.env.group),true)};this.remove_group_item=function(a){var b,d="G"+a.source+
+a.id;if(b=this.get_folder_li(d)){this.triggerEvent("group_delete",{source:a.source,id:a.id,li:b});b.parentNode.removeChild(b);delete this.env.contactfolders[d];delete this.env.contactgroups[d]}this.list_contacts(a.source,0)};this.add_input_keydown=function(a){a=rcube_event.get_keycode(a);if(a==13){if(a=this.name_input.val()){var b=this.set_busy(true,"loading");this.env.group_renaming?this.http_post("group-rename","_source="+urlencode(this.env.source)+"&_gid="+urlencode(this.env.group)+"&_name="+urlencode(a),
+b):this.http_post("group-create","_source="+urlencode(this.env.source)+"&_name="+urlencode(a),b)}return false}else a==27&&this.reset_add_input();return true};this.reset_add_input=function(){if(this.name_input){if(this.env.group_renaming){this.name_input.parent().children().last().show();this.env.group_renaming=false}this.name_input.remove();this.name_input_li&&this.name_input_li.remove();this.name_input=this.name_input_li=null}this.enable_command("list","listgroup",true)};this.insert_contact_group=
+function(a){this.reset_add_input();a.type="group";var b="G"+a.source+a.id;this.env.contactfolders[b]=this.env.contactgroups[b]=a;var d=$("<a>").attr("href","#").bind("click",function(){return rcmail.command("listgroup",a,this)}).html(a.name);b=$("<li>").attr("id","rcmli"+b).addClass("contactgroup").append(d).insertAfter(this.get_folder_li(a.source));this.triggerEvent("group_insert",{id:a.id,source:a.source,name:a.name,li:b[0]})};this.update_contact_group=function(a){this.reset_add_input();var b="G"+
+a.source+a.id,d,e=this.get_folder_li(b);if(e&&(d=e.firstChild)&&d.tagName.toLowerCase()=="a")d.innerHTML=a.name;this.env.contactfolders[b].name=this.env.contactgroups[b].name=a.name;this.triggerEvent("group_update",{id:a.id,source:a.source,name:a.name,li:e[0]})};this.init_subscription_list=function(){var a=this;this.subscription_list=new rcube_list_widget(this.gui_objects.subscriptionlist,{multiselect:false,draggable:true,keyboard:false,toggleselect:true});this.subscription_list.addEventListener("select",
+function(b){a.subscription_select(b)});this.subscription_list.addEventListener("dragstart",function(){a.drag_active=true});this.subscription_list.addEventListener("dragend",function(b){a.subscription_move_folder(b)});this.subscription_list.row_init=function(b){b.obj.onmouseover=function(){a.focus_subscription(b.id)};b.obj.onmouseout=function(){a.unfocus_subscription(b.id)}};this.subscription_list.init()};this.section_select=function(a){if(a=a.get_single_selection()){var b="",d=window;this.set_busy(true);
+if(this.env.contentframe&&window.frames&&window.frames[this.env.contentframe]){b="&_framed=1";d=window.frames[this.env.contentframe]}d.location.href=this.env.comm_path+"&_action=edit-prefs&_section="+a+b}return true};this.identity_select=function(a){if(a=a.get_single_selection())this.load_identity(a,"edit-identity")};this.load_identity=function(a,b){if(b=="edit-identity"&&(!a||a==this.env.iid))return false;var d="",e=window;if(this.env.contentframe&&window.frames&&window.frames[this.env.contentframe]){d=
+"&_framed=1";e=window.frames[this.env.contentframe];document.getElementById(this.env.contentframe).style.visibility="inherit"}if(b&&(a||b=="add-identity")){this.set_busy(true);e.location.href=this.env.comm_path+"&_action="+b+"&_iid="+a+d}return true};this.delete_identity=function(a){var b=this.identity_list.get_selection();if(b.length||this.env.iid){a||(a=this.env.iid?this.env.iid:b[0]);this.goto_url("delete-identity","_iid="+a+"&_token="+this.env.request_token,true);return true}};this.focus_subscription=
+function(a){var b,d,e=RegExp.escape(this.env.delimiter),f=RegExp("["+e+"]?[^"+e+"]+$");if(this.drag_active&&this.env.mailbox&&(b=document.getElementById(a)))if(this.env.subscriptionrows[a]&&(d=this.env.subscriptionrows[a][0])){if(this.check_droptarget(d)&&!this.env.subscriptionrows[this.get_folder_row_id(this.env.mailbox)][2]&&d!=this.env.mailbox.replace(f,"")&&!d.match(RegExp("^"+RegExp.escape(this.env.mailbox+this.env.delimiter)))){this.set_env("dstfolder",d);$(b).addClass("droptarget")}}else if(this.env.mailbox.match(RegExp(e))){this.set_env("dstfolder",
+this.env.delimiter);$(this.subscription_list.frame).addClass("droptarget")}};this.unfocus_subscription=function(a){var b=$("#"+a);this.set_env("dstfolder",null);this.env.subscriptionrows[a]&&b[0]?b.removeClass("droptarget"):$(this.subscription_list.frame).removeClass("droptarget")};this.subscription_select=function(a){var b,d;if(a&&(b=a.get_single_selection())&&(d=this.env.subscriptionrows["rcmrow"+b])){this.set_env("mailbox",d[0]);this.show_folder(d[0]);this.enable_command("delete-folder",!d[2])}else{this.env.mailbox=
+null;this.show_contentframe(false);this.enable_command("delete-folder","purge",false)}};this.subscription_move_folder=function(){var a=RegExp.escape(this.env.delimiter),b;if(this.env.mailbox&&this.env.dstfolder&&this.env.dstfolder!=this.env.mailbox&&this.env.dstfolder!=this.env.mailbox.replace(RegExp("["+a+"]?[^"+a+"]+$"),"")){b=RegExp("[^"+a+"]*["+a+"]","g");a=this.set_busy(true,"foldermoving");b=this.env.mailbox.replace(b,"");b=this.env.dstfolder==this.env.delimiter?b:this.env.dstfolder+this.env.delimiter+
+b;this.http_post("rename-folder","_folder_oldname="+urlencode(this.env.mailbox)+"&_folder_newname="+urlencode(b),a)}this.drag_active=false;this.unfocus_subscription(this.get_folder_row_id(this.env.dstfolder))};this.create_folder=function(){this.show_folder("",this.env.mailbox)};this.delete_folder=function(a){if((a=this.env.subscriptionrows[this.get_folder_row_id(a?a:this.env.mailbox)][0])&&confirm(this.get_label("deletefolderconfirm"))){var b=this.set_busy(true,"folderdeleting");this.http_post("delete-folder",
+"_mbox="+urlencode(a),b)}};this.add_folder_row=function(a,b,d,e){if(!this.gui_objects.subscriptionlist)return false;var f,g;for(g in this.env.subscriptionrows)if(this.env.subscriptionrows[g]!=null&&!this.env.subscriptionrows[g][2]){f=g;break}var h;g=this.gui_objects.subscriptionlist.tBodies[0];var k="rcmrow"+(g.childNodes.length+1),j=this.subscription_list.get_single_selection();if(d&&d.id)f=k=d.id;if(!k||!f||!(h=document.getElementById(f))){this.goto_url("folders");return false}f=this.clone_table_row(h);
+f.id=k;e&&(e=this.get_folder_row_id(e))?g.insertBefore(f,document.getElementById(e)):g.appendChild(f);d&&g.removeChild(d);this.env.subscriptionrows[f.id]=[a,b,0];f.cells[0].innerHTML=b;if(!d){f.cells[1].innerHTML="*";$('input[name="_subscribed[]"]',f).val(a).attr("checked",true)}this.init_subscription_list();j&&document.getElementById("rcmrow"+j)&&this.subscription_list.select_row(j);document.getElementById(k).scrollIntoView&&document.getElementById(k).scrollIntoView()};this.replace_folder_row=function(a,
+b,d,e){a=this.get_folder_row_id(a);a=document.getElementById(a);this.add_folder_row(b,d,a,e)};this.remove_folder_row=function(a){var b;if((a=this.get_folder_row_id(a))&&(b=document.getElementById(a)))b.style.display="none"};this.subscribe=function(a){if(a){var b=this.display_message(this.get_label("foldersubscribing"),"loading");this.http_post("subscribe","_mbox="+urlencode(a),b)}};this.unsubscribe=function(a){if(a){var b=this.display_message(this.get_label("folderunsubscribing"),"loading");this.http_post("unsubscribe",
+"_mbox="+urlencode(a),b)}};this.get_folder_row_id=function(a){for(var b in this.env.subscriptionrows)if(this.env.subscriptionrows[b]&&this.env.subscriptionrows[b][0]==a)break;return b};this.clone_table_row=function(a){for(var b,d,e=document.createElement("tr"),f=0;f<a.cells.length;f++){b=a.cells[f];d=document.createElement("td");if(b.className)d.className=b.className;b.align&&d.setAttribute("align",b.align);d.innerHTML=b.innerHTML;e.appendChild(d)}return e};this.show_folder=function(a,b,d){var e=
+window;a="&_action=edit-folder&_mbox="+urlencode(a);if(b)a+="&_path="+urlencode(b);if(this.env.contentframe&&window.frames&&window.frames[this.env.contentframe]){e=window.frames[this.env.contentframe];a+="&_framed=1"}if(String(e.location.href).indexOf(a)>=0&&!d)this.show_contentframe(true);else{if(!this.env.frame_lock)(parent.rcmail?parent.rcmail:this).env.frame_lock=this.set_busy(true,"loading");e.location.href=this.env.comm_path+a}};this.disable_subscription=function(a){(a=this.get_folder_row_id(a))&&
+$('input[name="_subscribed[]"]',$("#"+a)).attr("disabled",true)};this.folder_size=function(a){var b=this.set_busy(true,"loading");this.http_post("folder-size","_mbox="+urlencode(a),b)};this.folder_size_update=function(a){$("#folder-size").replaceWith(a)};this.set_page_buttons=function(){this.enable_command("nextpage","lastpage",this.env.pagecount>this.env.current_page);this.enable_command("previouspage","firstpage",this.env.current_page>1)};this.init_buttons=function(){for(var a in this.buttons)if(typeof a==
+"string")for(var b=0;b<this.buttons[a].length;b++){var d=this.buttons[a][b],e=document.getElementById(d.id);if(e){var f=false;if(d.type=="image"){e=e.parentNode;f=true}e._command=a;e._id=d.id;if(d.sel){e.onmousedown=function(){return rcmail.button_sel(this._command,this._id)};e.onmouseup=function(){return rcmail.button_out(this._command,this._id)};if(f)(new Image).src=d.sel}if(d.over){e.onmouseover=function(){return rcmail.button_over(this._command,this._id)};e.onmouseout=function(){return rcmail.button_out(this._command,
+this._id)};if(f)(new Image).src=d.over}}}};this.set_button=function(a,b){var d,e,f=this.buttons[a];if(!f||!f.length)return false;for(var g=0;g<f.length;g++){d=f[g];if((e=document.getElementById(d.id))&&d.type=="image"&&!d.status){d.pas=e._original_src?e._original_src:e.src;if(e.runtimeStyle&&e.runtimeStyle.filter&&e.runtimeStyle.filter.match(/src=['"]([^'"]+)['"]/))d.pas=RegExp.$1}else if(e&&!d.status)d.pas=String(e.className);if(e&&d.type=="image"&&d[b]){d.status=b;e.src=d[b]}else if(e&&typeof d[b]!=
+"undefined"){d.status=b;e.className=d[b]}if(e&&d.type=="input"){d.status=b;e.disabled=!b}}};this.set_alttext=function(a,b){if(this.buttons[a]&&this.buttons[a].length)for(var d,e,f,g=0;g<this.buttons[a].length;g++){d=this.buttons[a][g];e=document.getElementById(d.id);if(d.type=="image"&&e){e.setAttribute("alt",this.get_label(b));if((f=e.parentNode)&&f.tagName.toLowerCase()=="a")f.setAttribute("title",this.get_label(b))}else e&&e.setAttribute("title",this.get_label(b))}};this.button_over=function(a,
+b){var d,e,f=this.buttons[a];if(!f||!f.length)return false;for(var g=0;g<f.length;g++){d=f[g];if(d.id==b&&d.status=="act")if((e=document.getElementById(d.id))&&d.over)if(d.type=="image")e.src=d.over;else e.className=d.over}};this.button_sel=function(a,b){var d,e,f=this.buttons[a];if(f&&f.length)for(var g=0;g<f.length;g++){d=f[g];if(d.id==b&&d.status=="act"){if((e=document.getElementById(d.id))&&d.sel)if(d.type=="image")e.src=d.sel;else e.className=d.sel;this.buttons_sel[b]=a}}};this.button_out=function(a,
+b){var d,e,f=this.buttons[a];if(f&&f.length)for(var g=0;g<f.length;g++){d=f[g];if(d.id==b&&d.status=="act")if((e=document.getElementById(d.id))&&d.act)if(d.type=="image")e.src=d.act;else e.className=d.act}};this.set_pagetitle=function(a){if(a&&document.title)document.title=a};this.display_message=function(a,b){if(this.is_framed())return parent.rcmail.display_message(a,b);if(!this.gui_objects.message){if(b!="loading")this.pending_message=[a,b];return false}b=b?b:"notice";var d=this,e=a,f=b+(new Date).getTime(),
+g=this.message_time*(b=="error"||b=="warning"?2:1);if(b=="loading"){e="loading";g=this.env.request_timeout*1E3;a||(a=this.get_label("loading"))}if(this.messages[e]){this.messages[e].obj&&this.messages[e].obj.html(a);b=="loading"&&this.messages[e].labels.push({id:f,msg:a});this.messages[e].elements.push(f);window.setTimeout(function(){d.hide_message(f,b=="loading")},g);return f}var h=$("<div>").addClass(b).html(a).data("key",e);$(this.gui_objects.message).append(h).show();this.messages[e]={obj:h,elements:[f]};
+if(b=="loading")this.messages[e].labels=[{id:f,msg:a}];else h.click(function(){return d.hide_message(h)});window.setTimeout(function(){d.hide_message(f,b=="loading")},g);return f};this.hide_message=function(a,b){if(this.is_framed())return parent.rcmail.hide_message(a,b);var d,e,f,g,h=this.messages;if(typeof a=="object"){$(a)[b?"fadeOut":"hide"]();g=$(a).data("key");this.messages[g]&&delete this.messages[g]}else for(d in h)for(e in h[d].elements)if(h[d]&&h[d].elements[e]==a){h[d].elements.splice(e,
+1);if(h[d].elements.length){if(d=="loading")for(f in h[d].labels){if(h[d].labels[f].id==a)delete h[d].labels[f];else g=h[d].labels[f].msg;h[d].obj.html(g)}}else{h[d].obj[b?"fadeOut":"hide"]();delete h[d]}}};this.select_folder=function(a,b,d){if(this.gui_objects.folderlist){var e;if(e=this.get_folder_li(b,d))$(e).removeClass("selected").removeClass("unfocused");if(e=this.get_folder_li(a,d))$(e).removeClass("unfocused").addClass("selected");this.triggerEvent("selectfolder",{folder:a,old:b,prefix:d})}};
+this.get_folder_li=function(a,b){b||(b="rcmli");if(this.gui_objects.folderlist){a=String(a).replace(this.identifier_expr,"_");return document.getElementById(b+a)}return null};this.set_message_coltypes=function(a,b){this.env.coltypes=a;var d=this.gui_objects.messagelist?this.gui_objects.messagelist.tHead:null,e,f,g,h;if(d){if(b){f=document.createElement("thead");g=document.createElement("tr");c=0;for(h=b.length;c<h;c++){e=document.createElement("td");e.innerHTML=b[c].html;if(b[c].id)e.id=b[c].id;if(b[c].className)e.className=
+b[c].className;g.appendChild(e)}f.appendChild(g);d.parentNode.replaceChild(f,d);d=f}g=0;for(h=this.env.coltypes.length;g<h;g++){f=this.env.coltypes[g];if((e=d.rows[0].cells[g])&&(f=="from"||f=="to")){e.id="rcm"+f;if(e.firstChild&&e.firstChild.tagName.toLowerCase()=="a"){e=e.firstChild;e.onclick=function(){return rcmail.command("sort",this.__col,this)};e.__col=f}e.innerHTML=this.get_label(f)}}}this.env.subject_col=null;this.env.flagged_col=null;this.env.status_col=null;if((g=$.inArray("subject",this.env.coltypes))>=
+0){this.set_env("subject_col",g);if(this.message_list)this.message_list.subject_col=g}if((g=$.inArray("flag",this.env.coltypes))>=0)this.set_env("flagged_col",g);if((g=$.inArray("status",this.env.coltypes))>=0)this.set_env("status_col",g);this.message_list.init_header()};this.set_rowcount=function(a){$(this.gui_objects.countdisplay).html(a);this.set_page_buttons()};this.set_mailboxname=function(a){if(this.gui_objects.mailboxname&&a)this.gui_objects.mailboxname.innerHTML=a};this.set_quota=function(a){if(a&&
+this.gui_objects.quotadisplay)typeof a=="object"&&a.type=="image"?this.percent_indicator(this.gui_objects.quotadisplay,a):$(this.gui_objects.quotadisplay).html(a)};this.set_unread_count=function(a,b,d){if(!this.gui_objects.mailboxlist)return false;this.env.unread_counts[a]=b;this.set_unread_count_display(a,d)};this.set_unread_count_display=function(a,b){var d,e,f,g,h,k;if(f=this.get_folder_li(a)){g=this.env.unread_counts[a]?this.env.unread_counts[a]:0;e=f.getElementsByTagName("a")[0];d=/\s+\([0-9]+\)$/i;
+h=0;if((k=f.getElementsByTagName("div")[0])&&k.className.match(/collapsed/))for(var j in this.env.unread_counts)if(j.indexOf(a+this.env.delimiter)==0)h+=this.env.unread_counts[j];if(g&&e.innerHTML.match(d))e.innerHTML=e.innerHTML.replace(d," ("+g+")");else if(g)e.innerHTML+=" ("+g+")";else e.innerHTML=e.innerHTML.replace(d,"");d=RegExp(RegExp.escape(this.env.delimiter)+"[^"+RegExp.escape(this.env.delimiter)+"]+$");a.match(d)&&this.set_unread_count_display(a.replace(d,""),false);g+h>0?$(f).addClass("unread"):
+$(f).removeClass("unread")}d=/^\([0-9]+\)\s+/i;if(b&&document.title){e="";e=String(document.title);e=g&&e.match(d)?e.replace(d,"("+g+") "):g?"("+g+") "+e:e.replace(d,"");this.set_pagetitle(e)}};this.new_message_focus=function(){this.env.framed&&window.parent?window.parent.focus():window.focus()};this.toggle_prefer_html=function(a){var b;if(b=document.getElementById("rcmfd_addrbook_show_images"))b.disabled=!a.checked};this.toggle_preview_pane=function(a){var b;if(b=document.getElementById("rcmfd_preview_pane_mark_read"))b.disabled=
+!a.checked};this.set_headers=function(a){this.gui_objects.all_headers_row&&this.gui_objects.all_headers_box&&a&&$(this.gui_objects.all_headers_box).html(a).show()};this.load_headers=function(a){if(!(!this.gui_objects.all_headers_row||!this.gui_objects.all_headers_box||!this.env.uid)){$(a).removeClass("show-headers").addClass("hide-headers");$(this.gui_objects.all_headers_row).show();a.onclick=function(){rcmail.hide_headers(a)};this.gui_objects.all_headers_box.innerHTML||this.http_post("headers","_uid="+
+this.env.uid,this.display_message(this.get_label("loading"),"loading"))}};this.hide_headers=function(a){if(this.gui_objects.all_headers_row&&this.gui_objects.all_headers_box){$(a).removeClass("hide-headers").addClass("show-headers");$(this.gui_objects.all_headers_row).hide();a.onclick=function(){rcmail.load_headers(a)}}};this.percent_indicator=function(a,b){if(!b||!a)return false;var d=b.width?b.width:this.env.indicator_width?this.env.indicator_width:100,e=b.height?b.height:this.env.indicator_height?
+this.env.indicator_height:14,f=b.percent?Math.abs(parseInt(b.percent)):0,g=parseInt(f/100*d),h=$(a).position();h.top=Math.max(0,h.top);this.env.indicator_width=d;this.env.indicator_height=e;if(g>d){g=d;f=100}if(b.title)b.title=this.get_label("quota")+": "+b.title;var k=$("<div>");k.css({position:"absolute",top:h.top,left:h.left,width:d+"px",height:e+"px",zIndex:100,lineHeight:e+"px"}).attr("title",b.title).addClass("quota_text").html(f+"%");var j=$("<div>");j.css({position:"absolute",top:h.top+1,
+left:h.left+1,width:g+"px",height:e+"px",zIndex:99});g=$("<div>");g.css({position:"absolute",top:h.top+1,left:h.left+1,width:d+"px",height:e+"px",zIndex:98}).addClass("quota_bg");if(f>=80){k.addClass(" quota_text_high");j.addClass("quota_high")}else if(f>=55){k.addClass(" quota_text_mid");j.addClass("quota_mid")}else{k.addClass(" quota_text_normal");j.addClass("quota_low")}$(a).html("").append(j).append(g).append(k);$("#quotaimg").attr("title",b.title)};this.html2plain=function(a,b){var d=this,e=
+this.set_busy(true,"converting");console.log("HTTP POST: ?_task=utils&_action=html2text");$.ajax({type:"POST",url:"?_task=utils&_action=html2text",data:a,contentType:"application/octet-stream",error:function(f,g,h){d.http_error(f,g,h,e)},success:function(f){d.set_busy(false,null,e);$(document.getElementById(b)).val(f);console.log(f)}})};this.plain2html=function(a,b){var d=this.set_busy(true,"converting");$(document.getElementById(b)).val("<pre>"+a+"</pre>");this.set_busy(false,null,d)};this.redirect=
+function(a,b){if(b||b===null)this.set_busy(true);if(this.env.framed&&window.parent)parent.location.href=a;else location.href=a};this.goto_url=function(a,b,d){var e=this.env.comm_path;b=b?"&"+b:"";if(a.match(/([a-z]+)\/([a-z-_]+)/)){a=RegExp.$2;e=e.replace(/\_task=[a-z]+/,"_task="+RegExp.$1)}this.redirect(e+"&_action="+a+b,d)};this.http_request=function(a,b,d){var e=this.env.comm_path;if(a.match(/([a-z]+)\/([a-z-_]+)/)){a=RegExp.$2;e=e.replace(/\_task=[a-z]+/,"_task="+RegExp.$1)}var f=this.triggerEvent("request"+
+a,b);if(typeof f!="undefined")if(f===false)return false;else b=f;e+="&_remote=1&_action="+a+(b?"&":"")+b;console.log("HTTP GET: "+e);$.ajax({type:"GET",url:e,data:{_unlock:d?d:0},dataType:"json",success:function(g){l.http_response(g)},error:function(g,h,k){rcmail.http_error(g,h,k,d)}})};this.http_post=function(a,b,d){var e=this.env.comm_path;if(a.match(/([a-z]+)\/([a-z-_]+)/)){a=RegExp.$2;e=e.replace(/\_task=[a-z]+/,"_task="+RegExp.$1)}e+="&_action="+a;if(b&&typeof b=="object"){b._remote=1;b._unlock=
+d?d:0}else b+=(b?"&":"")+"_remote=1"+(d?"&_unlock="+d:"");a=this.triggerEvent("request"+a,b);if(typeof a!="undefined")if(a===false)return false;else b=a;console.log("HTTP POST: "+e);$.ajax({type:"POST",url:e,data:b,dataType:"json",success:function(f){l.http_response(f)},error:function(f,g,h){rcmail.http_error(f,g,h,d)}})};this.http_response=function(a){if(a){a.unlock&&this.set_busy(false);this.triggerEvent("responsebefore",{response:a});this.triggerEvent("responsebefore"+a.action,{response:a});a.env&&
+this.set_env(a.env);if(typeof a.texts=="object")for(var b in a.texts)typeof a.texts[b]=="string"&&this.add_label(b,a.texts[b]);if(a.exec){console.log(a.exec);eval(a.exec)}if(a.callbacks&&a.callbacks.length)for(b=0;b<a.callbacks.length;b++)this.triggerEvent(a.callbacks[b][0],a.callbacks[b][1]);switch(a.action){case "delete":if(this.task=="addressbook"){b=this.contact_list.get_selection();this.enable_command("compose",b&&this.contact_list.rows[b]);this.enable_command("delete","edit",b&&this.contact_list.rows[b]&&
+this.env.address_sources&&!this.env.address_sources[this.env.source].readonly);this.enable_command("export",this.contact_list&&this.contact_list.rowcount>0)}case "moveto":if(this.env.action=="show"){this.enable_command(this.env.message_commands,true);this.env.list_post||this.enable_command("reply-list",false)}else this.task=="addressbook"&&this.triggerEvent("listupdate",{folder:this.env.source,rowcount:this.contact_list.rowcount});case "purge":case "expunge":if(this.task=="mail"){if(!this.env.messagecount){this.env.contentframe&&
+this.show_contentframe(false);this.enable_command(this.env.message_commands,"purge","expunge","select-all","select-none","sort","expand-all","expand-unread","collapse-all",false)}this.message_list&&this.triggerEvent("listupdate",{folder:this.env.mailbox,rowcount:this.message_list.rowcount})}break;case "check-recent":case "getunread":case "search":case "list":if(this.task=="mail"){this.enable_command("show","expunge","select-all","select-none","sort",this.env.messagecount>0);this.enable_command("purge",
+this.purge_mailbox_test());this.enable_command("expand-all","expand-unread","collapse-all",this.env.threading&&this.env.messagecount);if(a.action=="list"||a.action=="search"){this.msglist_select(this.message_list);this.triggerEvent("listupdate",{folder:this.env.mailbox,rowcount:this.message_list.rowcount})}}else if(this.task=="addressbook"){this.enable_command("export",this.contact_list&&this.contact_list.rowcount>0);if(a.action=="list"||a.action=="search"){this.enable_command("group-create",this.env.address_sources[this.env.source].groups&&
+!this.env.address_sources[this.env.source].readonly);this.enable_command("group-rename","group-delete",this.env.address_sources[this.env.source].groups&&this.env.group&&!this.env.address_sources[this.env.source].readonly);this.triggerEvent("listupdate",{folder:this.env.source,rowcount:this.contact_list.rowcount})}}}a.unlock&&this.hide_message(a.unlock);this.triggerEvent("responseafter",{response:a});this.triggerEvent("responseafter"+a.action,{response:a})}};this.http_error=function(a,b,d,e){b=a.statusText;
+this.set_busy(false,null,e);a.abort();b&&this.display_message(this.get_label("servererror")+" ("+b+")","error")};this.start_keepalive=function(){this._int&&clearInterval(this._int);if(this.env.keep_alive&&!this.env.framed&&this.task=="mail"&&this.gui_objects.mailboxlist)this._int=setInterval(function(){l.check_for_recent(false)},this.env.keep_alive*1E3);else if(this.env.keep_alive&&!this.env.framed&&this.task!="login"&&this.env.action!="print")this._int=setInterval(function(){l.send_keep_alive()},
+this.env.keep_alive*1E3)};this.send_keep_alive=function(){this.http_request("keep-alive","_t="+(new Date).getTime())};this.check_for_recent=function(a){if(!this.busy){var b,d="_t="+(new Date).getTime()+"&_mbox="+urlencode(this.env.mailbox);if(a){b=this.set_busy(true,"checkingmail");d+="&_refresh=1";this.start_keepalive()}if(this.gui_objects.messagelist)d+="&_list=1";if(this.gui_objects.quotadisplay)d+="&_quota=1";if(this.env.search_request)d+="&_search="+this.env.search_request;this.http_request("check-recent",
+d,b)}};this.get_single_uid=function(){return this.env.uid?this.env.uid:this.message_list?this.message_list.get_single_selection():null};this.get_single_cid=function(){return this.env.cid?this.env.cid:this.contact_list?this.contact_list.get_single_selection():null};this.get_caret_pos=function(a){if(typeof a.selectionEnd!="undefined")return a.selectionEnd;else if(document.selection&&document.selection.createRange){var b=document.selection.createRange();if(b.parentElement()!=a)return 0;var d=b.duplicate();
+a.tagName=="TEXTAREA"?d.moveToElementText(a):d.expand("textedit");d.setEndPoint("EndToStart",b);b=d.text.length;return b<=a.value.length?b:-1}else return a.value.length};this.set_caret_pos=function(a,b){if(a.setSelectionRange)a.setSelectionRange(b,b);else if(a.createTextRange){var d=a.createTextRange();d.collapse(true);d.moveEnd("character",b);d.moveStart("character",b);d.select()}};this.lock_form=function(a,b){if(a&&a.elements){var d,e,f;if(b)this.disabled_form_elements=[];d=0;for(e=a.elements.length;d<
+e;d++){f=a.elements[d];if(f.type!="hidden")if(b&&f.disabled)this.disabled_form_elements.push(f);else if(b||$.inArray(f,this.disabled_form_elements)<0)f.disabled=b}}}}rcube_webmail.long_subject_title=function(l,a){if(!l.title){var b=$(l);if(b.width()+a*15>b.parent().width())l.title=b.html()}};rcube_webmail.prototype.addEventListener=rcube_event_engine.prototype.addEventListener;rcube_webmail.prototype.removeEventListener=rcube_event_engine.prototype.removeEventListener;