Index: trunk/expressoMail1_2/index.php
===================================================================
--- trunk/expressoMail1_2/index.php	(revision 7538)
+++ trunk/expressoMail1_2/index.php	(revision 7541)
@@ -332,5 +332,5 @@
 	$scripts = "js/abas.js," .
 				"js/main.min.js," .
-				"js/draw_api.js,";
+				"js/draw_api.min.js,";
 	
 	if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'])
Index: trunk/expressoMail1_2/js/draw_api.min.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.min.js	(revision 7541)
+++ trunk/expressoMail1_2/js/draw_api.min.js	(revision 7541)
@@ -0,0 +1,703 @@
+
+focusIn="";canMakeBox=true;fastSearch=false;selectedPagingMsgs={};allMsgsSelected=false;totalFolderMsgs=0;var jqXHR=new Array();var idattachbycontent=0;onceOpenedHeadersMessages={};var cache=new Array();var openTab={'type':[],'content_id':[],'imapUid':[],'countFile':[0,0,0,0,0,0,0,0,0,0],'imapBox':[],'toPreserve':[],'condition':[]};var autoSaveControl={'timer':[],'status':[]};var tabTypes={'new':4,'forward':6,'reply_with_history':7,'reply_to_all_with_history':8,'reply_without_history':9,'reply_to_all_without_history':10,'edit':5};var currentTab,numBox=0;function draw_tree_folders(folders){if(Element('dftree_tree_folders')){if(!expresso_offline){var update_tree_folders=function(data){draw_quota(data);var unseen_in_mailbox=0;var unseen_in_shared_folders=0;for(var i=0;i<data.length;i++){if(data[i].folder_unseen>0)
+{unseen_in_mailbox=parseInt(unseen_in_mailbox+data[i].folder_unseen);if(data[i].folder_id.indexOf('INBOX')!==0)
+unseen_in_shared_folders=parseInt(unseen_in_shared_folders+data[i].folder_unseen);}
+var folder_unseen=Element('dftree_'+data[i].folder_id+'_unseen');if((folder_unseen)&&(data[i].folder_unseen>0))
+{folder_unseen.innerHTML=data[i].folder_unseen;}
+else if(data[i].folder_unseen>0)
+{tree_folders.getNodeById(data[i].folder_id).alter({caption:lang_folder(data[i].folder_name)+'<font style=color:red>&nbsp(</font><span id="dftree_'+data[i].folder_id+'_unseen" style=color:red>'+data[i].folder_unseen+'</span><font style=color:red>)</font>'});tree_folders.getNodeById(data[i].folder_id)._refresh();}
+else if(data[i].folder_unseen<=0)
+{if(tree_folders.getNodeById(data[i].folder_id)){tree_folders.getNodeById(data[i].folder_id).alter({caption:lang_folder(data[i].folder_name)});tree_folders.getNodeById(data[i].folder_id)._refresh();}}
+if(data[i].folder_id==current_folder){var old_new_m=isNaN(parseInt(Element('new_m').innerHTML))?parseInt(Element('new_m').firstChild.innerHTML):parseInt(Element('new_m').innerHTML);Element('new_m').innerHTML=data[i].folder_unseen?'<font color="RED">'+data[i].folder_unseen+'</font>':0;draw_paging(Element('tot_m').innerHTML);}}
+var display_unseen_in_mailbox=tree_folders.getNodeById('root');display_unseen_in_mailbox.alter({caption:get_lang("My Folders")});display_unseen_in_mailbox._refresh();var display_unseen_in_shared_folders=tree_folders.getNodeById('user');if(display_unseen_in_shared_folders)
+{if(unseen_in_shared_folders)
+display_unseen_in_shared_folders.alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">'+unseen_in_shared_folders+'</span><font style=color:red>]</font> '+get_lang("Shared folders")});else
+display_unseen_in_shared_folders.alter({caption:get_lang("Shared folders")});display_unseen_in_shared_folders._refresh();}}
+cExecute("$this.imap_functions.get_folders_list&folder="+current_folder,update_tree_folders);}
+if(preferences.use_local_messages=="1"){var disabled_local_span=document.getElementById('llocal_disabledtree_folders');if(!expresso_mail_archive.enabled){if(typeof(tree_folders.getNodeById("local_disabled"))=='undefined'){var n_LocalDisabled=new dNode({id:"local_disabled",caption:get_lang('Offline'),onClick:"services_retry()",plusSign:false});tree_folders.add(n_LocalDisabled,'local_root');}
+tree_folders.getNodeById("local_disabled").alter({caption:get_lang('Offline'),onClick:"retry_local_folders()"});tree_folders.getNodeById("local_disabled")._refresh();if((disabled_local_span)&&(!document.getElementById('services_retry'))){disabled_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_services.png)";var service_retry=document.createElement("SPAN");service_retry.id='services_retry';service_retry.className='clean_trash';service_retry.style.cursor='pointer';service_retry.onclick=function(){services_retry();};service_retry.innerHTML="["+get_lang("Retry")+"]";service_retry.title="Reconectar ao Mail Archiver";service_retry.onmouseover=function(){service_retry.style.color="red";};service_retry.onmouseout=function(){service_retry.style.color="#666666";};disabled_local_span.parentNode.appendChild(service_retry);}
+else{if((!disabled_local_span)&&(!document.getElementById('services_retry'))){var n_LocalDisabled=new dNode({id:"local_disabled",caption:get_lang('Offline'),onClick:"services_retry()",plusSign:false});tree_folders.add(n_LocalDisabled,'local_root');var disabled_local_span=document.getElementById('llocal_disabledtree_folders');disabled_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_services.png)";var service_retry=document.createElement("SPAN");service_retry.id='services_retry';service_retry.className='clean_trash';service_retry.style.cursor='pointer';service_retry.onclick=function(){services_retry();};service_retry.innerHTML="["+get_lang("Retry")+"]";service_retry.title=get_lang("Reconect to MailArchiver services");service_retry.onmouseover=function(){service_retry.style.color="red";};service_retry.onmouseout=function(){service_retry.style.color="#666666";};disabled_local_span.parentNode.appendChild(service_retry);var div_ma_host=document.createElement('div');div_ma_host.id='div_login_ma_host';div_ma_host.style.position='absolute';div_ma_host.style.padding='0px';div_ma_host.style.margin='0px';div_ma_host.style.top='25px';div_ma_host.style.left='0px';div_ma_host.style.width='145px';div_ma_host.style.height='80px';div_ma_host.style.border='1px solid #CCCCCC';div_ma_host.style.backgroundColor='#F0F0F0';div_ma_host.style.fontWeight='normal';disabled_local_span.appendChild(div_ma_host);div_ma_host.innerHTML='<p><b>'+get_lang('In trouble?')+'</b></p><p>&rarr; '+get_lang('Try to access')+'<br/><a href="'+mail_archive_protocol+"://"+mail_archive_host+":"+mail_archive_port+'/admin" target="_blank" title="MailArchiver Admin">'+get_lang('MailArchiver admin console')+'.</p>';}
+else{var div_ma_host=document.createElement('div');div_ma_host.id='div_login_ma_host';div_ma_host.style.position='absolute';div_ma_host.style.padding='0px';div_ma_host.style.margin='0px';div_ma_host.style.top='25px';div_ma_host.style.left='0px';div_ma_host.style.width='145px';div_ma_host.style.height='80px';div_ma_host.style.border='1px solid #CCCCCC';div_ma_host.style.backgroundColor='#F0F0F0';div_ma_host.style.fontWeight='normal';disabled_local_span.appendChild(div_ma_host);div_ma_host.innerHTML='<p><b>'+get_lang('In trouble?')+'</b></p><p>&rarr; '+get_lang('Try to access')+'<br/><a href="'+mail_archive_protocol+"://"+mail_archive_host+":"+mail_archive_port+'/admin" target="_blank" title="MailArchiver Admin">'+get_lang('MailArchiver admin console')+'.</p>';}}}
+else{var services_retry_span=document.getElementById('services_retry');if(services_retry_span){var node_disabled_to_remove=document.getElementById('nlocal_disabledtree_folders');node_disabled_to_remove.parentNode.removeChild(node_disabled_to_remove);}
+var drawinginfo={treeObject:tree_folders,treeName:'tree_folders'};expresso_mail_archive.drawdata=drawinginfo;if(disabled_local_span)
+disabled_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_folder.png)";}}
+return;}
+else{if(!expresso_offline){tree_folders=new dFTree({name:'tree_folders'});var n_root=new dNode({id:'root',caption:get_lang("My Folders")});tree_folders.add(n_root,'anything');var unseen_in_mailbox=0;var unseen_in_shared_folders=0;for(var i=0;i<folders.length;i++){if(folders[i].folder_unseen>0)
+{unseen_in_mailbox=parseInt(unseen_in_mailbox+folders[i].folder_unseen);if(folders[i].folder_id.indexOf('INBOX')!==0)
+unseen_in_shared_folders=parseInt(unseen_in_shared_folders+folders[i].folder_unseen);var nn=new dNode({id:folders[i].folder_id,caption:lang_folder(folders[i].folder_name)+'<font style=color:red>&nbsp(</font><span id="dftree_'+folders[i].folder_id+'_unseen" style=color:red>'+folders[i].folder_unseen+'</span><font style=color:red>)</font>',onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')",plusSign:folders[i].folder_hasChildren});if(folders[i].folder_name.toLowerCase()=='inbox')
+Element('new_m').innerHTML='<font style="color:red">'+folders[i].folder_unseen+'</font>';}
+else
+var nn=new dNode({id:folders[i].folder_id,caption:lang_folder(folders[i].folder_name),onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')",plusSign:folders[i].folder_hasChildren});if(folders[i].folder_parent=='')
+folders[i].folder_parent='root';else if(folders[i].folder_parent=='user'){if(!tree_folders.getNodeById('user')){tmpFolderId=folders[i].folder_id.split(cyrus_delimiter).pop();var n_root_shared_folders=new dNode({id:'user',caption:get_lang("Shared folders"),plusSign:true});tree_folders.add(n_root_shared_folders,'root');}}
+tree_folders.add(nn,folders[i].folder_parent);}}
+if(preferences.use_local_messages=="1"){var root_local=new dNode({id:"local_root",caption:get_lang('local folders'),plusSign:true});tree_folders.add(root_local,"root");if(!expresso_mail_archive.enabled){var n_LocalDisabled=new dNode({id:"local_disabled",caption:get_lang('Offline'),onClick:"services_retry()",plusSign:false});tree_folders.add(n_LocalDisabled,'local_root');}
+else{var drawinginfo={treeObject:tree_folders,treeName:'tree_folders'};expresso_mail_archive.drawdata=drawinginfo;}}
+var handlerChannel=function(data){if(data==null||typeof(data)=='string')
+return;var root_rss=new dNode({id:"news_root",caption:get_lang('News')});tree_folders.add(root_rss,"root");for(i=0;i<data.length;i++)
+{var nodeNews=new dNode({id:"NEWS/"+data[i].name,caption:data[i].name,onClick:"open_rss('"+data[i].rss_url+"')",plusSign:0});tree_folders.add(nodeNews,"news_root");}
+var noden=document.getElementById('lnews_roottree_folders');noden.style.backgroundImage="url(templates/"+template+"/images/menu/rss.png)";}
+var trash_span=document.getElementById(mount_url_folder(["lINBOX",special_folders["Trash"]])+'tree_folders');var draft_span=document.getElementById(mount_url_folder(["lINBOX",special_folders["Drafts"]])+'tree_folders');var sent_span=document.getElementById(mount_url_folder(["lINBOX",special_folders["Sent"]])+'tree_folders');var spam_span=document.getElementById(mount_url_folder(["lINBOX",special_folders["Spam"]])+'tree_folders');var trash_local_span=document.getElementById('llocal_'+special_folders['Trash']+'tree_folders');var draft_local_span=document.getElementById('llocal_'+special_folders['Drafts']+'tree_folders');var sent_span_default=document.getElementById('llocal_'+special_folders['Sent']+'tree_folders');if(trash_span)
+trash_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_trash.png)";if(draft_span)
+draft_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_draft.png)"
+if(sent_span)
+sent_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";if(spam_span)
+spam_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_spam.png)";if(sent_span_default)
+sent_span_default.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";if(trash_local_span)
+trash_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_trash.png)";if(draft_local_span)
+draft_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_draft.png)"
+if(sent_span_default)
+sent_span_default.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";if((disabled_local_span)&&(!expresso_mail_archive.enabled)){disabled_local_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_services.png)";var div_ma_host=document.createElement('div');div_ma_host.id='div_login_ma_host';div_ma_host.style.position='absolute';div_ma_host.style.padding='0px';div_ma_host.style.margin='0px';div_ma_host.style.top='25px';div_ma_host.style.width='145px';div_ma_host.style.height='80px';div_ma_host.style.border='1px solid #CCCCCC';div_ma_host.style.backgroundColor='#F0F0F0';div_ma_host.style.fontWeight='normal';disabled_local_span.appendChild(div_ma_host);div_ma_host.innerHTML='<p><b>'+get_lang('In trouble?')+'</b></p><p>&rarr; '+get_lang('Try to access')+'<br/><a href="'+mail_archive_protocol+"://"+mail_archive_host+":"+mail_archive_port+'/admin" target="_blank" title="MailArchiver Admin">'+get_lang('MailArchiver admin console')+'.</p>';}
+draw_paging(Element('tot_m').innerHTML);if(document.getElementById(mount_url_folder(["nINBOX",special_folders["Trash"]])+"tree_folders"))
+{var trash=document.createElement("SPAN");trash.id='empty_trash';trash.className='clean_folder';trash.style.cursor='pointer';trash.onclick=function(){empty_trash_imap();};trash.innerHTML="["+get_lang("Clean")+"]";trash.title=get_lang("Empty trash");trash.onmouseover=function(){trash.style.color="red";};trash.onmouseout=function(){trash.style.color="#666666";};document.getElementById(mount_url_folder(["nINBOX",special_folders["Trash"]])+"tree_folders").appendChild(trash);}
+if(document.getElementById(mount_url_folder(["nINBOX",special_folders["Spam"]])+"tree_folders"))
+{var spam=document.createElement("SPAN");spam.id='empty_spam';spam.className='clean_folder';spam.style.cursor='pointer';spam.style.padding='0 0 0 6px';spam.onclick=function(){empty_spam_imap();};spam.innerHTML="["+get_lang("Clean")+"]";spam.title=get_lang("Empty Spam Folder");spam.onmouseover=function(){spam.style.color="red";};spam.onmouseout=function(){spam.style.color="#666666";};document.getElementById(mount_url_folder(["nINBOX",special_folders["Spam"]])+"tree_folders").appendChild(spam);}
+if(document.getElementById("nlocal_disabledtree_folders")&&(!expresso_mail_archive.enabled)&&(!document.getElementById('services_retry')))
+{var service_retry=document.createElement("SPAN");service_retry.id='services_retry';service_retry.className='clean_trash';service_retry.style.cursor='pointer';service_retry.onclick=function(){services_retry();};service_retry.innerHTML="["+get_lang("Retry")+"]";service_retry.title="Reconectar ao Mail Archiver";service_retry.onmouseover=function(){service_retry.style.color="red";};service_retry.onmouseout=function(){service_retry.style.color="#666666";};document.getElementById("nlocal_disabledtree_folders").appendChild(service_retry);}
+var display_unseen_in_mailbox=tree_folders.getNodeById('root');display_unseen_in_mailbox.alter({caption:get_lang("My Folders")});display_unseen_in_mailbox._refresh();var display_unseen_in_shared_folders=tree_folders.getNodeById('user');if(display_unseen_in_shared_folders)
+{if(unseen_in_shared_folders)
+display_unseen_in_shared_folders.alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">'+unseen_in_shared_folders+'</span><font style=color:red>]</font> '+get_lang("Shared folders")});else
+display_unseen_in_shared_folders.alter({caption:get_lang("Shared folders")});display_unseen_in_shared_folders._refresh();}}
+if(!expresso_offline){var folder_create="";var nm1="";if(tree_folders._folderPr.length>0){var nm_folder="";for(var i=0;i<tree_folders._folderPr.length;i++){nm_folder=tree_folders._folderPr[i].split(cyrus_delimiter);if(nm_folder[0]=="INBOX"){if(nm1==""){nm1=nm_folder[1];folder_create="INBOX"+cyrus_delimiter+nm_folder[1]+";";}else{if(nm1!=nm_folder[1]){folder_create+="INBOX"+cyrus_delimiter+nm_folder[1]+";";nm1=nm_folder[1];}}}}}}
+outOfficeVerify();}
+function draw_tree_labels(){labels=DataLayer.get('label',{criteria:{order:'name'}});if(!$("#MyMarckersList").length)
+var myLabels=$('#content_folders').append("<div id='MyMarckersList' class='acc-list list-label' ></div>").find("#MyMarckersList");else
+var myLabels=$("#MyMarckersList");myLabels.html("<div class='my-labels'>"+"<img src='../prototype/modules/mail/img/tag.png'/>"+"<a class='title-my-labels' tabindex='0' role='button' aria-expanded='false' title='"+get_lang("My Labels")+"'>"+get_lang("My Labels")+"</a>"+"<span class='status-list-labels ui-icon ui-icon-triangle-1-s'></span>"+"</div>").append(DataLayer.render("../prototype/modules/mail/templates/label_list.ejs",{labels:labels})).find("li.label-item").css({"background-color":"#ffffff","border-color":"#CCCCCC","color":"#444444"}).click(function(event,ui){if($(event.target).is('.square-color')){$(this).each(function(){configureLabels({selectedItem:$(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1]});var id_label_item=$(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1];$(".label-list-container .label-list").find(".label-item-"+id_label_item).trigger("click");});}else{var labelId=$(this).attr('class').match(/label-item-([\d]+[()a-zA-Z]*)/)[1];search_emails("UNDELETED KEYWORD \"$Label"+labelId+"\"");}}).find(".square-color").css("display","");$("#MyMarckersList a.title-my-labels").click(function(){if($("#MyMarckersList ul.label-list").css("display")=="none"){$("#MyMarckersList ul.label-list").show();}else{$("#MyMarckersList ul.label-list").hide();}
+$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-s");$('#MyMarckersList .status-list-labels').toggleClass("ui-icon-triangle-1-n");});if(!labels){$(".my-labels").hide();}}
+function draw_tree_local_folders(){if(preferences.use_local_messages=="1"){var local_folders_list=expresso_mail_archive.getFoldersList("");}}
+function update_local_box(){msg_range_end=(current_page*preferences.max_email_per_page);msg_range_begin=(msg_range_end-(preferences.max_email_per_page)+1);folder=get_current_folder();var msgs=expresso_local_messages.get_local_range_msgs(folder.substr(6),msg_range_begin,preferences.max_email_per_page,sort_box_type,sort_box_reverse,search_box_type,preferences.preview_msg_subject,preferences.preview_msg_tip);alternate_border(0);draw_box(msgs,folder,true);draw_paging(msgs.num_msgs);Element("tot_m").innerHTML=msgs.num_msgs;update_menu();}
+function update_menu(data){if(data&&data.imap_error)
+{if(preferences.use_local_messages==1&&expresso_local_messages.is_offline_installed){conf=confirm(get_lang("The expresso imap server is currently down, expresso noticed you have offline mail module installed, would you like to use it?"));if(conf){window.onresize=function(){var target=document.getElementById('divAppbox');target.style.height=document.body.clientHeight-83;}
+var target=document.getElementById('divAppbox');document.getElementById("divAppboxHeader").innerHTML="";target.style.height=document.body.clientHeight-83;expresso_local_messages.set_as_logged(account_id,0,true);target.innerHTML="<iframe src='offline.php?inside=1' width='100%' height='100%' frameBorder='0'></iframe>";return false;}}
+connector.newRequest('error.html','templates/'+template+'/error.html','GET',function(data)
+{var target=document.getElementById('divAppbox');if(target)
+target.innerHTML=data;});return false;}
+if(data){draw_tree_folders(data);draw_quota(data);var f_unseen=Element('dftree_'+current_folder+'_unseen');if(f_unseen&&f_unseen.innerHTML)
+Element('new_m').innerHTML='<font face="Verdana" size="1" color="RED">'+f_unseen.innerHTML+'</font>';else
+{if(parseInt(Element('new_m').innerHTML)==0)
+Element('new_m').innerHTML=0;}
+folders=data;}
+draw_new_tree_folder();draw_tree_labels();if(Element("table_quota"))
+connector.loadScript("InfoQuota");if(preferences.enable_quickadd_telephonenumber)
+connector.loadScript("QuickAddTelephone");}
+var handler_draw_box=function(data){draw_box(data,'INBOX',true);}
+function change_folder(folder,folder_name){if(openTab.imapBox[0]!=folder)
+{selectAllFolderMsgs(false);current_folder=folder;var handler_draw_box=function(data)
+{if(!verify_session(data))
+return;alternate_border(0);var title=lang_folder(folder_name);if(title.length>18)title=title.substring(0,18)+"...";Element("border_id_0").innerHTML="&nbsp;"+title+'&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">&nbsp;</span> / <span id="tot_m"></span>]</font>';draw_box(data,folder,true);draw_paging(data.num_msgs);Element("tot_m").innerHTML=data.num_msgs;$('#new_m').html(data.tot_unseen>0?data.tot_unseen:"0").css("color","red");$(".folders-loading").removeClass("folders-loading");return true;}
+if(/^local_messages/.test(current_folder)){$(".folders-loading").removeClass("folders-loading");}
+else{$.ajax({async:false,url:"controller.php?"+$.param({action:"$this.imap_functions.getMessagesIds",folder:folder,msg_range_begin:"0",msg_range_end:"0",sort_box_type:"SORTARRIVAL",search_box_type:search_box_type,sort_box_reverse:"1"}),success:function(data){data=connector.unserialize(data);if(data){var _data={};$.each(data,function(index,value){if(data[index]){_data[data[index]]=data[index];}});populateSelectedMsgs(_data);}},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort_box_type,search_box_type,sort_box_reverse,preferences.preview_msg_subject,preferences.preview_msg_tip,handler_draw_box);}
+else{$(".folders-loading").removeClass("folders-loading");alternate_border(0);}}
+function open_folder(folder,folder_name){if(current_folder!=folder){current_folder=folder;var handler_draw_box=function(data){if(!verify_session(data))
+return false;numBox++;create_border(folder_name,numBox.toString());draw_box(data,current_folder,false);alternate_border(numBox);return true;}
+cExecute("$this.imap_functions.get_range_msgs2&folder="+current_folder+"&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse+"",handler_draw_box);}
+else
+alternate_border(numBox);return true;}
+var lastPage=1;var numPages=5;var last_folder='INBOX';function draw_paging(num_msgs){num_msgs=parseInt(num_msgs);total_pages=1;if(last_folder!=current_folder){lastPage=1;current_page=1;last_folder=current_folder;}
+if(num_msgs>parseInt(preferences.max_email_per_page)){total_pages=parseInt(num_msgs/preferences.max_email_per_page);if((num_msgs/preferences.max_email_per_page)>total_pages)
+total_pages++;}
+if(total_pages==1){if(span_paging=document.getElementById("span_paging")){span_paging.parentNode.removeChild(span_paging);}
+return;}
+span_paging=document.getElementById("span_paging");if(!span_paging){span_paging=document.createElement("DIV");span_paging.id="span_paging";span_paging.className="boxHeaderText";span_paging.align="right";document.getElementById("div_menu_c3").appendChild(span_paging);}
+span_paging.style.width="100%";span_paging.innerHTML="";msg_range_begin=1;msg_range_end=preferences.max_email_per_page;if(current_page!=1){lnk_page=document.createElement("A");lnk_page.setAttribute("href","javascript:current_page=1; draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){alternate_border(0); draw_box(data, get_current_folder());});");}
+else{lnk_page=document.createElement("SPAN");}
+span_paging.appendChild(lnk_page);lnk_page.innerHTML="&lt;&lt;";lnk_page.title=get_lang("First");span_paging.innerHTML+="&nbsp;";if(current_page==lastPage+numPages)
+lastPage=current_page-1;else if((lastPage!=1&&lastPage==current_page)||current_page==total_pages)
+lastPage=current_page-(numPages-1);else if(current_page==1)
+lastPage=1;if(lastPage<1)
+lastPage=1;else if(lastPage>1&&(lastPage>(total_pages-(numPages-1))))
+lastPage=total_pages-(numPages-1);var hasMarked=false;for(i=lastPage;i<=total_pages;i++){if(current_page==i||(i==total_pages&&!hasMarked)){lnk_page=document.createElement("SPAN");span_paging.appendChild(lnk_page);lnk_page.style.color="red";lnk_page.innerHTML="&nbsp;<b>"+i+"</b>&nbsp;";hasMarked=true;continue;}
+else{lnk_page=document.createElement("A");span_paging.appendChild(lnk_page);msg_range_begin=((i*preferences.max_email_per_page)-(preferences.max_email_per_page-1));msg_range_end=(i*preferences.max_email_per_page);lnk_page.setAttribute("href","javascript:current_page="+i+"; draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){alternate_border(0); draw_box(data, get_current_folder());});");}
+lnk_page.innerHTML="&nbsp;...&nbsp;";if(i==(lastPage+numPages))
+break;else if(lastPage==1||i!=lastPage)
+lnk_page.innerHTML="&nbsp;"+i+"&nbsp;";span_paging.innerHTML+="&nbsp;";}
+if(current_page!=total_pages){lnk_page=document.createElement("A");msg_range_begin=((total_pages*preferences.max_email_per_page)-(preferences.max_email_per_page-1));msg_range_end=(total_pages*preferences.max_email_per_page);lnk_page.setAttribute("href","javascript:current_page="+total_pages+"; draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){alternate_border(0); draw_box(data, get_current_folder());});");}
+else{lnk_page=document.createElement("SPAN");}
+span_paging.innerHTML+="&nbsp;";span_paging.appendChild(lnk_page);lnk_page.title=get_lang("Last");lnk_page.innerHTML="&gt;&gt;";}
+var colSizes=[["3%","2%","1%","1%","1%","1%","2%","2%","2%","20%","45%","11%","11%"],["2%","1%","1%","1%","1%","1%","1%","20%","20%","33%","10%","9%"]];var colAligns=[['','','','','','','','left','left','center','center'],['','','','','','left','left','left','center','center']];var objCell=null;var adjCell=null;var cellClick=null;var cellResized=false;var maxWidth=0;var minWidth=0;var bodyWidth=0;var cssForResizing=false;function changeCursorState(ev){if(cellResized)
+cellResized=false;var el=ev.target||ev.srcElement;if(el.tagName!="TD")
+el=getFirstParentOfType(el,"TD")
+el.style.cursor="hand";el.style.cursor="pointer";if(!cssForResizing)
+return;var cellMouseX=(ev.clientX-parseInt(getColumnPosition(el,ev)));var cellWidth=el.offsetWidth;var tbl=getFirstParentOfType(el,"TABLE");if(tbl.emptyBody)
+return;if((((cellWidth-cellMouseX)<15)||((el.style.cursor=="col-resize")&&(detectLeftButton())))&&((el.className=="th_resizable")&&(el.cellIndex+1<el.parentNode.cells.length))){if(tbl)tbl.style.cursor="col-resize";el.style.cursor="col-resize";}
+else{if(tbl)tbl.style.cursor="pointer";el.style.cursor="hand";el.style.cursor="pointer";}}
+function getStyle(el,styleProp){var x=document.getElementById(el);if(x.currentStyle)
+var y=x.currentStyle[styleProp];else if(window.getComputedStyle)
+var y=document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);return y;}
+function resizeColumn(ev){if(!objCell||!adjCell){stopColResize(ev);return;}
+if(document.getElementById("table_message_header_box_"+numBox).emptyBody)
+return;if(objCell.style.cursor=="col-resize"&&detectLeftButton(ev)){var cellIndex=objCell.cellIndex;var adjIndex=adjCell.cellIndex;var cellOffset=parseInt(getColumnPosition(objCell,ev));var cellWidth=(ev.clientX-cellOffset);var tbl=getMessagesTable(objCell);var trM=tbl.rows;var tblType=((tbl.id=="table_box")?0:1);if(cellWidth<minWidth)
+cellWidth=minWidth;var adjWidth=maxWidth-cellWidth;if(adjWidth<minWidth){cellWidth=(cellWidth+adjWidth)-minWidth;adjWidth=minWidth;}
+colSizes[tblType][adjIndex]=(colSizes[tblType][adjIndex]=="*"?"*":getPct(is_ie?adjWidth:adjWidth-2));colSizes[tblType][cellIndex]=(colSizes[tblType][cellIndex]=="*"?"*":getPct(cellWidth));document.getElementById("table_message_ruler").style.left=cellOffset+cellWidth;}
+ev.returnValue=false;return(false);}
+function getPct(tdWidth){var suf=tdWidth.toString().substr(tdWidth.length-1,1);if(suf!="%"&&suf!="*")
+return(Math.round((tdWidth/bodyWidth)*10000)/100).toString()+"%";else
+return tdWidth;}
+function detectLeftButton(ev){ev=ev||window.event;var button=ev.which||ev.button;return(button==1);}
+function startColResize(ev){var el=ev.target||ev.srcElement;if(el.tagName!="TD")
+el=getFirstParentOfType(el,"TD")
+if(is_ie)
+ev.cancelBubble=true;else
+ev.stopPropagation();if(!el)return;if(!is_ie)ev.preventDefault();if(document.getElementById("table_message_header_box_"+numBox).emptyBody)
+return;if(el.style.cursor=="col-resize"&&detectLeftButton(ev)){var incIndex=((el.parentNode.cells.length>el.cellIndex+1)?1:-1);var msgTable=getMessagesTable(el);var bodyRows=msgTable.rows;objCell=el;adjCell=el.parentNode.cells[el.cellIndex+incIndex];var tbl=getFirstParentOfType(el,"TABLE");if(is_ie){tbl.detachEvent("onmousemove",changeCursorState);document.attachEvent("onmousemove",resizeColumn);document.attachEvent("onmouseup",stopColResize);document.attachEvent("onselect",selectCancel);tbl.attachEvent("onselectstart",selectCancel);}
+else{tbl.removeEventListener("mousemove",changeCursorState,false);document.addEventListener("mousemove",resizeColumn,false);document.addEventListener("mouseup",stopColResize,false);document.addEventListener("select",selectCancel,false);tbl.addEventListener("selectstart",selectCancel,false);}
+cellClick=objCell.onclick;objCell.onclick="";maxWidth=objCell.offsetWidth+adjCell.offsetWidth;bodyWidth=msgTable.offsetWidth;minWidth=Math.round(bodyWidth/80);document.getElementById("table_message_ruler").style.display="block";document.getElementById("table_message_ruler").style.left=ev.clientX;if(document.getElementById("content_id_"+numBox)==null)
+document.getElementById("table_message_ruler").style.height=document.getElementById("content_id_"+currentTab).offsetHeight;else
+document.getElementById("table_message_ruler").style.height=document.getElementById("content_id_"+numBox).offsetHeight;}}
+function stopColResize(ev){if(!objCell)
+return;if(is_ie)
+ev.cancelBubble=true;else
+ev.stopPropagation();var tbl=getFirstParentOfType(objCell,"TABLE");if(is_ie){tbl.detachEvent("onselectstart",selectCancel);document.detachEvent("onselect",selectCancel);document.detachEvent("onmousemove",resizeColumn);document.detachEvent("onmouseup",stopColResize);tbl.attachEvent("onmousemove",changeCursorState);}
+else{tbl.removeEventListener("selectstart",selectCancel,false);document.removeEventListener("select",selectCancel,false);document.removeEventListener("mousemove",resizeColumn,false);document.removeEventListener("mouseup",stopColResize,false);tbl.addEventListener("mousemove",changeCursorState,false);}
+var trM=getMessagesTable(objCell).rows;var adjIndex=adjCell.cellIndex;document.getElementById("table_message_ruler").style.display="none";maxWidth=0;objCell.onclick=cellClick;objCell=null;adjCell=null;cellResized=true;setColSizesCookie();syncColumns();}
+function getMessagesTable(el){var hT;if(el.tagName=="TABLE")
+hT=el;else
+hT=getFirstParentOfType(el,"TABLE");return(hT.parentNode.nextSibling.childNodes[0].className!=="local-messages-search-warning"?hT.parentNode.nextSibling.childNodes[0]:hT.parentNode.nextSibling.childNodes[1]);}
+function getColumnPosition(oNode,pNode){if(!pNode&&!is_webkit){var pos=getOffset(oNode);return[pos.left,pos.top];}
+pNode=pNode||document.body;var oCurrentNode=oNode;var iLeft=0;var iTop=0;while((oCurrentNode)&&(oCurrentNode!=pNode)){iLeft+=oCurrentNode.offsetLeft-oCurrentNode.scrollLeft;iTop+=oCurrentNode.offsetTop-oCurrentNode.scrollTop;oCurrentNode=oCurrentNode.offsetParent;}
+return[iLeft,iTop];}
+function getFirstParentOfType(obj,tag){while(obj&&obj.tagName!=tag&&obj.tagName!="BODY"){obj=obj.parentNode;}
+return obj;}
+function syncColumns(){var thisCell;var tbl=(document.getElementById("content_id_"+numBox)==null?1:0);if(objCell)
+thisCell=objCell;else
+thisCell=document.getElementById("table_message_header_box_"+numBox).rows[0].cells[0];var emptyBody=document.getElementById("table_message_header_box_"+numBox).emptyBody;var tbH=getFirstParentOfType(thisCell,"TABLE");var tbM=getMessagesTable(thisCell);var trM=tbM.rows;var _mouse_over;var _mouse_out;var _cell;for(var r=0;r<trM.length;r++){for(var c=0;c<trM[r].cells.length;c++){_cell=trM[r].cells[c];_cell.setAttribute("width",colSizes[tbl][c]);if(is_mozilla&&!is_webkit){if(!emptyBody){document.getElementById("colgroup_main_"+numBox).childNodes[c].setAttribute("width",colSizes[tbl][c]);}
+document.getElementById("colgroup_head_"+numBox).childNodes[c].setAttribute("width",colSizes[tbl][c]);if(tbH.rows[0].cells[c].className=="th_resizable"){if(_cell.childNodes&&_cell.childNodes.length>1){_mouse_over=_cell.childNodes[1].onmouseover;_mouse_out=_cell.childNodes[1].onmouseout;}
+_cell.innerHTML=trM[r].cells[c].innerHTML;if(_cell.childNodes&&_cell.childNodes.length>1){_cell.childNodes[1].onmouseover=_mouse_over;_cell.childNodes[1].onmouseout=_mouse_out;}
+tbH.rows[0].cells[c].innerHTML=tbH.rows[0].cells[c].innerHTML;}}}}
+if(is_mozilla&&!is_webkit){if(trM[r])
+for(var c=0;c<trM[r].cells.length;c++)
+document.getElementById("colgroup_main_"+numBox).childNodes[c].setAttribute("width",colSizes[tbl][c]);}
+if(is_webkit||is_ie){var arrHeader=$('.message_header td');var arrBody=$('#tbody_box :first td');for(i=0;i<arrHeader.length;i++){if(arrBody[i]!==undefined&&arrBody[i].width!==undefined)
+arrHeader[i].width=arrBody[i].width;}}}
+function resizeMailList(){if(document.getElementById("table_message_header_box_"+numBox)==null)
+return false;var innerWidth=(window.innerWidth?window.innerWidth:document.body.clientWidth);var scrollWidth=(innerWidth-20-getColumnPosition(Element("exmail_main_body"),"BODY")[0]);document.getElementById("table_message_header_box_"+numBox).style.width=(scrollWidth-2)+'px';if(document.getElementById("table_resultsearch_"+numBox)==null)
+document.getElementById("table_box").style.width=scrollWidth+'px';else
+document.getElementById("table_resultsearch_"+numBox).style.width=scrollWidth+'px';syncColumns();if(numBox>0){if(is_mozilla&&!is_webkit){$('#table_message_header_box_'+numBox).attr('style','width:99.5%');$('#colgroup_head_'+numBox).find('col').each(function(index,value){$(this).attr('width',colSizes[1][index]);});$('#colgroup_main_'+numBox).find('col').each(function(index,value){$(this).attr('width',colSizes[1][index]);});}
+else if(is_webkit){$('#table_message_header_box_'+numBox).removeAttr('style');$('#table_message_header_box_'+numBox).css('table-layout','auto');}
+else{$('#table_message_header_box_'+numBox).css('table-layout','auto');}
+$('#table_message_header_box_'+numBox).find('td').each(function(index,value){$(this).width(colSizes[1][index]);});$('#divScrollMain_'+numBox).find('tr:first').find('td').each(function(index,value){$(this).width(colSizes[1][index]);});}
+$('#table_resultsearch_'+numBox).removeAttr('style');}
+function selectCancel(ev){return(false);}
+function buildColGroup(tbl){var col_element;var colgr_element=document.createElement("COLGROUP");if(tbl==null)tbl=0;for(i=0;i<colSizes[tbl].length;i++){col_element=document.createElement("COL");col_element.setAttribute("align",colAligns[tbl][i]);colgr_element.appendChild(col_element);}
+return(colgr_element);}
+function createTDElement(table_list,col_index,class_name,td_align,td_id){var td_element=document.createElement("TD");td_element.setAttribute("width",colSizes[table_list][col_index]);if(class_name)td_element.className=class_name;if(td_align)td_element.align=td_align;if(td_id)td_element.id=td_id;return(td_element);}
+function prepareColSizesArray(){var colSizesCookie=getColSizesCookie();if(colSizesCookie){try{var colSizesA=colSizesCookie.split(":");colSizes=[colSizesA[0].split(","),colSizesA[1].split(",")];}
+catch(e){}}}
+function setColSizesCookie(){var str="maillist_colsizes="+colSizes[0].join()+":"+colSizes[1].join();var date=new Date();date.setTime(date.getTime()+(365*24*60*60*1000));str+=("; expires="+date.toGMTString());document.cookie=str;}
+function getColSizesCookie(){var search="maillist_colsizes=";if(document.cookie.length>0){var offset=document.cookie.indexOf(search);if(offset!=-1){offset+=search.length;var end=document.cookie.indexOf(";",offset);if(end==-1)
+end=document.cookie.length;return document.cookie.substring(offset,end);}}
+return null;}
+function drawSelectMsgsTable(){var div=$('<div>');div.html('<span class="none-selected">Nenhuma mensagem foi selecionada.</span>');div.attr('class','select-all-messages');$('#content_id_0').first().prepend(div);}
+function totalSelected(){var total=0;for(var obj in selectedPagingMsgs)
+if(selectedPagingMsgs[obj]==true)
+total++;return total;};function updateSelectedMsgs(selected,msg_number){var folder=$('#content_folders .folder.selected').attr('title');folder=folder?folder:get_lang('INBOX');folder=folder.length>70?'"'+folder.substr(0,70)+"..."+'"':'"'+folder+'"';var div=$('.select-all-messages');var filterFlag=search_box_type!="ALL"?'"'+get_lang(search_box_type)+"s"+'"':"";if(allMsgsSelected&&msg_number==undefined){$('.checkbox').each(function(){$(this).attr('checked',true);$(this).parent().parent().addClass('selected_msg');});}
+else if(msg_number==undefined){for(var obj in selectedPagingMsgs){if(selectedPagingMsgs[obj]==true){$('#check_box_message_'+obj).attr('checked',true);$('#check_box_message_'+obj).parent().parent().addClass('selected_msg');}}}
+if(selected&&msg_number!=undefined){selectedPagingMsgs[msg_number]=true;$(this).parent().parent().addClass('selected_msg');}
+else if(!selected&&msg_number!=undefined){selectedPagingMsgs[msg_number]=false;$(this).parent().parent().removeClass('selected_msg');allMsgsSelected=false;$('#chk_box_select_all_messages').attr('checked',false);}
+var tSelected=totalSelected();if(tSelected>0&&tSelected==totalFolderMsgs){allMsgsSelected=true;$('#chk_box_select_all_messages').attr('checked',true);if(total_pages>1){var link="<a class='select-link' href='#'>Limpar seleção?</a>";var info="Todas as <b>"+totalFolderMsgs+"</b> mensagens "+filterFlag+" em "+folder+" foram selecionadas. "+link;div.html("<span>"+info+"<span>");div.show();$('.select-link').bind('click',function(){selectAllFolderMsgs();$('.select-link').unbind('click');});}}
+else if(tSelected>0&&!allMsgsSelected&&total_pages>1){$('#chk_box_select_all_messages').attr('checked',false);var link="<a class='select-link' href='#'>Limpar seleção?</a>";if(tSelected==1){var info="Foi selecionada <b>"+tSelected+"</b> mensagem "+filterFlag+" em "+folder+". "+link;}
+else{var info="Foram selecionadas <b>"+tSelected+"</b> mensagens "+filterFlag+" em "+folder+". "+link;}
+div.html("<span>"+info+"<span>");div.show();$('.select-link').bind('click',function(){selectAllFolderMsgs();$('.select-link').unbind('click');});}
+else if(allMsgsSelected&&total_pages>1){var link="<a class='select-link' href='#'>Limpar seleção?</a>";var info="Todas as <b>"+totalFolderMsgs+"</b> mensagens "+filterFlag+" em "+folder+" foram selecionadas. "+link;div.html("<span>"+info+"<span>");div.show();$('.select-link').bind('click',function(){selectAllFolderMsgs();$('.select-link').unbind('click');});}
+else if(totalFolderMsgs>parseInt(preferences.max_email_per_page)){div.html('<span class="none-selected">Nenhuma mensagem foi selecionada.</span>');}
+else{div.hide();}
+resizeWindow();}
+function selectAllFolderMsgs(select){var folder=$('#content_folders .folder.selected').attr('title');folder=folder?folder:get_lang('INBOX');folder=folder.length>70?'"'+folder.substr(0,70)+"..."+'"':'"'+folder+'"';var filterFlag=search_box_type!="ALL"?get_lang(search_box_type)+"s":"";var div=$('.select-all-messages');if(select){allMsgsSelected=true;var link="<a class='select-link' href='#'>Limpar seleção?</a>";var info="Todas as <b>"+totalFolderMsgs+"</b> mensagens "+filterFlag+" em "+folder+" foram selecionadas. "+link;div.html("<span>"+info+"<span>");$('.select-link').bind('click',function(){selectAllFolderMsgs();$('.select-link').unbind('click');});for(var obj in selectedPagingMsgs){selectedPagingMsgs[obj]=true;}}else{allMsgsSelected=false;var checkbox=$("#content_id_0").find("input:checkbox");$.each(checkbox,function(i,v){$(v).removeAttr("checked");$(v).parents("tr:first").removeClass("selected_msg selected_shortcut_msg");});for(var obj in selectedPagingMsgs){selectedPagingMsgs[obj]=false;}
+div.html('<span class="none-selected">Nenhuma mensagem foi selecionada.</span>');}
+resizeWindow();}
+function populateSelectedMsgs(data){this.selectedPagingMsgs={};this.totalFolderMsgs=0;var total=0;$.each(data,function(index,value){if(value!=undefined){selectedPagingMsgs[value]=false;total++;}});delete selectedPagingMsgs[undefined];allMsgsSelected=false;this.totalFolderMsgs=total;}
+function draw_box(headers_msgs,msg_folder,alternate){if(msg_folder!=headers_msgs['folder']){if(headers_msgs['folder']){array_folder=headers_msgs['folder'].split('/');if(array_folder.length>1){name_folder=array_folder[1];}
+else{name_folder=headers_msgs['folder'];}
+current_folder=headers_msgs['folder'];Element("border_id_0").innerHTML="&nbsp;"+lang_folder(name_folder)+'&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">&nbsp;</span> / <span id="tot_m"></span>]</font>';Element('new_m').innerHTML=headers_msgs['tot_unseen']?'<font color="RED">'+headers_msgs['tot_unseen']+'</font>':0;Element("tot_m").innerHTML=headers_msgs['num_msgs'];tree_folders.getNodeById(headers_msgs['folder'])._select();}}
+for(var i=0;i<headers_msgs.length;i++){if(!onceOpenedHeadersMessages[current_folder])
+onceOpenedHeadersMessages[current_folder]={};onceOpenedHeadersMessages[current_folder][headers_msgs[i].msg_number]=headers_msgs[i];}
+if(alternate)
+kill_current_box();if(is_ie)
+document.getElementById("border_table").width="99.5%";numBox=0;openTab.content_id[numBox]=document.getElementById("content_id_"+numBox);openTab.content_id[numBox].innerHTML="";openTab.imapBox[numBox]=msg_folder;openTab.type[numBox]=0;table_message_header_box=document.getElementById("table_message_header_box_"+numBox);if(table_message_header_box==null){var table_element=document.createElement("TABLE");var colgr_element=buildColGroup();colgr_element.setAttribute("id","colgroup_head_"+numBox);var tbody_element=document.createElement("TBODY");$(table_element).mousemove(changeCursorState);$(table_element).mousedown(startColResize);table_element.setAttribute("id","table_message_header_box_"+numBox);table_element.className="table_message_header_box";if(!is_ie)
+table_element.style.width="98.8%";table_element.emptyBody=false;tr_element=document.createElement("TR");tr_element.className="message_header";td_element1=createTDElement(0,0);chk_box_element=document.createElement("INPUT");chk_box_element.id="chk_box_select_all_messages";chk_box_element.setAttribute("type","checkbox");chk_box_element.className="checkbox";chk_box_element.onclick=function(){select_all_messages(this.checked);};chk_box_element.onmouseover=function(){this.title=get_lang('Select all messages from this page.');};chk_box_element.onkeydown=function(e){if(is_ie)
+{if((window.event.keyCode)==46)
+proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');}
+else
+{if((e.keyCode)==46)
+proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');}};td_element1.appendChild(chk_box_element);td_element2=createTDElement(0,1);td_element3=createTDElement(0,8,"th_resizable","left","message_header_SORTFROM_"+numBox);td_element3.onclick=function(){sort_box(search_box_type,'SORTFROM');};folder_=special_folders['Sent'];current_=get_current_folder();if((preferences.from_to_sent=="1")&&(current_.substr(current_.length-folder_.length,folder_.length)==folder_)){td_element3.innerHTML=get_lang("To");}else{td_element3.innerHTML=get_lang("From");}
+td_element4=createTDElement(0,9,"th_resizable","left","message_header_SORTSUBJECT_"+numBox);td_element4.onclick=function(){sort_box(search_box_type,'SORTSUBJECT');};td_element4.innerHTML=get_lang("Subject");td_element5=createTDElement(0,10,"th_resizable","center","message_header_SORTARRIVAL_"+numBox);td_element5.onclick=function(){sort_box(search_box_type,'SORTARRIVAL');};td_element5.innerHTML=get_lang("Date");td_element6=createTDElement(0,11,"th_resizable","center","message_header_SORTSIZE_"+numBox);td_element6.onclick=function(){sort_box(search_box_type,'SORTSIZE');}
+td_element6.innerHTML=get_lang("Size");tr_element.appendChild(td_element1);tr_element.appendChild(td_element2);var td_element21=createTDElement(0,2);td_element21.innerHTML="&nbsp;";var td_element22=createTDElement(0,3);td_element22.innerHTML="&nbsp;";var td_element23=createTDElement(0,4);td_element23.innerHTML="&nbsp;";var td_element24=createTDElement(0,5);td_element24.innerHTML="&nbsp;";var td_element25=createTDElement(0,7);td_element25.innerHTML="&nbsp;";var td_element27=createTDElement(0,8);td_element25.innerHTML="&nbsp;";var td_element26=createTDElement(0,6);td_element26.innerHTML="&nbsp;";tr_element.appendChild(td_element21);tr_element.appendChild(td_element22);tr_element.appendChild(td_element23);tr_element.appendChild(td_element24);tr_element.appendChild(td_element26);tr_element.appendChild(td_element27);tr_element.appendChild(td_element25);tr_element.appendChild(td_element3);tr_element.appendChild(td_element4);tr_element.appendChild(td_element5);tr_element.appendChild(td_element6);tbody_element.appendChild(tr_element);table_element.appendChild(tbody_element);table_element.appendChild(colgr_element);var _divScroll=document.getElementById("divScrollHead_"+numBox);if(!_divScroll){_divScroll=document.createElement("DIV");_divScroll.id="divScrollHead_"+numBox;}
+_divScroll.style.overflowY="hidden";_divScroll.style.overflowX="hidden";_divScroll.style.width="100%";if(is_mozilla){_divScroll.style.width="99.3%";}
+_divScroll.appendChild(table_element);openTab.content_id[numBox].appendChild(_divScroll);var table_layout=(getStyle("table_message_header_box_"+numBox,"table-layout")||getStyle("table_message_header_box_"+numBox,"tableLayout"));cssForResizing=(table_layout=="fixed");if(cssForResizing)
+prepareColSizesArray();}
+draw_header_box();var table_element=document.createElement("TABLE");var colgr_element=buildColGroup();colgr_element.setAttribute("id","colgroup_main_"+numBox);var tbody_element=document.createElement("TBODY");table_element.id="table_box";table_element.className="table_box";table_element.borderColorDark="#bbbbbb";table_element.frame="void";table_element.rules="rows";table_element.cellPadding="0";table_element.cellSpacing="0";table_element.onkeydown=function(e){if(is_ie)
+{if((window.event.keyCode)==46)
+{proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');}}
+else
+{if((e.keyCode)==46)
+{proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');}}};if(is_ie)
+table_element.style.cursor="hand";tbody_element.setAttribute("id","tbody_box");table_element.appendChild(tbody_element);table_element.appendChild(colgr_element);var _divScroll=document.getElementById("divScrollMain_"+numBox);if(!_divScroll){_divScroll=document.createElement("DIV");_divScroll.id="divScrollMain_"+numBox;}
+_divScroll.style.overflowY="scroll";_divScroll.style.overflowX="hidden";_divScroll.style.width="100%";if(is_mozilla){_divScroll.style.overflow="-moz-scrollbars-vertical";_divScroll.style.width="100%";}
+_divScroll.appendChild(table_element);openTab.content_id[numBox].appendChild(_divScroll);var f_unseen=0;document.getElementById("table_message_header_box_"+numBox).emptyBody=false;if(headers_msgs.num_msgs==0)
+showEmptyBoxMsg(tbody_element);for(var i=0;i<headers_msgs.length;i++){if((headers_msgs[i].Unseen=='U')||(headers_msgs[i].Recent=='N'))
+f_unseen++;tr_element=make_tr_message(headers_msgs[i],msg_folder,headers_msgs.offsetToGMT);if(tr_element){tbody_element.appendChild(tr_element);add_className(tr_element,i%2!=0?'tr_msg_read2':'tr_msg_read');}
+$(tr_element).draggable({start:function(){if($(".shared-folders").length){$(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({over:function(a,b){over=$(this);$(this).addClass("folder-over");if(($(this)[0]!=$(this).parent().find(".head_folder")[0]))
+if($(this).prev()[0])
+if($(this).parent().find(".expandable-hitarea")[0]==$(this).prev()[0]){setTimeout(function(){if(over.hasClass("folder-over"))
+over.prev().trigger("click");},500);}},out:function(){$(this).removeClass("folder-over");},drop:function(event,ui){$(this).css("border","");if($(this).parent().attr('id')==undefined){var folder_to='INBOX';var to_folder_title=get_lang("Inbox");}else{var folder_to=$(this).parent().attr('id');var to_folder_title=$(this).attr('title');}
+var folder_to_move=ui.draggable.parent().attr('id');var border_id=ui.draggable.find("input[type=hidden]").attr("name");if(folder_to_move=="tbody_box"){move_msgs2(get_current_folder(),'selected',0,folder_to,to_folder_title,true);return refresh();}}});}},stop:function(){$(".shared-folders").parent().find(".folder").droppable("destroy");},helper:function(event){$(this).addClass("selected_msg").find("input:checkbox").attr("checked",true);updateSelectedMsgs($(this).find("input:checkbox").is(':checked'),$(this).attr("id"));if($("#tbody_box .selected_shortcut_msg").length>1){$("#tbody_box .selected_shortcut_msg").addClass("selected_msg").find('.checkbox').attr('checked',true);$.each($(".selected_shortcut_msg"),function(index,value){updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id"));});}
+if(totalSelected()>1)
+return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:(totalSelected()+" mensagens selecionadas"),type:"messages"})+"</td></tr>");if($(this).find(".td_msg_subject").text().length>18)
+return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:$(this).find(".td_msg_subject").text().substring(0,18)+"...",type:"messages"})+"</td></tr>");else
+return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:$(this).find(".td_msg_subject").text(),type:"messages"})+"</td></tr>");},iframeFix:true,delay:150,cursorAt:{top:5,left:56},refreshPositions:true,containment:"#divAppbox"}).bind('contextmenu',function(event){if(!(($(event.target).find('img').length>0)&&($(event.target).hasClass('td-label')))){if($(this).find("input:checkbox").attr("checked")!="checked"){$(this).find("input:checkbox").trigger('click');$(this).addClass("selected_msg");}
+updateSelectedMsgs($(this).find("input:checkbox").is(':checked'),$(this).attr("id"));}});}
+if((preferences.use_shortcuts=='1')&&(headers_msgs[0]))
+select_msg(headers_msgs[0].msg_number,'null',true);var tdFolders=Element("folderscol");tdFolders.style.display=preferences.hide_folders=='1'?"none":"";if(!currentTab)
+alternate_border(numBox);draw_footer_box(headers_msgs.num_msgs);Element('main_table').style.display='';if(is_ie6)
+setTimeout("resizeWindow()",1);else
+resizeWindow();if(debug){var _eTime=new Date();_eTime=_eTime.getTime();alert("Carregou em "+(_eTime-_bTime)+" ms");}
+var msg_folder=Element('msg_folder').value;var msg_number=Element('msg_number').value;if(!msg_folder&&msg_number){new_message('new','null');}
+else if(msg_folder&&msg_number){$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:msg_number,msg_folder:msg_folder,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)
+show_msg(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});Element('msg_folder').value='';Element('msg_number').value='';}
+connector.loadScript("InfoContact");if(Element("table_quota"))
+connector.loadScript("InfoQuota");var ruler_element=document.getElementById("table_message_ruler");if(ruler_element==null){ruler_element=document.createElement("DIV");ruler_element.setAttribute("id","table_message_ruler");ruler_element.className="table_message_ruler";ruler_element.style.top=getColumnPosition(document.getElementById("content_id_0"),"BODY")[1];document.getElementById("exmail_main_body").appendChild(ruler_element);}
+drawSelectMsgsTable();updateSelectedMsgs();resizeWindow();}
+function showEmptyBoxMsg(tbody_element){document.getElementById("table_message_header_box_"+numBox).emptyBody=true;var div_pasta=document.getElementById("div_msg_info");if(!div_pasta){div_info=document.createElement("div");div_info.setAttribute("id","div_msg_info");div_info.setAttribute("background","#FFF");h3_info=document.createElement("h3");h3_info.style.padding="10px";h3_info.setAttribute("id","msg_info");h3_info.align="center";h3_info.innerHTML=get_lang("This mail box is empty");div_info.appendChild(h3_info);tbody_element.parentNode.parentNode.appendChild(div_info);}}
+function html_entities(string){return String(string).replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');}
+function make_tr_message(headers_msgs,msg_folder,offsetToGMT){headers_msgs.subject=html_entities(headers_msgs.subject);if(typeof offsetToGMT=='undefined')
+{offsetToGMT=typeof headers_msgs.offsetToGMT!='undefined'?headers_msgs.offsetToGMT:0;}
+var tr_element=document.createElement('tr');if(typeof(preferences.line_height)!='undefined')
+tr_element.style.height=preferences.line_height;tr_element.id=headers_msgs.msg_number;tr_element.msg_sample="";tr_element.tip="";if(headers_msgs.msg_sample&&preferences.preview_msg_subject=="1"&&headers_msgs.msg_sample.body!=="")
+{if(cssForResizing)
+tr_element.msg_sample=html_entities(Base64.decode(headers_msgs.msg_sample.body).substr(0,180)+"...");else
+tr_element.msg_sample=html_entities(Base64.decode(headers_msgs.msg_sample.body).substr(0,120)+"...");if(proxy_mensagens.is_local_folder(current_folder)){if(cssForResizing){tr_element.msg_sample=headers_msgs.msg_sample.body.substr(0,180)+"...";}else{tr_element.msg_sample=headers_msgs.msg_sample.body.substr(0,120)+"...";}
+if(headers_msgs.msg_sample&&preferences.preview_msg_tip=="1"&&headers_msgs.msg_sample.body!==""){tr_element.tip=headers_msgs.msg_sample.body.substr(3,300)+"...";}}
+else{if(cssForResizing){tr_element.msg_sample=Base64.decode(headers_msgs.msg_sample.body).substr(0,180)+"...";}else{tr_element.msg_sample=Base64.decode(headers_msgs.msg_sample.body).substr(0,120)+"...";}
+if(headers_msgs.msg_sample&&preferences.preview_msg_tip=="1"&&headers_msgs.msg_sample.body!==""){tr_element.tip=Base64.decode(headers_msgs.msg_sample.body).substr(3,300)+"...";}}}
+if((headers_msgs.Unseen=='U')||(headers_msgs.Recent=='N')){if((headers_msgs.Flagged=='F')||(headers_msgs.Importance!==undefined&&headers_msgs.Importance.toLowerCase().indexOf("high")!=-1))
+add_className(tr_element,'flagged_msg');add_className(tr_element,'tr_msg_unread');}
+else{if((headers_msgs.Flagged=='F')||(headers_msgs.Importance!==undefined&&headers_msgs.Importance.toLowerCase().indexOf("high")!=-1))
+add_className(tr_element,'flagged_msg');}
+if((headers_msgs.Unseen=='U')||(headers_msgs.Recent=='N'))
+add_className(tr_element,'tr_msg_unread');if(headers_msgs.Flagged=='F')
+add_className(tr_element,'flagged_msg');td_element1=createTDElement(0,0,"td_msg");chk_box_element=document.createElement("INPUT");chk_box_element.setAttribute("type","checkbox");chk_box_element.className="checkbox";chk_box_element.setAttribute("id","check_box_message_"+headers_msgs.msg_number);$(chk_box_element).click(function(e){updateSelectedMsgs($(this).is(':checked'),headers_msgs.msg_number);$(".selected_shortcut_msg").removeClass("current_selected_shortcut_msg selected_shortcut_msg");$(".current_selected_shortcut_msg").removeClass("current_selected_shortcut_msg selected_shortcut_msg");if(preferences.use_shortcuts=='1')
+$(this).parents("tr:first").addClass("current_selected_shortcut_msg selected_shortcut_msg");changeBgColor(e,headers_msgs.msg_number);$(this).blur();});td_element1.appendChild(chk_box_element);td_element2=createTDElement(0,1,"td_msg");if(headers_msgs.attachment&&(headers_msgs.attachment==1||headers_msgs.attachment.number_attachments>0))
+td_element2.innerHTML="<img src ='templates/"+template+"/images/clip.gif' >";td_element21=createTDElement(0,2,"td_msg",null,"td_message_answered_"+headers_msgs.msg_number);if((headers_msgs.Forwarded=='F')||(headers_msgs.Draft=='X'&&headers_msgs.Answered=='A')){td_element21.onclick=function(){search_emails(headers_msgs.subject.replace(/^(re: ?|fw: ?|enc: ?|res: ?|fwd: ?)*/gi,''),true);};td_element21.innerHTML="<img src ='templates/"+template+"/images/forwarded.png' title='"+get_lang('Forwarded')+"'>";headers_msgs.Draft=''
+headers_msgs.Answered='';headers_msgs.Forwarded='F';}
+else if(headers_msgs.Draft=='X')
+td_element21.innerHTML="<img src ='templates/"+template+"/images/draft.png' title='"+get_lang('Draft')+"'>";else if(headers_msgs.Answered=='A'){td_element21.onclick=function(){search_emails(headers_msgs.subject.replace(/^(re: ?|fw: ?|enc: ?|res: ?|fwd: ?)*/gi,''),true);};td_element21.innerHTML="<img src ='templates/"+template+"/images/answered.png' title='"+get_lang('Answered')+"'>";}else
+td_element21.innerHTML="&nbsp;&nbsp;&nbsp;";td_element22=createTDElement(0,1,"td_msg",null,"td_message_signed_"+headers_msgs.msg_number);switch(headers_msgs.ContentType)
+{case"signature":{td_element22.innerHTML="<img src ='templates/"+template+"/images/signed_msg.gif' title='"+get_lang('Signed message')+"'>";break;}
+case"cipher":{td_element22.innerHTML="<img src ='templates/"+template+"/images/lock.gif' title='"+get_lang('Crypted message')+"'>";break;}
+default:{break;}}
+td_element23=createTDElement(0,4,"td_msg",null,"td_message_important_"+headers_msgs.msg_number);if((headers_msgs.Flagged=='F')||(headers_msgs.Importance!==undefined&&headers_msgs.Importance.toLowerCase().indexOf("high")!=-1))
+{td_element23.innerHTML="<img src ='templates/"+template+"/images/important.png' title='"+get_lang('Important')+"'>";}
+else
+td_element23.innerHTML="&nbsp;&nbsp;&nbsp;";td_element24=createTDElement(0,5,"td_msg",null,"td_message_sent_"+headers_msgs.msg_number);td_element24.innerHTML="&nbsp;&nbsp;&nbsp;";var _img_sent=new Image();_img_sent.src="templates/"+template+"/images/sent.gif";td_element25=createTDElement(0,7,"td_msg",null,"td_message_unseen_"+headers_msgs.msg_number);if((headers_msgs.Unseen=='U')||(headers_msgs.Recent=='N'))
+td_element25.innerHTML="<img src ='templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>";else
+td_element25.innerHTML="<img src ='templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>";td_element3=createTDElement(0,8,"td_msg td_resizable","left","td_from_"+headers_msgs.msg_number);var _onclick=function(){InfoContact.hide();proxy_mensagens.get_msg(headers_msgs.msg_number,msg_folder,true,show_msg);};td_element3.onclick=_onclick;td_element3.innerHTML='&nbsp;';test=true;if(msg_folder.indexOf(special_folders['Sent'])!=-1||msg_folder.indexOf(preferences.save_in_folder)!=-1||msg_folder.replace("local_","INBOX"+cyrus_delimiter).indexOf(preferences.save_in_folder)!=-1)
+test=false;if((msg_folder.indexOf(special_folders['Sent'])!=-1)&&(headers_msgs.from!=undefined)&&headers_msgs.from.email.toLowerCase()==Element("user_email").value.toLowerCase()&&(preferences.from_to_sent=="1")&&!(msg_folder.substr(0,5)=="user/"))
+{td_element3.onmouseover=function(){var title_to='';$.each(headers_msgs.to,function(index,value){if(index==(headers_msgs.to.length-1)){title_to=title_to+value.email;}
+else{title_to=title_to+value.email+', ';}});this.title=title_to;};if(headers_msgs.Draft=='X')
+td_element3.innerHTML+="<span style=\"color:red\">("+get_lang("Draft")+") </span>";else{if(headers_msgs.to&&headers_msgs.to[0].email!=null&&headers_msgs.to[0].email.toLowerCase()!=Element("user_email").value)
+td_element24.innerHTML="<img align='center' src ='templates/"+template+"/images/sent.gif' title='"+get_lang('Sent')+"'>";if(headers_msgs.to){if(headers_msgs.to[0].name!=null)
+td_element3.innerHTML+=headers_msgs.to[0].name;else if(headers_msgs.to[0].email!=null){td_element3.innerHTML+=headers_msgs.to[0].email;}
+else{td_element3.innerHTML+=get_lang("without destination");}}}}
+else{if(headers_msgs.Draft=='X'){td_element3.innerHTML="<span style=\"color:red\">("+get_lang("Draft")+") </span>";}
+else{var spanSender=document.createElement("SPAN");spanSender.setAttribute('class','span-sender');spanSender.onmouseover=function(event){try{InfoContact.begin(this,headers_msgs.reply_toaddress)}catch(e){};};spanSender.onmouseout=function(){try{clearTimeout(InfoContact.timeout);}catch(e){}};folder=special_folders['Sent'];current=get_current_folder();if((preferences.from_to_sent=="1")&&(current.substr(current.length-folder.length,folder.length)==folder)){spanSender.onmouseover=function(){var title_to='';$.each(headers_msgs.to,function(index,value){if(index==(headers_msgs.to.length-1)){title_to=title_to+value.email;}
+else{title_to=title_to+value.email+', ';}});this.title=title_to;};if(headers_msgs.to){if(headers_msgs.to[0].name!=null){spanSender.innerHTML+=headers_msgs.to[0].name;}else if(headers_msgs.to[0].email!=null){spanSender.innerHTML+=headers_msgs.to[0].email;}}}else if(headers_msgs.from!==undefined){spanSender.innerHTML=headers_msgs.from.name!=null?headers_msgs.from.name:headers_msgs.from.email;}
+if(spanSender.innerHTML.indexOf(" ")=='-1'&&spanSender.innerHTML.length>25){spanSender.innerHTML=spanSender.innerHTML.substring(0,25)+"...";}
+else if(spanSender.innerHTML.length>40){spanSender.innerHTML=spanSender.innerHTML.substring(0,40)+"...";}
+td_element3.appendChild(spanSender);}}
+td_element4=createTDElement(0,9,"td_msg td_resizable","left");td_element4.className+=" td_msg_subject";td_element4.onclick=_onclick;td_element4.innerHTML=!is_ie?"<a nowrap id='a_message_"+tr_element.id+"'>&nbsp;":"&nbsp;";if((headers_msgs.subject)&&(headers_msgs.subject.length>50))
+{if(cssForResizing)
+td_element4.innerHTML+=headers_msgs.subject+"<span style=\"color:#b3b3b3;\">  "+tr_element.msg_sample+"</span>";else{pos=headers_msgs.subject.indexOf("&",45);if((pos>0)&&(pos<=50)&&((headers_msgs.subject.charAt(pos+5)==";")||(headers_msgs.subject.charAt(pos+6)==";")))
+td_element4.innerHTML+=headers_msgs.subject.substring(0,pos+6)+"..."+"<span style=\"color:#b3b3b3;\">  "+tr_element.msg_sample+"</span>";else
+td_element4.innerHTML+=headers_msgs.subject.substring(0,50)+"..."+"<span style=\"color:#b3b3b3;\">  "+tr_element.msg_sample+"</span>";}}
+else
+{td_element4.innerHTML+=($.trim(headers_msgs.subject)==""?"("+get_lang("No Subject")+")":headers_msgs.subject)+"<span style=\"color:#b3b3b3;\">  "+tr_element.msg_sample+"</span>";}
+td_element4.title=tr_element.tip;if(!is_ie){td_element4.innerHTML+="</a>";}
+td_element5=createTDElement(0,10,"td_msg td_resizable","center");td_element5.onclick=_onclick;td_element27=createTDElement(0,7,"td_msg",null,"td_message_labels_"+headers_msgs.msg_number);$(td_element27).addClass("td-label");if(headers_msgs.labels){td_element27.innerHTML='<img src="../prototype/modules/mail/img/tag.png">';updateLabelsColumn(headers_msgs);}
+td_element26=createTDElement(0,6,"td_msg","center","td_message_followup_"+headers_msgs.msg_number);$(td_element26).addClass("td-followup-flag");if(get_current_folder().split("_")[0]!="local"){td_element26.innerHTML='<div class="flag-edited" style="width:8px;height:6px;"><img src="../prototype/modules/mail/img/flagEditor.png"></div>';}else{td_element26.innerHTML="";}
+if(headers_msgs.followupflagged){if(headers_msgs.followupflagged.followupflag.id<7){var nameFollowupflag=get_lang(headers_msgs.followupflagged.followupflag.name);}else{var nameFollowupflag=headers_msgs.followupflagged.followupflag.name;}
+$(td_element26).attr('title',nameFollowupflag).find(".flag-edited").css("background",headers_msgs.followupflagged.backgroundColor);if(headers_msgs.followupflagged.isDone=="1"){$(td_element26).find(".flag-edited").find("img").attr("src","../prototype/modules/mail/img/flagChecked.png").css("margin-left","-3px");}}else{$(td_element26).find(".flag-edited").css("background","#cccccc");}
+$(td_element26).click(function(){var messageClickedId=$(this).attr('id').match(/td_message_followup_([\d]+)/)[1];var followupColor=$('#td_message_followup_'+messageClickedId).find(".flag-edited").css('backgroundColor');$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).find(".flag-edited").html('<img alt="Carregando" title="Carregando" style="margin-left:-3px; margin-top:-4px; width:13px; height:13px;" src="../prototype/modules/mail/img/ajax-loader.gif" />');$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).find(".flag-edited").css("background","transparent");DataLayer.remove('followupflagged',false);var flagged=DataLayer.get('followupflagged',{filter:['AND',['=','messageNumber',messageClickedId],['=','folderName',msg_folder]]});if(!flagged){headers_msgs.followupflagged={uid:User.me.id,folderName:msg_folder,messageNumber:messageClickedId,alarmTime:false,backgroundColor:'#FF2016',followupflagId:'1'};headers_msgs.followupflagged.id=DataLayer.put('followupflagged',headers_msgs.followupflagged);DataLayer.commit(false,false,function(data){var fail='success';$.each(data,function(index,value){if(typeof value==='string'){fail=value;}});$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).find(".flag-edited").html('<img src="../prototype/modules/mail/img/flagEditor.png">');if(fail!='success'){$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).find(".flag-edited").css("background","#CCCCCC");MsgsCallbackFollowupflag[fail]();}else{$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).attr('title',get_lang('Follow up')).find(".flag-edited").css("background",headers_msgs.followupflagged.backgroundColor);updateCacheFollowupflag(messageClickedId,msg_folder,true);}});}else if(onceOpenedHeadersMessages[msg_folder][messageClickedId]['followupflagged'].followupflag.name=='Follow up'){$(this).find(".flag-edited").css("background","#cccccc");DataLayer.remove('followupflagged',flagged[0].id);DataLayer.commit(false,false,function(){updateCacheFollowupflag(messageClickedId,msg_folder,false);$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).find(".flag-edited").html('<img src="../prototype/modules/mail/img/flagEditor.png">');$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).attr('title','').find(".flag-edited").css("background",'#CCC');$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).find(".flag-edited").find("img").attr("src","../prototype/modules/mail/img/flagEditor.png").css("margin-left","0");});}else{$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).find(".flag-edited").html('<img src="../prototype/modules/mail/img/flagEditor.png">');$('#td_message_followup_'+messageClickedId+', '+'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_'+messageClickedId).find(".flag-edited").css("background",followupColor);$(tr_element).addClass('selected_msg').find(':checkbox').trigger('click');configureFollowupflag();}});var norm=function(arg){return(arg<10?'0'+arg:arg);};var weekDays=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];var today=new Date();today.setHours(23);today.setMinutes(59);today.setSeconds(59);today.setMilliseconds(999)
+var udate_local=null;var date_msg=null;if((headers_msgs.udate!==undefined)&&(headers_msgs.udate.toString().match(/\d{2}:\d{2}/)||headers_msgs.udate.toString().match(/\d{2}\/\d{2}\/\d{4}/)))
+{temp_msg_day=headers_msgs.msg_day.split('/');temp_msg_hour=headers_msgs.msg_hour.split(':');date_msg=new Date(temp_msg_day[2],temp_msg_day[1]-1,temp_msg_day[0],temp_msg_hour[0],temp_msg_hour[1]);}
+else
+{udate_local=headers_msgs.udate*1000+offsetToGMT*1000+today.getTimezoneOffset()*60*1000;date_msg=new Date(udate_local);}
+if(preferences.show_date_numerical==0||typeof(preferences.show_date_numerical)=='undefined'){if(today.getTime()-date_msg.getTime()<86400000)
+td_element5.innerHTML=norm(date_msg.getHours())+':'+norm(date_msg.getMinutes());else
+if(today.getTime()-date_msg.getTime()<172800000)
+td_element5.innerHTML=get_lang('Yesterday');else if(today.getTime()-date_msg.getTime()<259200000)
+td_element5.innerHTML=get_lang(weekDays[date_msg.getDay()]);else{td_element5.innerHTML=norm(date_msg.getDate())+'/'+norm(date_msg.getMonth()+1)+'/'+date_msg.getFullYear();td_element5.title=norm(date_msg.getDate())+'/'+norm(date_msg.getMonth()+1)+'/'+date_msg.getFullYear();td_element5.alt=td_element5.title;}}else{td_element5.innerHTML=norm(date_msg.getDate())+'/'+norm(date_msg.getMonth()+1)+'/'+date_msg.getFullYear();td_element5.title=norm(date_msg.getDate())+'/'+norm(date_msg.getMonth()+1)+'/'+date_msg.getFullYear();td_element5.alt=td_element5.title;}
+td_element6=createTDElement(0,11,"td_msg td_resizable","center");td_element6.onclick=_onclick;td_element6.setAttribute("noWrap","true");td_element6.innerHTML=borkb(headers_msgs.Size);tr_element.appendChild(td_element1);tr_element.appendChild(td_element2);tr_element.appendChild(td_element21);tr_element.appendChild(td_element22);tr_element.appendChild(td_element23);tr_element.appendChild(td_element24);tr_element.appendChild(td_element26);tr_element.appendChild(td_element27);tr_element.appendChild(td_element25);tr_element.appendChild(td_element3);tr_element.appendChild(td_element4);tr_element.appendChild(td_element5);tr_element.appendChild(td_element6);return tr_element;}
+function sort_box(search,sort,clean_selected){if(typeof(clean_selected)=="undefined")
+selectAllFolderMsgs(false);if(cellResized)
+return;var message_header=Element("message_header_"+search);var handler_draw_box=function(data){draw_box(data,current_folder,true);var msgs_unseen=0;draw_paging(data.num_msgs);Element("new_m").innerHTML='<font style="color:'+(data.tot_unseen==0?'':'red')+'">'+data.tot_unseen+'</font>';Element("tot_m").innerHTML=data.num_msgs;}
+if(sort_box_type==sort&&search_box_type==search){sort_box_reverse=sort_box_reverse?0:1;}
+else if(sort_box_type!=sort){if((sort=='SORTFROM')||(sort=='SORTSUBJECT'))
+sort_box_reverse=0;else
+sort_box_reverse=1;}
+sort_box_type=sort;search_box_type=search;if(typeof(clean_selected)=="undefined"){$.ajax({url:"controller.php?"+$.param({action:"$this.imap_functions.getMessagesIds",folder:get_current_folder(),sort_box_type:"SORTARRIVAL",search_box_type:search_box_type,sort_box_reverse:"1"}),success:function(data){data=connector.unserialize(data);if(data){var _data={};$.each(data,function(index,value){if(value){_data[index]=value;}});populateSelectedMsgs(_data);}},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort,search,sort_box_reverse,preferences.preview_msg_subject,preferences.preview_msg_tip,handler_draw_box);current_page=1;}
+function draw_header_box(){var types={'SORTFROM':'From','SORTSUBJECT':'Subject','SORTARRIVAL':'Date','SORTSIZE':'Size'};type_name=(types[sort_box_type]?get_lang(types[sort_box_type]):get_lang("Date"));folder=special_folders['Sent'];current=get_current_folder();if((preferences.from_to_sent=="1")&&(current.substr(current.length-folder.length,folder.length)==folder)){$("#message_header_SORTFROM_"+numBox).html(get_lang("To"));if(sort_box_type=="SORTFROM")
+type_name=get_lang("To");}else{$("#message_header_SORTFROM_"+numBox).html(get_lang("From"));}
+$("#message_header_SORTSUBJECT_"+numBox).html(get_lang("Subject"));$("#message_header_SORTARRIVAL_"+numBox).html(get_lang("Date"));$("#message_header_SORTSIZE_"+numBox).html(get_lang("Size"));document.getElementById("message_header_"+(sort_box_type.lastIndexOf("SORT")!="-1"?sort_box_type:"SORTARRIVAL")+"_"+numBox).innerHTML="<B>"+type_name+"</B><img src ='templates/"+template+"/images/arrow_"+(sort_box_reverse==1?'desc':'asc')+"endant.gif'>";}
+function verifyOption(name,id){var str=name+''+id;if(!Element(str).style.display==""){var option_reply_options=document.getElementById('msg_opt_reply_options_'+id);option_reply_options.value='show';option_reply_options.src='../expressoMail1_2/templates/default/images/down.png';Element('tr_other_options_'+id).style.display='none';var option_more_options=document.getElementById('msg_opt_more_options_'+id);option_more_options.value='show';option_more_options.src='../expressoMail1_2/templates/default/images/down.png';Element('tr_other_more_options_'+id).style.display='none';var option_mark_as_options=document.getElementById('msg_opt_mark_options_'+id);option_mark_as_options.value='show';option_mark_as_options.src='../expressoMail1_2/templates/default/images/down.png';Element('tr_other_mark_options_'+id).style.display='none';}}
+function firstRow(){var thisCell;if(objCell)
+thisCell=objCell;else
+thisCell=document.getElementById("table_message_header_box_0").rows[0].cells[0];var tbM=getMessagesTable(thisCell);proxy_mensagens.get_msg(tbM.rows[0].getAttribute('id'),get_current_folder(),true,show_msg);}
+function lastRow(){var thisCell;if(objCell)
+thisCell=objCell;else
+thisCell=document.getElementById("table_message_header_box_0").rows[0].cells[0];var tbM=getMessagesTable(thisCell);proxy_mensagens.get_msg(tbM.rows[tbM.rows.length-1].getAttribute('id'),get_current_folder(),true,show_msg);}
+var msg_selected;function draw_message(info_msg,ID){if(info_msg.Unseen=="U"){$.each(fromRules,function(index,value){if(value==info_msg.msg_folder){cExecute("$this.imap_functions.removeFlagMessagesFilter&folder="+info_msg.msg_folder+"&msg_number="+info_msg.msg_number,function(){});return false;}});}
+var content=document.getElementById('content_id_'+ID);var menuHidden=Element("folderscol").style.display=='none'?true:false;var next_previous_msg_td=document.createElement("TD");next_previous_msg_td.setAttribute("noWrap","true");next_previous_msg_td.align="right";next_previous_msg_td.style.fontSize="10px";next_previous_msg_td.width="40px";var img_next_msg=document.createElement("IMG");img_next_msg.id='msg_opt_next_'+ID;img_next_msg.src='./templates/'+template+'/images/down.button.png';if(preferences.use_shortcuts=='1')
+img_next_msg.title=get_lang('Next Shortcut:Control + Down');else
+img_next_msg.title=get_lang('Next');img_next_msg.style.cursor='pointer';var folder_id=ID.match(/\d+/)[0];var folder;if((folder=Element(info_msg.original_ID))==null)
+folder=Element(info_msg.msg_number);if(folder){if(folder.nextSibling){var nextMsgBox=folder.nextSibling.name?folder.nextSibling.name:info_msg.msg_folder;if(nextMsgBox=="INBOX"+cyrus_delimiter+"decifradas")
+nextMsgBox=get_current_folder();img_next_msg.onclick=function()
+{currentTab=ID;openTab.type[ID]=2;proxy_mensagens.get_msg(folder.nextSibling.id,nextMsgBox,true,show_msg);if(!msg_selected){select_msg('null','down',true);msg_selected=true;}};}
+else if((current_page<total_pages)){img_next_msg.onclick=function()
+{current_page++;var tot_msgs=parseInt(Element("tot_m").innerHTML);var range_begin=preferences.max_email_per_page*(current_page-1)+1;var range_end;if(range_begin+parseInt(preferences.max_email_per_page-1)>tot_msgs)
+range_end=tot_msgs;else
+range_end=range_begin+parseInt(preferences.max_email_per_page-1);var creatBoxProximo=function(data){draw_box(data,get_current_folder());firstRow();};proxy_mensagens.messages_list(get_current_folder(),range_begin,range_end,sort_box_type,search_box_type,sort_box_reverse,'','',creatBoxProximo);};}
+else
+{img_next_msg.src="./templates/"+template+"/images/down.gray.button.png";img_next_msg.style.cursor='default';}}
+else
+{img_next_msg.src="./templates/"+template+"/images/down.gray.button.png";img_next_msg.style.cursor='default';if(!proxy_mensagens.is_local_folder(get_current_folder())&&!(info_msg.msg_folder=="INBOX"+cyrus_delimiter+"decifradas"))
+{img_next_msg.onclick=function()
+{delete_border(ID);};}}
+var img_space=document.createElement("SPAN");img_space.innerHTML="&nbsp;";var img_previous_msg=document.createElement("IMG");img_previous_msg.id='msg_opt_previous_'+ID;img_previous_msg.src='./templates/'+template+'/images/up.button.png';if(preferences.use_shortcuts=='1')
+img_previous_msg.title=get_lang('Previous Shortcut:Control + Up');else
+img_previous_msg.title=get_lang('Previous');img_previous_msg.style.cursor='pointer';if(folder){if(folder.previousSibling)
+{var previousMsgBox=folder.previousSibling.name?folder.previousSibling.name:info_msg.msg_folder;if(previousMsgBox=="INBOX"+cyrus_delimiter+"decifradas")
+previousMsgBox=get_current_folder();img_previous_msg.onclick=function()
+{currentTab=ID;openTab.type[ID]=2;proxy_mensagens.get_msg(folder.previousSibling.id,previousMsgBox,true,show_msg);if(!msg_selected){select_msg('null','up',true);msg_selected=true;}};}
+else if(current_page>1){img_previous_msg.onclick=function()
+{current_page--;var range_begin=(current_page-1)*preferences.max_email_per_page+1;var range_end=current_page*preferences.max_email_per_page;var creatBoxAnterior=function(data){draw_box(data,get_current_folder());lastRow();};proxy_mensagens.messages_list(get_current_folder(),range_begin,range_end,sort_box_type,search_box_type,sort_box_reverse,'','',creatBoxAnterior);};}
+else
+{img_previous_msg.src="./templates/"+template+"/images/up.gray.button.png";img_previous_msg.style.cursor='default';}}
+else
+{img_previous_msg.src="./templates/"+template+"/images/up.gray.button.png";img_previous_msg.style.cursor='default';if(!proxy_mensagens.is_local_folder(get_current_folder())&&!(info_msg.msg_folder=="INBOX"+cyrus_delimiter+"decifradas"))
+{img_previous_msg.onclick=function()
+{delete_border(ID);};}}
+next_previous_msg_td.appendChild(img_previous_msg);next_previous_msg_td.appendChild(img_space);next_previous_msg_td.appendChild(img_next_msg);var table_message=document.createElement("TABLE");var tbody_message=document.createElement("TBODY");table_message.border="0";table_message.setAttribute("class","expressomail-message-body");table_message.setAttribute("className","expressomail-message-body");var tr0=document.createElement("TR");tr0.className="tr_message_header";var td0=document.createElement("TD");var table_message_options=document.createElement("TABLE");table_message_options.width="100%";table_message_options.border='0';table_message_options.className='table_message';var tbody_message_options=document.createElement("TBODY");var tr=document.createElement("TR");var td=document.createElement("TD");td.setAttribute("noWrap","true");td.style.fontSize="10px";var _name='';var _maxChar=menuHidden?40:15;if(info_msg.from){if(info_msg.from.name)
+{var spanName=document.createElement("SPAN");spanName.innerHTML=info_msg.from.name;_name=spanName.innerHTML.length>_maxChar?spanName.innerHTML.substring(0,_maxChar)+"...":spanName.innerHTML;}
+else
+_name=info_msg.from.email.length>_maxChar?info_msg.from.email.substring(0,_maxChar)+"...":info_msg.from.email;}
+td.innerHTML=_name.bold()+', '+info_msg.smalldate;if(info_msg.attachments&&info_msg.attachments.length>0)
+td.innerHTML+="&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+ID+"\").onclick()' src ='templates/"+template+"/images/clip.gif' title='"+info_msg.attachments[0].name+"'>";if(typeof(info_msg.signature)=='string')
+{if(info_msg.signature!="void")
+td.innerHTML+='&nbsp;<img style="cursor:pointer" onclick="alert(\''+get_lang("This message is signed, and you can trust.")+info_msg.signature+'\');" src="templates/'+template+'/images/signed.gif">';else
+td.innerHTML+="&nbsp;<img style='cursor:pointer' onclick='alert(\""+get_lang("This message is signed, but it is invalid. You should not trust on it.")+"\");' title='"+get_lang("Voided message")+"' src='templates/"+template+"/images/invalid.gif'>";}
+if(info_msg.DispositionNotificationTo)
+{td.innerHTML+='&nbsp;<img id="disposition_notification_'+ID+'" style="cursor:pointer" alt="'+get_lang('Message with read notification')+'" title="'+get_lang('Message with read notification')+'" src="templates/'+template+'/images/notification.gif">';}
+if(info_msg.Flagged=='F')
+{td.innerHTML+='&nbsp;<img id="disposition_important_'+ID+'" style="cursor:pointer" alt="'+get_lang('Important message')+'" title="'+get_lang('Important message')+'" src="templates/'+template+'/images/important.png">';}
+if(info_msg.Draft!='X')
+{var options=document.createElement("TD");options.width="30%";options.setAttribute("noWrap","true");options.style.fontSize="10px";var option_hide_more=document.createElement("SPAN");option_hide_more.className='message_options';option_hide_more.onmouseover=function(){this.className='message_options_active';};option_hide_more.onmouseout=function(){this.className='message_options'};options.align='right';option_hide_more.value='more_options';option_hide_more.id='option_hide_more_'+ID;option_hide_more.onclick=function(){if(this.value=='more_options'){this.innerHTML="<b><u>"+get_lang('Hide details')+"</u></b>";this.value='hide_options';Element('table_message_others_options_'+ID).style.display='';}
+else{this.innerHTML=get_lang('Show details');this.value='more_options';Element('table_message_others_options_'+ID).style.display='none';}
+resizeWindow();};var option_mark_as=document.createElement("SPAN");option_mark_as.innerHTML="<b>"+get_lang('Mark as')+"</b>";option_mark_as.className='message_options';option_mark_as.onmouseover=function(){this.className='message_options_active';};option_mark_as.onmouseout=function(){this.className='message_options'};option_mark_as.onclick=function(){verifyOption('tr_other_mark_options_',ID);var thi=document.getElementById('msg_opt_mark_options_'+ID);if(thi.value!='hide'){thi.value='hide';option_mark_as_options.src='../expressoMail1_2/templates/default/images/pressed.png';Element('tr_other_mark_options_'+ID).style.display='';}
+else{thi.value='show';option_mark_as_options.src='../expressoMail1_2/templates/default/images/down.png';Element('tr_other_mark_options_'+ID).style.display='none';}};var option_mark_as_unseen=document.createElement("SPAN");option_mark_as_unseen.className="reply_options";option_mark_as_unseen.onclick=function(){changeLinkState(this,'seen');proxy_mensagens.proxy_set_message_flag(folder_id,'unseen',null,ID.split("_r_")[0]);write_msg(get_lang('Message marked as ')+get_lang("Unseen"));};option_mark_as_unseen.onmouseover=function(){this.className='reply_options_active'};option_mark_as_unseen.onmouseout=function(){this.className='reply_options'};option_mark_as_unseen.innerHTML=get_lang("Unseen");var option_mark_important=document.createElement("SPAN");option_mark_important.className='reply_options';option_mark_important.onmouseover=function(){this.className='reply_options_active';};option_mark_important.onmouseout=function(){this.className='reply_options'};if(info_msg.Flagged=="F"){option_mark_important.onclick=function(){var _this=this;changeLinkState(_this,'important');proxy_mensagens.proxy_set_message_flag(folder_id,'unflagged',null,ID.split("_r_")[0]);write_msg(get_lang('Message marked as ')+get_lang("Normal"));};option_mark_important.innerHTML=get_lang("Normal");}
+else{option_mark_important.onclick=function(){changeLinkState(this,'normal',null,ID.substr(0,ID.length-2));proxy_mensagens.proxy_set_message_flag(folder_id,'flagged',null,ID.split("_r_")[0]);write_msg(get_lang('Message marked as ')+get_lang("Important"));};option_mark_important.innerHTML=get_lang("Important");}
+option_hide_more.innerHTML=get_lang('Show details');option_hide_more.title=(preferences.use_shortcuts=='1')?get_lang('Shortcut: %1','O'):get_lang('Show details');var space3=document.createElement("SPAN");space3.innerHTML='&nbsp;|&nbsp;';var option_mark_as_options=document.createElement('IMG');option_mark_as_options.id='msg_opt_mark_options_'+ID;option_mark_as_options.src='../expressoMail1_2/templates/default/images/down.png';option_mark_as_options.value='show';option_mark_as_options.onmouseover=function(){option_mark_as_options.src='../expressoMail1_2/templates/default/images/over.png';option_mark_as.className='message_options_active';};option_mark_as_options.onmouseout=function(){option_mark_as.className='message_options';if(this.value=='show')
+{option_mark_as_options.src='../expressoMail1_2/templates/default/images/down.png';}
+else
+{option_mark_as_options.src='../expressoMail1_2/templates/default/images/pressed.png';}};option_mark_as_options.onclick=function(){verifyOption('tr_other_mark_options_',ID);if(this.value!='hide'){this.value='hide';option_mark_as_options.src='../expressoMail1_2/templates/default/images/pressed.png';Element('tr_other_mark_options_'+ID).style.display='';}
+else{this.value='show';option_mark_as_options.src='../expressoMail1_2/templates/default/images/down.png';Element('tr_other_mark_options_'+ID).style.display='none';}};options.appendChild(option_hide_more);options.appendChild(space3);options.appendChild(option_mark_as_options);options.appendChild(option_mark_as);var space0=document.createElement("SPAN");space0.innerHTML='&nbsp;|&nbsp;';var space1=document.createElement("SPAN");space1.innerHTML='&nbsp;|&nbsp;';var space2=document.createElement("SPAN");space2.innerHTML='&nbsp;|&nbsp;';var option_more=document.createElement("SPAN");option_more.id='msg_opt_more_actions_'+ID;option_more.className='message_options';option_more.onmouseover=function(){this.className='message_options_active';};option_more.onmouseout=function(){this.className='message_options'};option_more.onclick=function(){verifyOption('tr_other_more_options_',ID);if(option_more_options.value!='hide'){option_more_options.value='hide';option_more_options.src='../expressoMail1_2/templates/default/images/pressed.png';Element('tr_other_more_options_'+ID).style.display='';}
+else{option_more_options.value='show';option_more_options.src='../expressoMail1_2/templates/default/images/down.png';Element('tr_other_more_options_'+ID).style.display='none';}};option_more.innerHTML=get_lang('More Actions');var option_more_options=document.createElement('IMG');option_more_options.id='msg_opt_more_options_'+ID;option_more_options.src='../expressoMail1_2/templates/default/images/down.png';option_more_options.value='show';option_more_options.onmouseover=function(){option_more.className='message_options_active';option_more_options.src='../expressoMail1_2/templates/default/images/over.png';};option_more_options.onmouseout=function(){option_more.className='message_options';if(this.value=='show')
+{option_more_options.src='../expressoMail1_2/templates/default/images/down.png';}
+else
+{option_more_options.src='../expressoMail1_2/templates/default/images/pressed.png';}};option_more_options.onclick=function(){verifyOption('tr_other_more_options_',ID);if(this.value!='hide'){this.value='hide';option_more_options.src='../expressoMail1_2/templates/default/images/pressed.png';Element('tr_other_more_options_'+ID).style.display='';}
+else{this.value='show';option_more_options.src='../expressoMail1_2/templates/default/images/down.png';Element('tr_other_more_options_'+ID).style.display='none';}};options.appendChild(space1);options.appendChild(option_more_options);options.appendChild(option_more);var option_reply=document.createElement("SPAN");option_reply.id='msg_opt_reply_'+ID;option_reply.className='message_options';option_reply.onclick=function(){new_message('reply_with_history',ID);};option_reply.innerHTML=get_lang('Reply');option_reply.onmouseover=function(){this.className='message_options_active';};option_reply.onmouseout=function(){this.className='message_options'};option_reply.title=(preferences.use_shortcuts=='1')?get_lang('Shortcut: %1','R'):get_lang('Reply');options.appendChild(space2);var option_reply_options=document.createElement('IMG');option_reply_options.id='msg_opt_reply_options_'+ID;option_reply_options.src='../expressoMail1_2/templates/default/images/down.png';option_reply_options.value='show';option_reply_options.onmouseover=function(){option_reply_options.src='../expressoMail1_2/templates/default/images/over.png';};option_reply_options.onmouseout=function(){if(this.value=='show')
+{option_reply_options.src='../expressoMail1_2/templates/default/images/down.png';}
+else
+{option_reply_options.src='../expressoMail1_2/templates/default/images/pressed.png';}};option_reply_options.onclick=function(){verifyOption('tr_other_options_',ID);if(this.value!='hide'){this.value='hide';option_reply_options.src='../expressoMail1_2/templates/default/images/pressed.png';Element('tr_other_options_'+ID).style.display='';}
+else{this.value='show';option_reply_options.src='../expressoMail1_2/templates/default/images/down.png';Element('tr_other_options_'+ID).style.display='none';}};options.appendChild(option_reply_options);options.appendChild(option_reply);var option_forward=document.createElement("SPAN");option_forward.id='msg_opt_forward_'+ID;option_forward.className='message_options';option_forward.innerHTML=get_lang('Forward');option_forward.onclick=function(){new_message('forward',ID);};option_forward.onmouseover=function(){this.className='message_options_active';};option_forward.onmouseout=function(){this.className='message_options'};option_forward.title=(preferences.use_shortcuts=='1')?get_lang('Shortcut: %1','E'):get_lang('Forward');var space9=document.createElement("SPAN");space9.innerHTML='&nbsp;|&nbsp;';options.appendChild(space9);options.appendChild(option_forward);var option_delete=document.createElement("SPAN");option_delete.id='msg_opt_delete_'+ID;option_delete.className='message_options';option_delete.onclick=function(){proxy_mensagens.delete_msgs('null','selected','null');};option_delete.innerHTML=get_lang('Delete');option_delete.onmouseover=function(){this.className='message_options_active';};option_delete.onmouseout=function(){this.className='message_options'};option_delete.title=(preferences.use_shortcuts=='1')?get_lang('Shortcut: %1','Delete'):get_lang('Delete');var space6=document.createElement("SPAN");space6.innerHTML='&nbsp;|&nbsp;';options.appendChild(space6);options.appendChild(option_delete);tr.appendChild(td);tr.appendChild(options);tr.appendChild(next_previous_msg_td);tbody_message_options.appendChild(tr);var tr_other_options=document.createElement("TR");var tr_other_mark_options=document.createElement("TR");var tr_other_more_options=document.createElement("TR");tr_other_mark_options.id='tr_other_mark_options_'+ID;tr_other_mark_options.style.display='none';tr_other_mark_options.style.backgroundColor='#205C8E';tr_other_options.id='tr_other_options_'+ID;tr_other_options.style.display='none';tr_other_options.style.backgroundColor='#205C8E';tr_other_more_options.id='tr_other_more_options_'+ID;tr_other_more_options.style.display='none';tr_other_more_options.style.backgroundColor='#205C8E';var td_other_options=document.createElement("TD");var td_other_mark_options=document.createElement("TD");var td_other_more_options=document.createElement("TD");td_other_options.colSpan='3';td_other_mark_options.colSpan='3';td_other_more_options.colSpan='3';var div_other_options=document.createElement("DIV");var div_other_mark_options=document.createElement("DIV");var div_other_more_options=document.createElement("DIV");var block_user='<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick ="block_user_email(\''+info_msg.from.email+'\');">'+get_lang("Block Sender")+'</span> | ';var option_move='<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=wfolders.makeWindow("'+ID+'","move_to");>'+get_lang("Move")+'</span> | ';var option_print='<span onclick="print_all()" onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options">'+get_lang("Print")+'</span> | ';var option_export='<span onclick="proxy_mensagens.export_all_messages()" onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options">'+get_lang("Export")+'</span> | ';option_reply_to_all__title=(preferences.use_shortcuts=='1')?get_lang('Shortcut: %1','T'):'';var option_reply_to_all='<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick="new_message(\'reply_to_all_with_history\',\''+ID+'\');" title="'+option_reply_to_all__title+'">'+get_lang("Reply to all")+'</span> | ';var option_reply_without_history='<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=new_message("reply_without_history","'+ID+'");>'+get_lang("Reply without history")+'</span> | ';var option_reply_to_all_without_history='<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=new_message("reply_to_all_without_history","'+ID+'");>'+get_lang("Reply to all without history")+'</span>  | ';var report_error='<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=reports_window("'+currentTab+'");>'+get_lang("Report error")+'</span> | ';div_other_more_options.innerHTML+=option_move+option_print+option_export+block_user+report_error;div_other_options.innerHTML+=option_reply_without_history+option_reply_to_all_without_history+option_reply_to_all;if(use_spam_filter){if(info_msg.msg_folder=='INBOX'+cyrus_delimiter+'Spam'||(info_msg.msg_folder.match(/^user/)&&info_msg.msg_folder.match(/Spam$/))){div_other_mark_options.innerHTML+='<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick="nospam('+info_msg.msg_number+',\'null\', \''+info_msg.msg_folder+'\');">'+get_lang("Not Spam")+'</span> | ';}
+else{div_other_mark_options.innerHTML+='<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick="spam(\''+info_msg.msg_folder+'\', '+info_msg.msg_number+',\'null\');">'+get_lang("Is Spam")+'</span> | ';}}
+var space5=document.createElement("SPAN");space5.innerHTML='&nbsp;|&nbsp;';div_other_mark_options.appendChild(option_mark_as_unseen);var space4=document.createElement("SPAN");space4.innerHTML='&nbsp;|&nbsp;';div_other_mark_options.appendChild(space4);div_other_mark_options.appendChild(option_mark_important);var space7=document.createElement("SPAN");space7.innerHTML='&nbsp;|&nbsp;';div_other_mark_options.appendChild(space7);td_other_options.align='right';td_other_options.style.paddingTop='3px';td_other_options.appendChild(div_other_options);td_other_mark_options.align='right';td_other_mark_options.style.paddingTop='3px';td_other_mark_options.appendChild(div_other_mark_options);td_other_more_options.align='right';td_other_more_options.style.paddingTop='3px';td_other_more_options.appendChild(div_other_more_options);tr_other_options.appendChild(td_other_options);tbody_message_options.appendChild(tr_other_options);tr_other_more_options.appendChild(td_other_more_options);tbody_message_options.appendChild(tr_other_more_options);tr_other_mark_options.appendChild(td_other_mark_options);tbody_message_options.appendChild(tr_other_mark_options);if(info_msg.signature&&info_msg.signature.length>0)
+{var tr_signature=document.createElement("TR");var td_signature=document.createElement("TD");td_signature.className='tr_message_header';tr_signature.id='tr_signature_'+ID;td_signature.colSpan="5";tr_signature.style.display='none';for(i in info_msg.signature)
+{if(typeof(info_msg.signature[i])=='object')
+{var aux='';for(ii in info_msg.signature[i])
+{if(info_msg.signature[i][ii].indexOf("###")>-1)
+{aux+=get_lang(info_msg.signature[i][ii].substring(0,info_msg.signature[i][ii].indexOf("###")))+info_msg.signature[i][ii].substring(info_msg.signature[i][ii].indexOf("###")+3);}
+else
+{aux+=info_msg.signature[i][ii];}}
+td_signature.innerHTML+="<a onclick=\"javascript:alert('"+aux+"')\"><b><font color=\"#0000FF\">"+get_lang("More")+"...</font></b></a>";continue;}
+if(info_msg.signature[i].indexOf("#@#")>-1)
+{td_signature.innerHTML+='<span style=color:red><strong>'+get_lang(info_msg.signature[i].substring(0,info_msg.signature[i].indexOf("#@#")))+'</strong> '+info_msg.signature[i].substring(info_msg.signature[i].indexOf("#@#")+3)+'</span> <br /> ';}
+if(info_msg.signature[i].indexOf("###")>-1)
+{td_signature.innerHTML+='<span><strong>'+get_lang(info_msg.signature[i].substring(0,info_msg.signature[i].indexOf("###")))+'</strong> '+info_msg.signature[i].substring(info_msg.signature[i].indexOf("###")+3)+'</span> <br /> ';}}
+var signature_status_pos=info_msg.signature[0].indexOf('Message untouched');td_signature.id="td_signature_"+ID;if(signature_status_pos<0)
+{td.innerHTML+='&nbsp;<img style="cursor:pointer" src="templates/'+template+'/images/signed_error.gif" title="'+get_lang("Details")+'">';tr_signature.style.display='';}
+else
+{td.innerHTML+='&nbsp;<img style="cursor:pointer" src="templates/'+template+'/images/signed_table.gif" title="'+get_lang("Details")+'">';}
+td.onclick=function(){var _height=Element("div_message_scroll_"+ID).style.height;_height=parseInt(_height.replace("px",""));var _offset=130;if(this.value=='more_cert'){this.value='hide_cert';Element("div_message_scroll_"+ID).style.height=(_height+_offset)+"px";Element('tr_signature_'+ID).style.display='none';Element('td_signature_'+ID).style.display='none';}
+else{this.value='more_cert';Element("div_message_scroll_"+ID).style.height=(_height-_offset)+"px";Element('tr_signature_'+ID).style.display='';Element('td_signature_'+ID).style.display='';}};tr_signature.appendChild(td_signature);tbody_message_options.appendChild(tr_signature);}
+table_message_options.appendChild(tbody_message_options);td0.appendChild(table_message_options);tr0.appendChild(td0);tbody_message.appendChild(tr0);}
+else
+{var options=document.createElement("TD");options.setAttribute("noWrap","true");var option_edit=' | <span class="message_options" onclick="new_message(\'edit\',\''+ID+'\',\''+info_msg.Flagged+'\');">'+get_lang('Edit')+'</span>';var option_print=' | <span class="message_options" onclick="print_msg(\''+info_msg.msg_folder+'\',\''+info_msg.msg_number+'\',\''+ID+'\');">'+get_lang('Print')+'</span>';var option_hide_more=document.createElement("SPAN");option_hide_more.className='message_options';options.align='right';option_hide_more.value='more_options';option_hide_more.id='option_hide_more_'+ID;option_hide_more.innerHTML=get_lang('Show details');option_hide_more.onclick=function(){var _height=Element("div_message_scroll_"+ID).style.height;_height=parseInt(_height.replace("px",""));var _offset=35;if(this.value=='more_options'){this.innerHTML="<b><u>"+get_lang('Hide details')+"</u></b>";this.value='hide_options';Element("div_message_scroll_"+ID).style.height=(_height-_offset)+"px";Element('table_message_others_options_'+ID).style.display='';}
+else{this.innerHTML=get_lang('Show details');this.value='more_options';Element("div_message_scroll_"+ID).style.height=(_height+_offset)+"px";Element('table_message_others_options_'+ID).style.display='none';}};options.appendChild(option_hide_more);options_actions=document.createElement('SPAN');options_actions.innerHTML=option_edit+option_print;options.appendChild(options_actions);tr.appendChild(td);tr.appendChild(options);tr.appendChild(next_previous_msg_td);tbody_message_options.appendChild(tr);table_message_options.appendChild(tbody_message_options);td0.appendChild(table_message_options);tr0.appendChild(td0);tbody_message.appendChild(tr0);var important_message=document.createElement("INPUT");important_message.id="is_important_"+ID;important_message.name="is_important";important_message.type="HIDDEN";important_message.value=(info_msg.Importance==""||info_msg.Importance=="Normal")?"0":"1";options.appendChild(important_message);}
+var table_message_others_options=document.createElement("TABLE");table_message_others_options.id='table_message_others_options_'+ID;table_message_others_options.width="100%";table_message_others_options.style.display='none';if(navigator.appName.indexOf('Internet Explorer')>0){table_message_others_options.className="table_message_options_ie";}else{table_message_others_options.className="table_message_options";}
+var tbody_message_others_options=document.createElement("TBODY");var tr1=document.createElement("TR");tr1.className="tr_message_header";if(info_msg.from){var td1=document.createElement("TD");td1.innerHTML=get_lang("From: ");td1.appendChild(deny_email(info_msg.from.email));td1.width="7%";}
+if(info_msg.sender){var tr111=document.createElement("TR");tr111.className="tr_message_header";var td111=document.createElement("TD");td111.innerHTML=get_lang("Sent by")+": ";td111.appendChild(deny_email(info_msg.sender.email));td111.setAttribute("noWrap","true");var sender=document.createElement("TD");sender.id="sender_"+ID;var sender_values=document.createElement("INPUT");sender_values.id="sender_values_"+ID;sender_values.type="HIDDEN";sender_values.value=info_msg.sender.full;sender.innerHTML+=draw_plugin_cc(ID,info_msg.sender.full);sender.className="header_message_field";tr111.appendChild(td111);tr111.appendChild(sender);tr111.appendChild(sender_values);tbody_message_others_options.appendChild(tr111);}
+var from=document.createElement("TD");from.id="from_"+ID;if(info_msg.from){from.innerHTML=info_msg.from.full;}
+if(info_msg.Draft!="X"){from.innerHTML+=draw_plugin_cc(ID,info_msg.from);tbody_message_others_options.appendChild(tr1);}
+from.className="header_message_field";var from_values=document.createElement("INPUT");from_values.id="from_values_"+ID;from_values.type="HIDDEN";if(info_msg.from){from_values.value=info_msg.from.full;}
+var local_message=document.createElement("INPUT");local_message.id="is_local_"+ID;local_message.name="is_local";local_message.type="HIDDEN";local_message.value=(info_msg.local_message)?"1":"0";if(info_msg.from){tr1.appendChild(td1);}
+tr1.appendChild(from);tr1.appendChild(from_values);tr1.appendChild(local_message);if(info_msg.reply_to){var tr11=document.createElement("TR");tr11.className="tr_message_header";var td11=document.createElement("TD");td11.innerHTML=get_lang("Reply to")+": ";td11.setAttribute("noWrap","true");var reply_to=document.createElement("TD");reply_to.id="reply_to_"+ID;var reply_to_values=document.createElement("INPUT");reply_to_values.id="reply_to_values_"+ID;reply_to_values.type="HIDDEN";reply_to_values.value=info_msg.reply_to;$.each(break_comma(info_msg.reply_to),function(index,value){reply_to.innerHTML+=draw_plugin_cc(ID,value);})
+reply_to.className="header_message_field";tr11.appendChild(td11);tr11.appendChild(reply_to);tr11.appendChild(reply_to_values);tbody_message_others_options.appendChild(tr11);}
+var tr2=document.createElement("TR");tr2.className="tr_message_header";var td2=document.createElement("TD");td2.width="7%";td2.innerHTML=get_lang("To: ");var to=document.createElement("TD");to.id="to_"+ID;var to_values=document.createElement("INPUT");to_values.id="to_values_"+ID;to_values.type="HIDDEN";to_values.value=info_msg.toaddress2;var input_current_folder=document.createElement('input');input_current_folder.id="input_folder_"+ID;input_current_folder.name="input_folder";input_current_folder.type="hidden";input_current_folder.value=info_msg.msg_folder;td2.appendChild(input_current_folder);if(info_msg.toaddress2!=null)
+{toaddress_array[ID]=break_comma(info_msg.toaddress2);var notValidUser=false;if(toaddress_array[ID].length>1)
+{to.innerHTML+=draw_plugin_cc(ID,toaddress_array[ID][0]);var div_toaddress=document.createElement("SPAN");div_toaddress.id="div_toaddress_"+ID;div_toaddress.style.display="";div_toaddress.innerHTML+=" (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+ID+"','to');>"+get_lang('more')+"</a>)";to.appendChild(div_toaddress);}
+else
+{toAdd=toaddress_array[ID].toString()
+if(trim(toAdd)!=""){toAdd=toAdd.replace("<","&lt;").replace(">","&gt;");}else{toAdd=get_lang("without destination");notValidUser=true;}
+to.innerHTML+=draw_plugin_cc(ID,toAdd,notValidUser,notValidUser);}
+to.className="header_message_field";tr2.appendChild(td2);tr2.appendChild(to);tr2.appendChild(to_values);}
+tbody_message_others_options.appendChild(tr2);if(info_msg.cc){var tr3=document.createElement("TR");tr3.className="tr_message_header";var td3=document.createElement("TD");td3.innerHTML="CC: ";var cc=document.createElement("TD");cc.id="cc_"+ID;var cc_values=document.createElement("INPUT");cc_values.id="cc_values_"+ID;cc_values.type="HIDDEN";cc_values.value=info_msg.cc;ccaddress_array[ID]=break_comma(info_msg.cc);if(ccaddress_array[ID].length>1){var div_ccaddress=document.createElement("SPAN");div_ccaddress.id="div_ccaddress_"+ID;var div_ccaddress_full=document.createElement("SPAN");div_ccaddress_full.id="div_ccaddress_full_"+ID;div_ccaddress.style.display="";cc.innerHTML=draw_plugin_cc(ID,ccaddress_array[ID][0]);div_ccaddress.innerHTML+=" (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+ID+"','cc');>"+get_lang('more')+"</a>)";cc.appendChild(div_ccaddress);}
+else{cc.innerHTML=draw_plugin_cc(ID,info_msg.cc);}
+cc.className="header_message_field";tr3.appendChild(td3);tr3.appendChild(cc);tr3.appendChild(cc_values);tbody_message_others_options.appendChild(tr3);}
+if(info_msg.bcc)
+{var tr3=document.createElement("tr");tr3.className="tr_message_header";var td3=document.createElement("td");td3.innerHTML=get_lang("BCC")+" : ";var cco=document.createElement("td");cco.id="cco_"+ID;var cco_values=document.createElement("input");cco_values.id="cco_values_"+ID;cco_values.type="hidden";cco_values.value=info_msg.bcc;ccoaddress_array[ID]=info_msg.bcc.split(",");if(ccoaddress_array[ID].length>1){var div_ccoaddress=document.createElement("SPAN");div_ccoaddress.id="div_ccoaddress_"+ID;var div_ccoaddress_full=document.createElement("SPAN");div_ccoaddress_full.id="div_ccoaddress_full_"+ID;div_ccoaddress.style.display="";cco.innerHTML=ccoaddress_array[ID][0];div_ccoaddress.innerHTML+=" (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+ID+"','cco');>"+get_lang('more')+"</a>)";cco.appendChild(div_ccoaddress);}
+else{cco.innerHTML=info_msg.bcc;}
+cco.className="header_message_field";tr3.appendChild(td3);tr3.appendChild(cco);tr3.appendChild(cco_values);tbody_message_others_options.appendChild(tr3);}
+var tr4=document.createElement("TR");tr4.className="tr_message_header";var td4=document.createElement("TD");td4.innerHTML=get_lang("Date: ");var date=document.createElement("TD");date.id="date_"+ID;date.innerHTML=info_msg.fulldate;var date_day=document.createElement("INPUT");date_day.id="date_day_"+ID;date_day.type="HIDDEN";date_day.value=info_msg.msg_day;var date_hour=document.createElement("INPUT");date_hour.id="date_hour_"+ID;date_hour.type="HIDDEN";date_hour.value=info_msg.msg_hour
+date.className="header_message_field";tr4.appendChild(td4);tr4.appendChild(date);tr4.appendChild(date_day);tr4.appendChild(date_hour);tbody_message_others_options.appendChild(tr4);var tr5=document.createElement("TR");tr5.className="tr_message_header";var td5=document.createElement("TD");td5.innerHTML=get_lang("Subject");var subject=document.createElement("TD");subject.id="subject_"+ID;subject.innerHTML=html_entities(info_msg.subject);subject.className="header_message_field";if(defaultCalendar=="expressoCalendar"&&$("#expressoCalendarid")[0]){var new_task_logo=document.createElement("IMG");new_task_logo.title="Criar uma nova tarefa a partir deste email.";new_task_logo.alt="Criar uma nova tarefa a partir deste email.";new_task_logo.src="./templates/default/images/big-task.png";new_task_logo.style.cursor="pointer";new_task_logo.style.marginLeft="5px";new_task_logo.onclick=function(){import_implements_calendar();DataLayer.dispatchPath="../prototype/";var path="../prototype/modules/calendar/";taskDetails(decodeCreateSchedulable('task',ID),true,path,true);}
+var new_event_logo=document.createElement("IMG");new_event_logo.title="Criar evento a partir deste email";new_event_logo.alt="Criar evento a partir deste email";new_event_logo.src="./templates/default/images/big-event.png";new_event_logo.style.cursor="pointer";new_event_logo.style.marginLeft="5px";new_event_logo.onclick=function(){import_implements_calendar();DataLayer.dispatchPath="../prototype/";var path="../prototype/modules/calendar/";eventDetails(decodeCreateSchedulable('event',ID),true,path,true);}
+subject.appendChild(new_event_logo);subject.appendChild(new_task_logo);}
+tr5.appendChild(td5);tr5.appendChild(subject);tbody_message_others_options.appendChild(tr5);var update_labeleds_msg=function(){DataLayer.remove('labeled',false);var labels=DataLayer.get("labeled",{filter:['AND',['=','folderName',current_folder],['=','messageNumber',folder_id]],criteria:{deepness:2}});if(labels.length!=0){var tr8=document.createElement("TR");tr8.className="tr_message_header";var td8=document.createElement("TD");td8.innerHTML=get_lang("Labels: ");var markers=document.createElement("TD");markers.id="markers_"+ID;for(var i=0;i<labels.length;i++){fontColor=labels[i].label.fontColor;borderColor=labels[i].label.borderColor;backgroundColor=labels[i].label.backgroundColor;nameLabel=labels[i].label.name;id=labels[i].id;markers.innerHTML+="<div  style='height: 15px; background:"+backgroundColor+"; float: left; -webkit-border-radius: 3px; -moz-border-radius: 3px; margin:0 0 1px 1px; border: 1px solid "+borderColor+"'><span style='color: "+fontColor+"; margin: 5px;'>"+nameLabel+"</span><span class='removeLabeledMsg' id='"+id+"' title='"+get_lang("Remove Label")+"'>x</span></div>";}
+$(markers).find('span.removeLabeledMsg').click(function(event){var id_labeled=$(event.target).attr("id");DataLayer.remove('labeled',id_labeled);DataLayer.commit(false,false,function(){var index_folder=id_labeled.lastIndexOf('/');var folder_name=id_labeled.slice(0,index_folder);var index_number=id_labeled.lastIndexOf('#');var msg_number=id_labeled.slice(index_folder+1,index_number);updateLabelsColumn({msg_number:msg_number,boxname:folder_name,labels:false});update_labeleds_msg();tbody_message_others_options.removeChild(tr8);});});markers.className="header_message_field";tr8.appendChild(td8);tr8.appendChild(markers);tbody_message_others_options.appendChild(tr8);}}
+if(info_msg.attachments&&info_msg.attachments.length>0)
+{var tr6=document.createElement("TR");tr6.className="tr_message_header";var td6=document.createElement("TD");td6.innerHTML=get_lang("Attachments: ");var attachments=document.createElement("TD");td6.valign="top";attachments.align='left';if(info_msg.attachments.length>=1){if(info_msg.attachments.length>1){var link_attachment=document.createElement("A");if(proxy_mensagens.is_local_folder(current_folder))
+link_attachment.setAttribute("href","javascript:expresso_local_messages.download_all_local_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");else
+link_attachment.setAttribute("href","javascript:download_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");link_attachment.innerHTML=" "+info_msg.attachments.length+' '+get_lang('files')+' :: '+get_lang('Download all atachments');attachments.appendChild(link_attachment);}
+if(parseInt(preferences.remove_attachments_function))
+{attachments.appendChild(document.createTextNode('  '));var del_attachments=document.createElement("A");del_attachments.setAttribute("href","javascript:remove_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");del_attachments.innerHTML=get_lang('remove all attachments');attachments.appendChild(del_attachments);}
+attachments.appendChild(document.createElement('BR'));}
+attachments.id="attachments_"+ID;var parserImport=false;for(var i=0;i<info_msg.attachments.length;i++)
+{var import_url='$this.db_functions.import_vcard&msg_folder='+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"&idx_file="+i+"&encoding="+info_msg.attachments[i].encoding;var link_attachment=document.createElement("a");link_attachment.setAttribute("class","type_images");link_attachment.style.display="block";link_attachment.setAttribute("href",proxy_mensagens.link_anexo(info_msg,i));link_attachment.innerHTML=url_decode(info_msg.attachments[i].name)+" ("+borkb(info_msg.attachments[i].fsize)+")";if((url_decode(info_msg.attachments[i].name).indexOf(".ics")!=-1)||(url_decode(info_msg.attachments[i].name).indexOf(".vcard")!=-1))
+{var link_import_attachment=new Image();link_import_attachment.src="templates/"+template+"/images/new.png";link_import_attachment.setAttribute("onclick","javascript:import_calendar('"+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"&idx_file="+i+"&encoding="+info_msg.attachments[i].encoding+"'); return false;");link_import_attachment.title=get_lang("Import to calendar");link_import_attachment.style.display="inline";link_import_attachment.align="top";link_import_attachment.style.marginLeft="5px";link_import_attachment.style.cursor="pointer";link_attachment.appendChild(link_import_attachment);parserImport=true;}
+if((url_decode(info_msg.attachments[i].name).indexOf(".eml")!=-1))
+{var link_open_msg=new Image();link_open_msg.src="templates/"+template+"/images/email.png";link_open_msg.setAttribute("onclick","javascript:open_msg_part('"+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"'); return false;");link_open_msg.title=get_lang("Open message");link_open_msg.align="top";link_open_msg.style.marginLeft="5px";link_open_msg.style.cursor="pointer";link_attachment.appendChild(link_open_msg);}
+attachments.appendChild(link_attachment);}
+tr6.appendChild(td6);tr6.appendChild(attachments);tbody_message_others_options.appendChild(tr6);}
+if(parserImport){$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(),async:true,success:function(data){data=connector.unserialize(data);if(typeof(data)=="object"){var calendarPermission=data.calendar;data=data.action;}
+switch(parseInt(data)){case 5:$('.type_images').append('<img class="loader" src="templates/default/images/ajax-loader.gif" align="top" style="margin-left: 5px; cursor: pointer; display: inline">');$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&selected=true',success:function(msg){$('.type_images').append('<img src="../prototype/modules/mail/img/flagDone.png" align="top" style="margin: 3px 0 0 5px; cursor: pointer; display: inline">').parent().find('.loader').remove();write_msg(((connector.unserialize(msg))=="ok")?"Seu evento foi Atualizado com sucesso":"Ocorreu um erro ao atualizar evento");}});return;break;case 4:$('.type_images').append('<img src="../prototype/modules/mail/img/flagDone.png" align="top" style="margin: 3px 0 0 5px; cursor: pointer; ">');write_msg("Seu evento encontra-se atualizado.");return;break;case 12:write_msg('Este evento não existe mais.');return;break;}}});}
+var div=document.createElement("DIV");div.id="div_message_scroll_"+ID;div.style.background='WHITE';div.style.overflow="auto";table_message_others_options.appendChild(tbody_message_others_options);var tr=document.createElement("TR");tr.className="tr_message_header";var td=document.createElement("TD");td.colspan='2';td.style.fontSize='10pt';td.style.fontFamily='Arial,Verdana';td.style.verticalAlign='top';td.style.height='100%';div.appendChild(table_message_others_options);var imgTag=info_msg.body.match(/(<img[^>]*src[^>=]*=['"]?[^'">]*["']?[^>]*>)|(<[^>]*(style[^=>]*=['"][^>]*background(-image)?:[^:;>]*url\()[^>]*>)/gi);var newBody=info_msg.body;if(!info_msg.showImg&&imgTag)
+{var domains='';var blocked=false;var forbidden=true;if(preferences.notification_domains!=null&&typeof(preferences.notification_domains)!='undefined')
+{domains=preferences.notification_domains.split(',');for(var j=0;j<imgTag.length;j++)
+{for(var i=0;i<domains.length;i++)
+{if(imgTag[j].match(/cid:([\w\d]){5,}/)||imgTag[j].match(/src=\"\.\/inc\/get_archive\.php/g))
+{forbidden=false;continue;}
+imgSource=imgTag[j].match(/=['"](http:\/\/)+[^'"\/]*/);if(imgSource&&imgSource.toString().substr(5).match(domains[i]))
+forbidden=false;}
+if(forbidden)
+{newBody=newBody.replace(imgTag[j],"<img src='templates/"+template+"/images/forbidden.png'>");blocked=true;}}
+if(blocked)
+{var showImgLink=document.createElement('DIV');showImgLink.id="show_img_link_"+ID;showImgLink.onclick=function(){show_msg_img(info_msg.msg_number,info_msg.msg_folder)};showImgLink.className="show_img_link";showImgLink.innerHTML=get_lang("Show images from")+": "+info_msg.from.email;td.appendChild(showImgLink);}}}
+td.appendChild(div);tr.appendChild(td)
+tbody_message.appendChild(tr);var tr=document.createElement("TR");tr.className="tr_message_body";var td=document.createElement("TD");var _body=document.createElement('div');_body.id='body_'+ID;_body.innerHTML=newBody;_body.style.marginLeft='5px';var _elements=_body.getElementsByTagName('*');for(var i=0;i<_elements.length;i++)
+if(_elements[i].attributes&&_elements[i].attributes.getNamedItem('id'))
+_elements[i].attributes.removeNamedItem('id');div.appendChild(_body);function mailto(link)
+{var mail=link.href.substr(7);link.onclick=function()
+{new_message_to(mail);return false;};}
+var links=div.getElementsByTagName('a');for(var i=0;i<links.length;i++){try{if(links.item(i).href.indexOf('mailto:')===0){mailto(links.item(i));}
+else{var anchor_pattern="http://"+location.host+location.pathname+"#";if((links.item(i).href.indexOf('javascript:')!==0)&&(links.item(i).href.indexOf(anchor_pattern)!==0))
+links.item(i).setAttribute('target','_blank');}}catch(e){}}
+if((info_msg.thumbs)&&(info_msg.thumbs.length>0)){var thumbs=jQuery.parseJSON(info_msg.thumbs);var div_thumbs=document.createElement("div");div_thumbs.setAttribute("class","expressomail-thumbs");div_thumbs.setAttribute("className","expressomail-thumbs");var div_thumbs_lbl=document.createElement("DIV");div_thumbs_lbl.setAttribute("class","expressomail-thumbs-label");div_thumbs_lbl.setAttribute("className","expressomail-thumbs-label");var div_thumbs_lbl_sp=document.createElement("SPAN");div_thumbs_lbl_sp.setAttribute("class","message_options");div_thumbs_lbl_sp.setAttribute("className","message_options");var div_thumbs_lbl_st=document.createElement("STRONG");div_thumbs_lbl_st.innerHTML=info_msg.attachments.length+" "+get_lang("attachment")+(info_msg.attachments.length>1?"s":"")+" "+get_lang("in this message");var div_thumbs_lbl_a=document.createElement("A");if(info_msg.thumbs.length>1){if(proxy_mensagens.is_local_folder(current_folder))
+div_thumbs_lbl_a.setAttribute("href","javascript:expresso_local_messages.download_all_local_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");else
+div_thumbs_lbl_a.setAttribute("href","javascript:download_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");div_thumbs_lbl_a.innerHTML=get_lang('Download all atachments');}else{div_thumbs_lbl_a.setAttribute("style","display:none; visibility:hidden;");}
+div_thumbs_lbl_sp.appendChild(div_thumbs_lbl_st);div_thumbs_lbl_sp.appendChild(document.createTextNode(' :: '));div_thumbs_lbl_sp.appendChild(div_thumbs_lbl_a);div_thumbs_lbl.appendChild(div_thumbs_lbl_sp);var div_thumbs_lbl_sp2=document.createElement("SPAN");div_thumbs_lbl_sp2.setAttribute("class","message_tips");div_thumbs_lbl_sp2.setAttribute("className","message_tips");div_thumbs_lbl_sp2.innerHTML=get_lang("<strong>Tip:</strong> <span>For faster save, click over the image with <em>right button</em>.</span>");var ul_thumbs_list=document.createElement("UL");ul_thumbs_list.setAttribute("class","expressomail-thumbs-list");ul_thumbs_list.setAttribute("className","expressomail-thumbs-list");var msg=info_msg.msg_number;var fdr=info_msg.msg_folder;var i=0;if(thumbs){jQuery.each(thumbs,function(i,thumb){if(fdr.indexOf("local_")>=0){var href=info_msg.array_attach[i].url+'&image=true';var src=info_msg.array_attach[i].url+'&image=thumbnail';i++;}else{var href='./inc/get_archive.php?msgFolder='+utf8_decoder(fdr)+'&msgNumber='+msg+'&indexPart='+thumb.pid+'&image=true';var src='inc/get_archive.php?msgFolder='+utf8_decoder(fdr)+'&msgNumber='+msg+'&indexPart='+thumb.pid+'&image=thumbnail';}
+var msgid=fdr+";;"+msg+";;"+i+";;"+thumb.pid+";;"+thumb.encoding;var image_info='{"folder":"'+fdr+'","message":"'+msg+'","thumbIndex":"'+i+'","pid":"'+thumb.pid+'","encoding":"'+thumb.encoding+'","type":"'+thumb.type+'"}';var image='<img id="'+msgid+'" title="'+
+get_lang('Click here do view (+)')+'" src="'+src+'" style="width:auto;height:100%;" />';var content='<a title="'+thumb.name+'" rel="thumbs'+ID+'" class="expressomail-thumbs-link" onMouseDown="save_image(event,this,\''+thumb.type+'\')" href="'+href+'" onclick="window.open(\''+href+'\',\'mywindow\',\'width=700,height=600,scrollbars=yes\');return false;">'+image+'</a>';content+='<input id="thumb_'+ID+'_'+i+'" type="hidden" value="'+escape(image_info)+'" />';jQuery(ul_thumbs_list).append('<li>'+content+'</li>');});div_thumbs.appendChild(div_thumbs_lbl);div_thumbs.appendChild(div_thumbs_lbl_sp2);div_thumbs.appendChild(ul_thumbs_list);}else{div_thumbs.appendChild(div_thumbs_lbl);div_thumbs.appendChild(div_thumbs_lbl_sp2);div_thumbs.innerHTML=div_thumbs.innerHTML+info_msg.thumbs;}
+div.appendChild(div_thumbs);}
+table_message.appendChild(tbody_message);content.appendChild(table_message);resizeWindow();var msg_number=document.createElement('INPUT');msg_number.id="msg_number_"+ID;msg_number.type="hidden";msg_number.value=info_msg.msg_number;content.appendChild(msg_number);if(preferences.show_head_msg_full==1)
+{option_hide_more.onclick();if(Element('div_toaddress_'+ID)!=null)
+show_div_address_full(ID,'to');if(Element('div_ccaddress_'+ID)!=null)
+show_div_address_full(ID,'cc');}
+var jcarousel=false;if(jcarousel){jQuery(document).ready(function(){jQuery('.expressomail-thumbs-list').attr('id','expressomail-thumbs-list'+ID).addClass('jcarousel-skin-default').jcarousel();jQuery('.expressomail-thumbs-link img').attr('style','');jQuery(".expressomail-thumbs-list li a").attr('onclick','return true;');jQuery(".expressomail-thumbs-list li a").fancybox({'hideOnContentClick':true,'type':'image','titlePosition':'over','titleFormat':function(name,currentArray,currentIndex,currentOpts){var image_info=$('#thumb_'+ID+'_'+currentIndex).val();return'<div id="fancybox-title" class="fancybox-title-over" style="width: 100%; display: block;">'+'<div id="fancybox-title-over">'+'<a title="Anterior" onclick="javascript:$.fancybox.prev();" style="float:left;">'+'<img src="./templates/'+template+'/images/left_arrow_white.png" width="30" height="30" />'+'</a>'+'<a title="Baixar imagem" onclick="javascript:save_image2(\''+image_info+'\');" style="padding:0 5px;">'+'<img src="./templates/'+template+'/images/image_down.png" width="22" height="22" />'+'</a>'+'<a title="Baixar todas de uma vez" onclick="javascript:download_all_attachments(\''+info_msg.msg_folder+"','"+info_msg.msg_number+'\')" style="padding:0 5px;">'+'<img src="./templates/'+template+'/images/package_down.png" width="26" height="26" />'+'</a>'+'<span style="margin-left:5px; margin-top:7px; position:absolute;">'+name+'</span>'+'<a title="Próxima" onclick="javascript:$.fancybox.next();" style="float:right;">'+'<img src="./templates/'+template+'/images/right_arrow_white.png" width="30" height="30" />'+'</a>'+'</div>'+'</div>';}});});}
+if(is_webkit){var ev=document.createEvent('MouseEvents');ev.initEvent('click',false,true);var divScroll=Element('div_message_scroll_'+ID);if(divScroll){divScroll.setAttribute('tabindex','-1');divScroll.onclick=function(){setTimeout(function(){$("#div_message_scroll_"+ID).focus();},0);};divScroll.dispatchEvent(ev);}}
+else $("#div_message_scroll_"+ID).focus();update_labeleds_msg();resizeWindow();$("#div_message_scroll_"+ID).scrollTo(0,400,{queue:true});}
+function changeLinkState(el,state){el.innerHTML=get_lang(state);switch(state){case'important':{el.onclick=function(){changeLinkState(el,'normal');proxy_mensagens.proxy_set_message_flag(currentTab.substr(0,currentTab.indexOf("_r")),'flagged');write_msg(get_lang('Message marked as ')+get_lang("Important"))}
+break;}
+case'normal':{el.onclick=function(){var _this=this;proxy_mensagens.proxy_set_message_flag(currentTab.substr(0,currentTab.indexOf("_r")),'unflagged',function(success){if(success){changeLinkState(_this,'important');write_msg(get_lang('Message marked as ')+get_lang("Normal"));}});}
+break;}
+case'unseen':{el.onclick=function(){changeLinkState(el,'seen');proxy_mensagens.proxy_set_message_flag(currentTab.substr(0,currentTab.indexOf("_r")),'unseen');write_msg(get_lang('Message marked as ')+get_lang("unseen"))}
+break;}
+case'seen':{el.onclick=function(){changeLinkState(el,'unseen');proxy_mensagens.proxy_set_message_flag(currentTab.substr(0,currentTab.indexOf("_r")),'seen');write_msg(get_lang('Message marked as ')+get_lang("seen"))}
+break;}
+default:{break;}}}
+function mySplit(val){return val.split(/,\s*/);}
+function extractLast(term){return mySplit(term).pop();}
+function draw_email_box(input_data,location,personal,shared){if($.trim(input_data)!=""){var box_data=valid_emails(input_data);var html=DataLayer.render("../prototype/modules/mail/templates/emailBox.ejs",box_data);var newBox=location.before(html).prev();box_actions(newBox);if((preferences.expressoMail_ldap_identifier_recipient||personal)&&$(newBox).hasClass("invalid-email-box")){show_detais(newBox,input_data,personal,shared);}else{$(newBox).find(".box-loading").remove();}}}
+function valid_emails(email){var ContactBox={name:"",email:"",valid:false};var reSimpleEmail=/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[_a-z0-9-]+(\.[_a-z0-9-]+)+$/;var reComplexEmail=/<([^<]*)>[\s]*$/;var validation=email.split('"');var complexValidation=function(complexMail){var Objct={};if($.trim(complexMail[1]).match(reComplexEmail)){if($.trim(complexMail[1]).match(reComplexEmail).length){Objct['email']=$.trim(complexMail[1]).match(reComplexEmail)[1];}}else{Objct['email']=$.trim(complexMail[1]);}
+Objct['name']=complexMail[0];Objct['valid']=reSimpleEmail.test(Objct['email'].toLowerCase());return Objct;}
+switch(validation.length){case 1:validation.unshift("");ContactBox=complexValidation(validation);break;case 2:ContactBox=complexValidation(validation);break;case 3:validation.shift();ContactBox=complexValidation(validation);break;default:if($.trim(validation[validation.length-1]).match(reComplexEmail)){if($.trim(validation[validation.length-1]).match(reComplexEmail).length){ContactBox.mail=$.trim(validation[validation.length-1]).match(reComplexEmail)[1];}}else{ContactBox.mail=$.trim(complexMail[1]);}
+ContactBox.valid=reSimpleEmail.test(ContactBox.mail.toLowerCase());}
+return ContactBox;}
+function input_keydowns(input,ID){var f9=false;input.keydown(function(e){f9=false;focusIn=input;var focusing=input.parent().find(".email-text");if(parseInt(preferences.use_dynamic_contacts)&&!input.hasClass("box-input")){if(e.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){e.preventDefault();return false;}
+if((e.keyCode==27)&&$(this).data("autocomplete").menu.active){e.stopPropagation();e.preventDefault();}
+if(e.keyCode==$.ui.keyCode.ENTER&&$(this).data("autocomplete").menu.active){e.preventDefault();return false;}
+if(e.keyCode==$.ui.keyCode.DELETE&&$(this).data("autocomplete").menu.active){if($($(this).data("autocomplete").menu.element).find(".ui-state-hover").parents("li:first").hasClass("dynamic-recent"))
+$($(this).data("autocomplete").menu.element).find(".ui-state-hover").next().trigger("click");return false;}}
+if((e.keyCode)==120){f9=true;emQuickSearch($(this).val(),"."+$(this).parents("tr:first").attr('class').split("-")[0],ID,undefined,true);e.preventDefault();return false;}
+if(e.keyCode==13||e.keyCode==9||(e.keyCode==191&&!e.shiftKey)){if(e.keyCode==13){e.preventDefault();}
+if(input.val()!=""){if(e.keyCode==188&&!e.shiftKey&&input.val().split("\"").length>1){return;}
+if(e.keyCode!=9)
+e.preventDefault();draw_email_box(input.val(),input);if(input.hasClass("box-input")){input.remove();focusing.focus();return;}}
+if(input.length)
+input.val("");}
+if((e.keyCode==8||e.keyCode==37)&&input.val()==""&&input.prev().hasClass("box")){e.preventDefault();input.prev().focus();return;}
+if(e.keyCode==190&&e.shiftKey&&input.val().length==getPosition(input[0])){input.val(input.val()+">");draw_email_box(input.val(),input);e.preventDefault();input.val("");if(input.hasClass("box-input")){input.remove();focusing.focus();return;}}
+setTimeout(function(){if(input.val()[input.val().length-1]==";"){draw_email_box(input.val().substring(0,input.val().length-1),input);input.val("");}else if(input.val()[input.val().length-1]==","){draw_email_box(input.val().substring(0,input.val().length-1),input);input.val("");}},100);setTimeout(function(){input_search=$(input).val();var char=input.val().charAt(input.val().length-1);var maiusculas=RegExp("[A-Z]");var tamanho=0;if(char==">"){for(i=0;i<input.val().length;i++){if(maiusculas.test(input.val().substr(i,1))==true){tamanho+=9;}
+else{tamanho+=7.2;}}
+input.css("width",tamanho);}
+else{input.css("width",15+(input.val().length*9));}
+input.parent().scrollTo(":last");},10);}).focusout(function(e){var these=$(this);function makeBoxMail(){if(canMakeBox&&!fastSearch){if(!(f9||click||$(this).parents("tr:first").find("button").hasClass("ui-state-active"))){if($(input).val()!="")
+draw_email_box(input.val(),input);if(input.hasClass("box-input"))
+input.remove();$(input).val("");input_search="";}
+f9=false;click=false;}
+canMakeBox=true;fastSearch=false;}
+setTimeout(makeBoxMail,250);}).bind("paste",function(e){var pthis=$(this);setTimeout(function(){if(pthis.val().split('"').length>1){var str=break_comma(pthis.val());}else{var str=pthis.val().replace(/[,;\t\n]/gi,",");str=str.split(",");}
+if(str.length!=1){$.each(str,function(index,value){draw_email_box(value,pthis);});}else if(str[0].split(" ").length==1){draw_email_box(str[0],pthis);}else{$(pthis).val(str[0]);return false;}
+$(pthis).val("");},50);});if(input.hasClass("box-input")){input.css("max-width",parseInt(input.parents(".email-area:first").css("width"))-15);input.trigger("keydown");input.focus();}}
+var input_search="";var click=false;function box_actions(box){box.keydown(function(e){switch(e.keyCode){case $.ui.keyCode.LEFT:if($(this).prev().hasClass("box"))
+$(this).removeClass("box-selected").prev().focus();break;case $.ui.keyCode.RIGHT:if($(this).next().hasClass("box"))
+$(this).removeClass("box-selected").next().focus();else
+$(this).removeClass("box-selected").next().focus();break;case $.ui.keyCode.HOME:e.preventDefault();$(this).parents(".email-area").find("div:first").focus();break;case $.ui.keyCode.END:e.preventDefault();$(this).parents(".email-area").find("div:last").focus();break;case $.ui.keyCode.DELETE:if($(this).next().hasClass("box"))
+$(this).next().focus();else
+$(this).next().focus();$(this).remove();break;case $.ui.keyCode.BACKSPACE:if($(this).prev().hasClass("box"))
+$(this).removeClass("box-selected").prev().focus();else if($(this).next().hasClass("box"))
+$(this).next().focus();else
+$(this).next().focus();$(this).remove();e.preventDefault();break;case $.ui.keyCode.ENTER:e.preventDefault();$(this).trigger("dblclick");break;}}).dblclick(function(e){var input=$(this).find("input").clone();input.css("display","inline-block");$(this).before(input);$(this).remove();$(input).focus();input_keydowns(input,currentTab);}).click(function(){$(this).focus();}).focus(function(){$(this).parent().find("div").removeClass("box-selected");$(this).addClass("box-selected");}).focusout(function(){$(this).removeClass("box-selected");}).draggable({revert:'invalid',helper:'clone',stack:"body",containment:".new-msg-head-data",start:function(e,ui){$(this).parent().droppable("disable");},stop:function(e,ui){$(this).parent().droppable("enable");}});}
+function show_detais(box,value,personal,shared){var ldap_id=preferences.expressoMail_ldap_identifier_recipient;var group=(personal!=undefined?(personal=="G"?true:false):false);shared=shared?shared:false;if(group){REST.get("/"+(shared?"shared":"")+"group/"+value,{},function(data){if(!data.error){if(data.collection.error)
+box.find(".box-loading").remove();else{box.find(".box-loading").removeClass("box-loading").addClass("box-info");box.addClass("box-"+value).removeClass("invalid-email-box");loadGroupBox(data.collection,".box-"+value);box.unbind("dblclick").bind("dblclick",function(e){new $.Zebra_Dialog(get_lang("Impossible editing this contact, but it's possible to remove it"),{'buttons':false,'modal':false,'position':['right - 20','top + 20'],'auto_close':3000});}).find(".box-input").val("\""+data.collection.data[1].value+"\" <"+$.trim(data.collection.data[2].value)+">");box.find(".email-box-value").html((data.collection.data[1].value.length>18?data.collection.data[1].value.substring(0,15)+"...":data.collection.data[1].value))}}else{box.find(".box-loading").remove();}});return;}
+if(personal){REST.get("/"+(shared?"shared":"")+"personalContact/"+value,{},function(data){if(!data.error){if(data.collection.error)
+box.find(".box-loading").remove();else{var item=normalizeContact(data.collection.itens[0].data);box.find(".box-loading").removeClass("box-loading").addClass("box-info");box.addClass("box-"+value).removeClass("invalid-email-box");loadExtraLDAPBox(item,".box-"+value);box.unbind("dblclick").bind("dblclick",function(e){new $.Zebra_Dialog(get_lang("Impossible editing this contact, but it's possible to remove it"),{'buttons':false,'modal':false,'position':['right - 20','top + 20'],'auto_close':3000});}).find(".box-input").val("\""+item.name+"\" <"+$.trim(item.email)+">");box.find(".email-box-value").html(normalizeBoxName(item.name,item.value));}}else{box.find(".box-loading").remove();}});return;}
+REST.get("/usersldap",{field:ldap_id,value:value},function(data){if(!data.error){if(data.collection.error)
+box.find(".box-loading").remove();else{var item=normalizeContact(data.collection.itens[0].data);box.find(".box-loading").removeClass("box-loading").addClass("box-info");box.addClass("box-"+value).removeClass("invalid-email-box");loadExtraLDAPBox(item,".box-"+value);box.unbind("dblclick").bind("dblclick",function(e){new $.Zebra_Dialog(get_lang("Impossible editing this contact, but it's possible to remove it"),{'buttons':false,'modal':false,'position':['right - 20','top + 20'],'auto_close':3000});}).find(".box-input").val("\""+item.name+"\" <"+$.trim(item.email)+">");box.find(".email-box-value").html(normalizeBoxName(item.name,item.value));if(item.vacationActive=="TRUE"){box.addClass("out-office-box");}}}else{box.find(".box-loading").remove();}});}
+function normalizeBoxName(name,mail){var emailBoxValue=name.length>18?name.substring(0,15)+"...":name;emailBoxValue=emailBoxValue.length>2?emailBoxValue:email.substr(0,email.indexOf('@'));emailBoxValue=emailBoxValue>18?emailBoxValue.substr(0,15)+"...":emailBoxValue;return emailBoxValue;}
+function normalizeContact(data){var item={};$.each(data,function(j,e){item[e.name]=e.value;});return item;}
+function normalizeContacts(data){var decoded=[];if(!$.isArray(data)){data=[data];}
+for(var i=0;i<data.length;i++){var item={};$.each(data[i].data,function(j,e){item[e.name]=e.value;});decoded.push(item);}
+return decoded;}
+dynamicData=false;currentTypeContact='';function input_binds(div,ID){div.click(function(e){if(e.target==$(this)[0]){$(this).find("textarea:first").focus();$(this).find("div").removeClass("box-selected");}}).focusout(function(e){if(!$(e.target).parents(".email-area:first").length)
+$(this).find("div").removeClass("box-selected");}).droppable({hoverClass:"box-draggable-hover",accept:".box",drop:function(e,ui){ui.draggable.parent().droppable("enable");var box=ui.draggable.clone().removeClass("box-selected");box_actions(box);if(box.find(".box-info").length){box.unbind("dblclick").bind("dblclick",function(e){new $.Zebra_Dialog('<strong>Impossivel editar</strong> um contato do ldap\n'+'<strong>Porém</strong>é possivel remove-lo',{'buttons':false,'modal':false,'position':['right - 20','top + 20'],'auto_close':3000});});}
+$(this).prepend(box);ui.draggable.remove();}});input_keydowns(div.find("textarea:first"),ID);if(parseInt(preferences.use_dynamic_contacts)){REST.get("/usercontacts",false,updateDynamicContact);var decodeType={'/dynamiccontacts':{css:'recent',img:'recent',text:'Contato Recente'},'/personalContact':{css:'personal',img:'personal',text:'Contato pessoal'},'/sharedcontact':{css:'personal',img:'sharedcontact',text:'Contato compartilhado'},'/groups':{css:'group',img:'group',text:'Grupo pessoal'},'/sharedgroup':{css:'group',img:'sharedgroup',text:'Grupo compartilhado'}}
+div.find("textarea").autocomplete({source:function(request,response){if(request.term in cache){response(cache[request.term]);return;}
+if(dynamicData===false){updateDynamicContact();}
+var data=$.ui.autocomplete.filter(dynamicData,request.term).slice(0,50);cache[request.term]=data;response(data);},focus:function(){return false;},select:function(event,ui){canMakeBox=false;event.preventDefault();$(this).val("");var isShared=(ui.item.type.substring(0,7)=="/shared");switch(ui.item.typel){case'/personalContact':draw_email_box(""+ui.item.id,$(this),true,isShared);break;case'/groups':draw_email_box(""+ui.item.id,$(this),"G",isShared);break;default:draw_email_box(ui.item.name?("\""+ui.item.name+"\" <"+ui.item.mail+">"):ui.item.mail,$(this));}
+return false;},autoFocus:true,position:{my:"left top",at:"left bottom",collision:"fit"},delay:120,minLength:0}).bind('catcompleteopen',function(event,ui){$(this).data('is_open',true);}).bind('catcompleteclose',function(event,ui){canMakeBox=true;$(this).data('is_open',false);}).data("autocomplete")._renderItem=function(ul,item){var autocomplete=$(this)[0].element;var minwidth=450;var width=(item.label?item.label.length:(item.value?item.value.length:(item.mail?item.mail.length:30)));width=(is_ie?width*2:(is_webkit&&!is_mozilla?width*4:width*5))+30;if(width<minwidth)
+width=minwidth;ul.css({"min-width":width,"max-height":"180px","overflow-y":"auto","min-height":"30px"});item.raty=((item.number_of_messages*10)/topContact)>1?((item.number_of_messages*10)/topContact):1;if(item.typel!=currentTypeContact){if((item.typel=="/groups"&&$(ul).find(".dynamic-recent").length)||(item.typel=="/personalContact"&&($(ul).find(".dynamic-group").length||$(ul).find(".dynamic-recent").length))){currentTypeContact=item.typel;item.asDiv=true;}else{currentTypeContact=item.typel;}}
+var li='';if(item.asDiv){li='<li class="dynamic-separator"><div class="line-separator">&nbsp;</div></li>';}
+li+='<li class="dynamic-'+decodeType[item.type].css+'">';li+='<a style="width:'+(item.type=='/dynamiccontacts'?'91%':'97.5%')+';  display: inline-block; background: none;">';li+='<img style="position:relative; top:2px; "src="../prototype/modules/mail/img/'+decodeType[item.type].img+'.png" title="'+decodeType[item.type].text+'"/>';li+=($.trim(item.name)!=""?((item.name.length>20?item.name.substring(0,17)+"...":item.name)+" - "):'')+item.mail;li+=item.type=='/dynamiccontacts'?'<div class="dynamic-stars" style="display: inline-block;float: right;" id="'+item.raty+'_'+item.id+'"/>':''
+li+='</a>';li+='<span style="width:16px; height:16px; top:1px; left:7px; '+(item.type=='/dynamiccontacts'?'':'display:none')+'">Excluir contato recente</span>';li+='</li>';li=$(li).data("item.autocomplete",item).appendTo(ul);li.find("span").button({icons:{primary:"ui-icon-close"},text:false}).click(function(event){if(!event.keyCode)
+autocomplete.autocomplete("close");canMakeBox=false;$.Zebra_Dialog('Deseja remover <b>'+(item.name?(item.name.length<=30?item.name:item.name.substr(0,27)+"...")+" - ":"")+item.mail+'</b>?',{'type':'question','custom_class':(is_ie?'configure-zebra-dialog':''),'buttons':['Sim','Não'],'overlay_opacity':'0.5','onClose':function(caption){if(caption=='Sim'){REST['delete']("/dynamiccontact/"+item.id);updateDynamicContact();cache=new Array();}else if(caption=='Não'){$(focusIn).focus();}}});});li.find(".dynamic-stars").jRating({step:true,length:5,decimalLength:2,rateMax:10,isDisabled:true,bigStarsPath:'../prototype/plugins/jquery.jrating/icons/stars.png',smallStarsPath:'../prototype/plugins/jquery.jrating/icons/small.png'});if($(ul).find("li:last").hasClass("dynamic-separator")){$(ul).find("li:last").remove();}
+$(ul).scroll(function(){canMakeBox=false;});return li;};}
+div.parents("tr:first").find("button").button().click(function(){click=true;fastSearch=true;canMakeBox=false;if(!$(":focus").hasClass("new-message-input"))
+emQuickSearch(($(this).parents("tr:first").find("textarea").val()?$(this).parents("tr:first").find("textarea").val():input_search),"."+$(this).parents("tr:first").attr('class').split("-")[0],ID,undefined,true);});}
+function draw_new_message(border_ID){connector.loadScript("color_palette");connector.loadScript('wfolders');connector.loadScript("ccQuickAdd");if(typeof(RichTextEditor)=='undefined'||typeof(ColorPalette)=='undefined'||typeof(wfolders)=='undefined')
+return false;if(typeof($.fn.elastic)=="undefined"){$.lazy({src:'../prototype/plugins/jquery-elastic/jquery.elastic.source.js',name:'elastic'});}
+var ID=create_border("",border_ID);if(ID==0)
+return 0;else if(ID=='maximo')
+return'maximo';hold_session=true;if($("#footer_menu").length){$("#footer_menu").css('display','none');}
+var content=$("#content_id_"+ID).html(DataLayer.render("../prototype/modules/mail/templates/new_message.ejs",{id:ID}));RichTextEditor.loadEditor2(ID);draw_from_field(content.find(".from-select")[0],content.find(".from-tr")[0]);var check_input=function(field){var check=field.attr("checked");field.attr("checked",(!check?true:false));return(!check?true:false);}
+var change_text=function(field,text,to_text){var text=(field.html()==text?to_text:text);field.html(text);}
+var show_hide=function(field,button){button.toggleClass("expressomail-button-icon-ative");field.toggle();field.find("textarea").val("").parent().find("input").focus();field.find(".email-area div").remove();if(!field.find("textarea").hasClass("track")){field.find("textarea").css({"max-height":"115px","overflow-y":"hidden","max-width":parseInt(content.find(".email-area").css("width"))-28}).addClass("track").focus();input_binds(field.find(".email-area"),ID);}}
+input_binds(content.find('[name="input_aux_to"]').css("max-width",parseInt(content.find(".email-area").css("width"))-28).focus().parent().css({"max-height":"115px","overflow-y":"auto"}),ID);content.find(".new-msg-head-right-buttons").find(".button").button().filter(".rich-button").click(function(){if($(".rich-button").find("span").text()==get_lang("Simple Text")){$.Zebra_Dialog(get_lang("Convert this message into plain text can make parts of it are removed. Continue?"),{'type':'warning','overlay_opacity':'0.5','buttons':['OK','Cancelar'],'width':380,'onClose':function(clicked){if(clicked=='OK'){RichTextEditor.setPlain(check_input(content.find('[name="textplain_rt_checkbox"]')),ID);$(".rich-button").find("span").text(get_lang("Rich Text"));}}})}
+else{RichTextEditor.setPlain(check_input(content.find('[name="textplain_rt_checkbox"]')),ID);$(".rich-button").find("span").text(get_lang("Simple Text"));}}).end().filter(".cco-button").click(function(){show_hide(content.find(".cco-tr"),$(this));change_text($(this).find(".ui-button-text"),get_lang("Add BCC"),get_lang('Remove CCo'));}).end().filter(".cc-button").click(function(){show_hide(content.find(".cc-tr"),$(this));change_text($(this).find(".ui-button-text"),get_lang("Add CC"),get_lang('Remove CC'));}).end().filter(".reply-to-button").click(function(){show_hide(content.find(".reply-to-tr"),$(this));});content.find(".send").button({icons:{primary:"expressomail-icon-send"}}).click(function(){send_message(ID,preferences.save_in_folder,null);}).end().find(".save-and-send").button({icons:{primary:"expressomail-icon-send"}}).click(function(){wfolders.makeWindow(ID,"send_and_file");}).end().find(".save").button({icons:{primary:"expressomail-icon-save"}}).click(function(){save_msg(ID);refresh();}).end().find(".return-recept").button({icons:{primary:"expressomail-icon-read-confirmation"}}).click(function(){check_input(content.find('[name="input_return_receipt"]'));$(this).toggleClass("expressomail-button-icon-ative");}).end().find(".important").button({icons:{primary:"expressomail-icon-important"}}).click(function(){check_input(content.find('[name="input_important_message"]'));$(this).toggleClass("expressomail-button-icon-ative");}).end().find(".return_digital").button({icons:{primary:"expressomail-icon-signature"}}).click(function(){check_input(content.find('[name="input_return_digital"]'));$(this).toggleClass("expressomail-button-icon-ative");}).end().find(".return_cripto").button({icons:{primary:"expressomail-icon-encryption"}}).click(function(){check_input(content.find('[name="input_return_cripto"]'));$(this).toggleClass("expressomail-button-icon-ative");});content.find(".attachment td").filter(".value").prepend(DataLayer.render("../prototype/modules/mail/templates/attachment.ejs",{ID:ID}));var fileUploadMSG=$('#fileupload_msg'+ID);var maxAttachmentSize=(preferences.max_attachment_size!==""&&preferences.max_attachment_size!=0)?(parseInt(preferences.max_attachment_size.replace('M',''))*1048576):41943040;content.find(".new-msg-head-data").scroll(function(){$.each(fileUploadMSG.find(".attachments-list .att-box"),function(index,value){$(this).qtip("api").updatePosition();$(this).qtip("api").updateWidth();});});$("#fileupload_msg"+ID+"_droopzone").click(function(){$(this).removeClass('in hover');$(this).hide();$(this).prev().show();});fileUploadMSG.find(".button").button().filter(".fileinput-button").find(".ui-button-text").css("margin-top","2px").find("input:file").fileupload({sequentialUploads:true,type:'post',dataType:'json',url:"../prototype/post.php",forceIframeTransport:false,dropZone:$("#fileupload_msg"+ID+"_droopzone"),formData:function(form){return[{name:"mailAttachment[0][source]",value:"files0"},{name:"mailAttachment[0][disposition]",value:$(form[0]['attDisposition'+$(form[0]['abaID']).val()]).val()},{name:"MAX_FILE_SIZE",value:maxAttachmentSize}];},add:function(e,data){var iterator=idattachbycontent;if(!maxAttachmentSize||data.files[0].size<maxAttachmentSize||is_ie){setTimeout(function(){$('#attDisposition'+ID).val('attachment');jqXHR[iterator]=data.submit();},100);}
+fileUploadMSG.find(' .attachments-list').show();$.each(data.files,function(index,file){var attach={};attach.fullFileName=file.name;attach.fileName=file.name;if(file.name.length>20)
+attach.fileName=file.name.substr(0,17)+" ... "+file.name.substr(file.name.length-6,file.name.length);attach.fileSize=formatBytes(file.size);if(maxAttachmentSize&&file.size>maxAttachmentSize)
+attach.error='Tamanho de arquivo nao permitido'
+else
+attach.error=true;var upload=$(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs",{file:attach}));upload.find('.att-box-delete').click(function(){$("#content_id_"+currentTab+" .save").button("enable");var idAttach=$(this).parent().find('input[name="fileId[]"]').val();fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]').remove();delAttachment(ID,idAttach);$(this).parent().qtip("destroy");$(this).parent().remove();if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){fileUploadMSG.find(' .attachments-list').hide();}
+if(jqXHR){jqXHR[iterator].abort();}});fileUploadMSG.find('.attachments-list').append(upload);fileUploadMSG.find('.attachments-list .att-box:last').qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true,screen:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:3,textAlign:'left',tip:true,name:(typeof(attach.error)=='boolean'?'light':'red')}});fileUploadMSG.find('.attachments-list .att-box:last').css('width',fileUploadMSG.find('.attachments-list .att-box:last div:first').css('width'));if(!maxAttachmentSize||file.size<maxAttachmentSize){if(data.fileInput){fileUploadMSG.find('.fileinput-button.new').append(data.fileInput[0]).removeClass('new');fileUploadMSG.find('.attachments-list').find('[type=file]').addClass('hidden');}}else
+fileUploadMSG.find(' .fileinput-button.new').removeClass('new');idattachbycontent++});},done:function(e,data){$("#content_id_"+currentTab+" .save").button("enable");var attach_box=fileUploadMSG.find('.att-box-loading:first').parents('.att-box');var attach={fullFileName:attach_box.find(".att-box-fullfilename").text(),fileSize:attach_box.find(".att-box-filesize").text(),error:false};if(!!data.result&&data.result!="[]"){var newAttach=data.result;if(!newAttach.mailAttachment.error||newAttach.rollback!==false){attach_box.append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>');addAttachment(ID,newAttach['mailAttachment'][0][0].id);}else{attach_box.addClass('invalid-email-box');attach.error=newAttach.mailAttachment.error?newAttach.mailAttachment.error:'Erro ao anexar...';}}else{attach_box.addClass('invalid-email-box');attach.error='Erro ao anexar...';}
+attach_box.qtip("destroy").qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true,screen:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:3,textAlign:'left',tip:true,name:(attach.error==false?'blue':'red')}});fileUploadMSG.find('.att-box-loading:first').remove();}}).css({"height":"20px","width":(is_webkit?"205px":"100px"),"border-width":"0 0 0px 0px","-moz-transform":"rotate(-180deg) translate(-147px, -0.5px) scale(1.1)","-webkit-transform":"rotate(-180deg) translate(-104px, 0px)"}).end().end().end().filter(".message-attach-link").click(function(){jQuery('#message-attach-dialog').html(DataLayer.render("../prototype/modules/attach_message/attach_message.ejs",{}));var lastFolderSelected=$('#content_folders .folder.selected');$("#mailpreview_container span.ui-icon-close").click();jQuery('#message-attach-dialog').dialog({width:920,height:550,resizable:false,modal:true,closeOnEscape:true,close:function(event,ui)
+{event.stopPropagation();if(typeof(shortcut)!='undefined')shortcut.disabled=false;lastFolderSelected.toggleClass('selected');},open:function(event,ui)
+{if(typeof(shortcut)!='undefined')shortcut.disabled=true;},autoOpen:false});jQuery.getScript("../prototype/modules/attach_message/attach_message.js",function(){jQuery('#message-attach-dialog').dialog('open');jQuery('#message-attach-attach-btn').unbind('click');jQuery('#message-attach-attach-btn').click(function(event){jQuery.each(selectedMessages,function(folder_name,messages){jQuery.each(selectedMessages[folder_name],function(message_number,message){if(message){fileUploadMSG.find(' .attachments-list').show();var att=new Object();att.folder=folder_name;att.uid=message_number;att.type='imapMSG';att.name=Base64.encode(onceOpenedMessages[folder_name][message_number].subject+'.eml');var idATT=JSON.stringify(att);addAttachment(ID,idATT);var attach={};attach.fileName=onceOpenedMessages[folder_name][message_number].subject+'.eml';attach.fullFileName=onceOpenedMessages[folder_name][message_number].subject+'.eml';if(attach.fileName.length>20)
+attach.fileName=attach.fileName.substr(0,17)+"... "+attach.fileName.substr(attach.fileName.length-9,attach.fileName.length);attach.error=false;attach.OK=true;attach.fileSize=formatBytes(onceOpenedMessages[folder_name][message_number].size);var upload=$(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs",{file:attach}));$("#content_id_"+currentTab+" .save").button("enable");upload.find('.att-box-loading').remove();upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>');upload.find('.att-box-delete').click(function(){$("#content_id_"+currentTab+" .save").button("enable");var idAttach=$(this).parent().find('input[name="fileId[]"]').val();fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]').remove();delAttachment(ID,idAttach);$(this).parent().qtip("destroy");$(this).parent().remove();if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){fileUploadMSG.find(' .attachments-list').hide();}});fileUploadMSG.find('.attachments-list').append(upload);upload.find('.att-box-loading').remove();fileUploadMSG.find('.attachments-list .att-box:last').qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:5,textAlign:'center',tip:true,name:'blue'}});}});});jQuery('#message-attach-dialog').dialog('close');});jQuery('#message-attach-cancel-btn').click(function(event){jQuery('#message-attach-dialog').dialog('close');});});});$(document).bind('drop dragover',function(e){e.preventDefault();});if(!is_ie){$("body").bind('dragenter',function(e){var dropZone=$("#fileupload_msg"+ID+"_droopzone");var timeout=window.dropZoneTimeout;dropZone.show();dropZone.prev().hide();if(!timeout){dropZone.addClass('in');}else{clearTimeout(timeout);}
+if(e.target===dropZone[0]){dropZone.addClass('hover');}else{dropZone.removeClass('hover');}
+$(window).unbind('dragleave');window.dropZoneTimeout=setTimeout(function(){$(window).bind('dragleave',function(e){window.dropZoneTimeout=null;dropZone.removeClass('in hover');dropZone.hide();dropZone.prev().show();});},1);}).bind('dragleave',function(e){var dropZone=$("#fileupload_msg"+ID+"_droopzone");window.dropZoneTimeout=setTimeout(function(){$(window).bind('dragleave',function(e){window.dropZoneTimeout=null;dropZone.removeClass('in hover');dropZone.hide();dropZone.prev().show();});},1);}).bind('drop',function(e){var dropZone=$("#fileupload_msg"+ID+"_droopzone");window.dropZoneTimeout=null;dropZone.removeClass('in hover');dropZone.hide();dropZone.prev().show();});}
+return ID;}
+function draw_from_field(sel_from,tr1_1){var el_shared_users=Element("el_shared_users");var user_shared=folder.split(cyrus_delimiter);if(user_shared[0]=="INBOX"){user_shared=User.me.uid;}else{user_shared=user_shared[1];}
+if(el_shared_users){if(el_shared_users.options.length==0)
+return;tr1_1.style.display='';for(var x=0;x<el_shared_users.options.length;x++){var _option=document.createElement("OPTION");_option.text=el_shared_users.options[x].text;_option.value=el_shared_users.options[x].value;var str_begin_name=_option.text.indexOf('<')+1;var str_end_name=_option.text.indexOf('@');var user_selected_name=_option.text.substring(str_begin_name,str_end_name);if(user_selected_name==user_shared){_option.selected='selected';}
+sel_from.options[sel_from.options.length]=_option;}
+return;}
+var sharedFolders=new Array();for(var i=0;i<folders.length;i++){var x=folders[i].folder_id;if(folders[i].folder_parent=='user'){sharedFolders[sharedFolders.length]=x;}}
+var matchUser='#';var sharedUsers=new Array();for(var i=0;i<sharedFolders.length;i++){matchUser=sharedFolders[i];sharedUsers[sharedUsers.length]=matchUser.substring(("user"+cyrus_delimiter).length,matchUser.length);}
+var h_user=function(data){if(data.length>0){tr1_1.style.display='';var mycn=typeof(data.myname!='undefined')?data.myname:'';var _option=document.createElement("OPTION");_option.text='"'+mycn+'" <'+Element("user_email").value+'>';_option.value=mycn+";"+Element("user_email").value;if(user_shared==User.me.uid)
+_option.selected='selected';sel_from.options[sel_from.options.length]=_option;var options='';var cn='';for(var x=0;x<data.length;x++){cn=typeof(data[x].cn[0]!='undefined')?data[x].cn[0]:'';var _option=document.createElement("OPTION");_option.text='"'+cn+'" <'+data[x].mail[0]+'>';_option.value=cn+';'+data[x].mail[0]+';'+data[x].save_shared[0]+';'+data[x].uid[0];var str_begin_name=_option.text.indexOf('<')+1;var str_end_name=_option.text.indexOf('@');var user_selected_name=_option.text.substring(str_begin_name,str_end_name);if(user_selected_name==user_shared){_option.selected='selected';}
+sel_from.options[sel_from.options.length]=_option;}}
+var shared_users_from=Element("el_shared_users");if(!shared_users_from){shared_users_from=sel_from.cloneNode(true);shared_users_from.id="el_shared_users";shared_users_from.style.display='none';document.body.appendChild(shared_users_from);}}
+cExecute("$this.ldap_functions.getSharedUsersFrom&uids="+sharedUsers.join(';'),h_user);}
+function changeBgColorToON(all_messages,begin,end){var _tab_prefix=getTabPrefix();var _msg_id;for(begin;begin<=end;begin++)
+{_msg_id=getMessageIdFromRowId(all_messages[begin].id);add_className(all_messages[begin],'selected_msg');Element(_tab_prefix+"check_box_message_"+_msg_id).checked=true;updateSelectedMsgs(true,_msg_id);}}
+function updateBoxBgColor(box){var _className='tr_msg_read2';for(var i=0;i<box.length;i++){if(exist_className(box[i],_className))
+remove_className(box[i],_className);_className=(_className=='tr_msg_read2'?'tr_msg_read':'tr_msg_read2');if(!exist_className(box[i],_className))
+add_className(box[i],_className);}}
+function changeBgColor(event,msg_number){var _element_id=msg_number.toString();var first_order,last_order;if(typeof(currentTab)!='number'){_element_id=_element_id+'_s'+numBox;}
+actual_tr=Element(_element_id);if(event.shiftKey)
+{var last_tr=Element(last_message_selected);if(!last_tr)
+last_tr=actual_tr;var all_messages=actual_tr.parentNode.childNodes;for(var i=0;i<all_messages.length;i++)
+{if(actual_tr.id==all_messages[i].id)
+first_order=i;if(last_tr.id==all_messages[i].id)
+last_order=i;}
+if(parseInt(first_order)>parseInt(last_order))
+changeBgColorToON(all_messages,last_order,first_order);else
+changeBgColorToON(all_messages,first_order,last_order);}else if(event.target!=document.getElementById(getTabPrefix()+'check_box_message_'+msg_number)){if($(event.target).attr("checked")=="checked"){$(event.target).parents("tr:first").addClass("selected_msg");}else{$(event.target).parents("tr:first").removeClass("selected_msg");}}
+else{if(document.getElementById(getTabPrefix()+'check_box_message_'+msg_number).checked){if(document.getElementById("chk_box_select_all_messages").checked){add_className(actual_tr,'selected_msg selected_shortcut_msg');}else
+add_className(actual_tr,'selected_msg');}else{if(document.getElementById("chk_box_select_all_messages").checked){remove_className(actual_tr,'selected_msg selected_shortcut_msg');remove_className(actual_tr,'selected_msg');remove_chk_box_select_all_messages();if(actual_tr.className=='selected_msg')
+remove_className(actual_tr,'selected_msg');}else
+remove_className(actual_tr,'selected_msg');}}
+last_message_selected=_element_id;}
+function build_quota(data){if(proxy_mensagens.is_local_folder(current_folder)){return;}
+id="content_quota";q_limit=data['quota_limit'];var div=document.getElementById(id);if(!q_limit){div.innerHTML='<span><font size="2" style="color:red"><strong>'+get_lang("Without Quota")+'</strong></font></span>';}
+else{if(div)
+div.innerHTML='';value=data['quota_percent'];q_used=data['quota_used'];table=document.getElementById("table_quota");if(table)
+table.parentNode.removeChild(table);table=document.createElement("TABLE");tbody=document.createElement("TBODY");table.appendChild(tbody);table.id="table_quota";table.width="102";table.border="0";table.cellSpacing=0;table.cellPadding=0;td11=document.createElement("TD");td11.align="center";td11.setAttribute("noWrap","true");td11.innerHTML+='<div id="quota_progressbar" class="boxHeaderText" style="display: block; float: left; height: 13px; width: 121px;"></div>&nbsp;<span class="boxHeaderText" style="line-height : 0px;">'+value+"% ("+borkb(q_used*1024)+"/"+borkb(q_limit*1024)+")</span>";tr2=document.createElement("TR");td22=document.createElement("TD");tr2.appendChild(td11);tbody.appendChild(tr2);div.appendChild(table);$("#quota_progressbar").progressbar({value:value});if(value>90){if(value>=100)
+write_msg(get_lang("Your Mailbox is 100% full! You must free more space or will not receive messages."));else
+write_msg(get_lang("Warning: Your Mailbox is almost full!"));$("#quota_progressbar").find(".ui-progressbar-value").css({"background-image":"url(templates/default/images/dsalert.gif)","border-color":"red"});}
+else if(value>80)
+$("#quota_progressbar").find(".ui-progressbar-value").css({"background-image":"url(templates/default/images/dswarn.gif)","border-color":"yellow"});}}
+function draw_quota(data){this.build_quota(data);}
+function update_quota(folder_id){cExecute("$this.imap_functions.get_quota&folder_id="+folder_id,this.build_quota);}
+function draw_search(headers_msgs){Element("border_id_0").innerHTML="&nbsp;&nbsp;"+get_lang('Search Result')+"&nbsp;&nbsp;";var tbody=Element('tbody_box');for(var i=0;i<(headers_msgs.length);i++){var tr=this.make_tr_message(headers_msgs[i],headers_msgs[i].msg_folder);if(tr)
+tbody.appendChild(tr);}}
+function draw_search_header_box(){var table_message_header_box=Element("table_message_header_box");table_message_header_box.parentNode.removeChild(table_message_header_box);var content_id_0=Element("content_id_0");var table_element=document.createElement("TABLE");var tbody_element=document.createElement("TBODY");table_element.setAttribute("id","table_message_header_box");table_element.className="table_message_header_box";tr_element=document.createElement("TR");tr_element.className="message_header";td_element1=document.createElement("TD");td_element1.setAttribute("width","1%");chk_box_element=document.createElement("INPUT");chk_box_element.id="chk_box_select_all_messages";chk_box_element.setAttribute("type","checkbox");chk_box_element.className="checkbox";chk_box_element.onclick=function(){select_all_messages(this.checked);};chk_box_element.onmouseover=function(){this.title=get_lang('Select all messages.')};chk_box_element.onkeydown=function(e){if(is_ie)
+{if((window.event.keyCode)==46)
+{proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');}}
+else
+{if((e.keyCode)==46)
+{proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');}}};td_element1.appendChild(chk_box_element);td_element2=document.createElement("TD");td_element2.setAttribute("width","3%");td_element3=document.createElement("TD");td_element3.setAttribute("width","30%");td_element3.id="message_header_SORTFROM";td_element3.align="left";td_element3.innerHTML=get_lang("From");td_element4=document.createElement("TD");td_element4.setAttribute("width","49%");td_element4.id="message_header_SORTSUBJECT";td_element4.align="left";td_element4.innerHTML=get_lang("Subject");td_element5=document.createElement("TD");td_element5.setAttribute("width","10%");td_element5.id="message_header_SORTARRIVAL";td_element5.align="center";td_element5.innerHTML="<B>"+get_lang("Date")+"</B>";td_element5.innerHTML+="<img src ='templates/"+template+"/images/arrow_descendant.gif'>";td_element6=document.createElement("TD");td_element6.setAttribute("width","10%");td_element6.id="message_header_SORTSIZE";td_element6.align="right";td_element6.innerHTML=get_lang("Size");tr_element.appendChild(td_element1);tr_element.appendChild(td_element2);tr_element.appendChild(td_element3);tr_element.appendChild(td_element4);tr_element.appendChild(td_element5);tr_element.appendChild(td_element6);tbody_element.appendChild(tr_element);table_element.appendChild(tbody_element);content_id_0.appendChild(table_element);}
+function draw_search_division(msg){var tbody=Element('tbody_box');var tr=document.createElement("TR");var td=document.createElement("TD");td.colSpan='7';td.width='100%';var action_info_table=document.createElement("TABLE");var action_info_tbody=document.createElement("TBODY");action_info_table.className="action_info_table";action_info_table.width="100%";var action_info_tr=document.createElement("TR");var action_info_th1=document.createElement("TH");action_info_th1.width="40%";action_info_th1.innerHTML="&nbsp;";var action_info_th2=document.createElement("TH");action_info_th2.innerHTML=msg;action_info_th2.className="action_info_th";action_info_th2.setAttribute("noWrap","true");var action_info_th3=document.createElement("TH");action_info_th3.width="40%";action_info_th3.innerHTML="&nbsp;";action_info_tr.appendChild(action_info_th1);action_info_tr.appendChild(action_info_th2);action_info_tr.appendChild(action_info_th3);action_info_tbody.appendChild(action_info_tr);action_info_table.appendChild(action_info_tbody);td.appendChild(action_info_table);tr.appendChild(td);tbody.appendChild(tr);}
+function draw_search_box(){var content_id_0=Element("content_id_0");var table=document.createElement("TABLE");table.id="table_box";table.width='auto';var tbody=document.createElement("TBODY");tbody.id="tbody_box";table.className="table_box";table.setAttribute("frame","below");table.setAttribute("rules","none");table.setAttribute("cellpadding","0");table.onkeydown=function(e){if(is_ie)
+{if((window.event.keyCode)==46)
+{proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');}}
+else
+{if((e.keyCode)==46)
+{proxy_mensagens.delete_msgs(get_current_folder(),'selected','null');}}};if(is_ie)
+table.style.cursor="hand";table.appendChild(tbody);content_id_0.appendChild(table);}
+var idx_cc=0;function draw_plugin_cc(ID,addrs,notValidUser){connector.loadScript("ccQuickAdd");var array_addrs='';var array_name='';var cc_data=new Array();if(typeof(addrs.name)!='undefined'){array_name=LTrim(addrs.name).split(" ");array_addrs=new Array(addrs.email);}
+else{array_addrs=(typeof addrs=='object'?addrs.toString().split("\" "):addrs.split("\" "));array_name=LTrim(array_addrs[0]).replace('"','').split(" ");}
+var _split=array_name[0].split('@');cc_data[0]=_split[0];cc_data[1]=_split[0];cc_data[2]='';for(i=1;i<array_name.length;i++)
+cc_data[2]+=array_name[i]+" ";if(array_addrs.length>1)
+cc_data[3]=array_addrs[1]?array_addrs[1].replace("&lt;",'').replace("&gt;",''):'';else
+cc_data[3]=array_addrs[0];var onclick='';$.each(cc_data,function(index,value){onclick+="'"+value+"',";});onclick=onclick.substr(0,onclick.length-1);var to_addybook_add="<SPAN id='insert_plugin_"+idx_cc+"_"+ID+"'>";to_addybook_add+=addrs;if(!!!notValidUser)
+{var sm_envelope_img1='<img style="cursor:'+(is_ie?'hand':'pointer')+'" title="'+get_lang("Add Contact")+'" onclick="ccQuickAddOne.showList(['+onclick+'])" src="./templates/'+template+'/images/user_card.png">';to_addybook_add+=sm_envelope_img1;}
+idx_cc++;to_addybook_add+="</SPAN>";return to_addybook_add;}
+function deny_email(email){connector.loadScript("filter");connector.loadScript("filters");var dn_em=document.createElement("SPAN");dn_em.id="tt_d";dn_em.onclick=function(){block_user_email(email);};dn_em.setAttribute("title",get_lang("Block Sender"));dn_em.style.cursor="pointer";dn_em.innerHTML="<script src='../prototype/modules/filters/filters.js'></script><img align='top' src='./templates/"+template+"/images/deny.gif'>";return dn_em;}
+function show_div_address_full(id,type){var div_address_full=Element("div_"+type+"address_full_"+id);if(!div_address_full){div_address_full=document.createElement("SPAN");div_address_full.id="div_"+type+"address_full_"+id;div_address_full.style.display="none";var _address=eval(type+"address_array['"+id+"']");var isOverLimit=(_address.length>100);if(isOverLimit){alert("Esse campo possui muitos endereços ("+_address.length+" destinatários).\r\n"+"Para evitar o travamento do navegador, o botão 'Adicionar Contato' foi desabilitado!");}
+for(var idx=1;idx<_address.length;idx++){div_address_full.innerHTML+=isOverLimit?'<br>'+_address[idx]:','+draw_plugin_cc(id,_address[idx]);}
+div_address_full.innerHTML+=" (<a STYLE='color: RED;' onclick=document.getElementById('div_"+type+"address_full_"+id+"').style.display='none';document.getElementById('div_"+type+"address_"+id+"').style.display='';>"+get_lang('less')+"</a>)";Element(type+"_"+id).appendChild(div_address_full);}
+Element('div_'+type+'address_'+id).style.display='none';div_address_full.style.display='';}
+function draw_footer_box(num_msgs){folder=get_current_folder();connector.loadScript('wfolders');var span_R=Element("table_message");var span_options=Element("span_options");if(!span_options){span_options=document.createElement("TD");span_options.style.fontSize="12";span_options.id="span_options";span_R.appendChild(span_options);}
+var change_font_color='onmouseover="var last_class = this.className;'+'if (this.className != \'message_options_over\')'+'this.className=\'message_options_active\'; '+'this.onmouseout=function(){this.className=last_class;}"';span_options.innerHTML='<span class="message_options_trash"><span '+change_font_color+' title="'+get_lang("Delete")+'" class="message_options" onclick=proxy_mensagens.delete_msgs(\'null\',\'selected\',\'null\')>'+get_lang("Delete")+'</span></span>'+'<span class="message_options_move"><span '+change_font_color+' title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"\",\"move_to\")>'+get_lang("Move")+'</span></span>'+
+((expresso_offline)?" ":'<span class="message_options_print"><span '+change_font_color+' title="'+get_lang("Print")+'" class="message_options" onclick=print_all()>'+get_lang("Print")+'</span></span>')+
+((expresso_offline)?" ":'<span class="message_options_export"><span '+change_font_color+' title="'+get_lang("Export")+'" class="message_options" onclick="proxy_mensagens.export_all_messages()">'+get_lang("Export")+'</span></span>')+
+((expresso_offline)?" ":'<span class="message_options_import"><span '+change_font_color+' title="'+get_lang("Import")+'" class="message_options" onclick="import_window()">'+get_lang("Import")+'</span></span>');if(preferences.use_local_messages==1){if(expresso_mail_archive.enabled){if(proxy_mensagens.is_local_folder(current_folder))
+span_options.innerHTML+='&nbsp; <span title="'+get_lang("Unarchive")+'" class="message_options" onclick="expresso_mail_archive.unarchieve(\''+folder+'\', null, null);">'+get_lang("Unarchive")+'</span>';else
+span_options.innerHTML+='&nbsp; <span title="'+get_lang("Archive")+'" class="message_options" onclick="archive_msgs(\''+folder+'\',null,null)">'+get_lang("Archive")+'</span>';}}
+if(use_spam_filter){if(current_folder=='INBOX'+cyrus_delimiter+'Spam'){span_options.innerHTML+=' | <span '+change_font_color+' title="'+get_lang("Not Spam")+'" class="message_options" onclick="nospam(\'selected\',\'null\',\'null\')">'+get_lang("Not Spam")+'</span>';}
+else{span_options.innerHTML+=' | <span '+change_font_color+' title="'+get_lang("Mark as Spam")+'" class="message_options" onclick="spam(\'null\', \'selected\',\'null\')">'+get_lang("Mark as Spam")+'</span>';}}
+var span_D=Element("span_D");if(!span_D){span_D=document.createElement("TD");span_D.align="right";span_D.style.fontSize="12";span_D.id="span_D";span_R.appendChild(span_D);}
+var answer='<span '+change_font_color+' id="span_flag_ANSWERED" class="'+(search_box_type=='ANSWERED'?'message_options_over':'message_options')+'" title="'+get_lang("title_answered")+'" onclick="if(\'ANSWERED\' == \''+search_box_type+'\') return false;sort_box(\'ANSWERED\',\''+sort_box_type+'\')">'+get_lang("l_answered")+'</span>, ';span_D.innerHTML=get_lang("List")+': '+'<span '+change_font_color+' id="span_flag_SORTARRIVAL" class="'+(search_box_type=='ALL'?'message_options_over':'message_options')+'" title="'+get_lang("All")+'" onclick="if(\'ALL\' == \''+search_box_type+'\') return false;sort_box(\'ALL\',\''+sort_box_type+'\')">'+get_lang("All")+'</span>, '+'<span '+change_font_color+' id="span_flag_UNSEEN" class="'+(search_box_type=='UNSEEN'?'message_options_over':'message_options')+'" title="'+get_lang("l_unseen")+'" onclick="if(\'UNSEEN\' == \''+search_box_type+'\') return false;sort_box(\'UNSEEN\',\''+sort_box_type+'\')">'+get_lang("l_unseen")+'</span>, '+'<span '+change_font_color+' id="span_flag_SEEN" class="'+(search_box_type=='SEEN'?'message_options_over':'message_options')+'" title="'+get_lang("l_seen")+'" onclick="if(\'SEEN\' == \''+search_box_type+'\') return false;sort_box(\'SEEN\',\''+sort_box_type+'\')">'+get_lang("l_seen")+'</span>, '+
+answer+'<span '+change_font_color+' id="span_flag_FLAGGED" class="'+(search_box_type=='FLAGGED'?'message_options_over':'message_options')+'" title="'+get_lang("l_important")+'" onclick="if(\'FLAGGED\' == \''+search_box_type+'\') return false;sort_box(\'FLAGGED\',\''+sort_box_type+'\')">'+get_lang("l_important")+'</span>&nbsp;&nbsp;';if(!proxy_mensagens.is_local_folder(current_folder)){draw_paging(num_msgs);Element("tot_m").innerHTML=num_msgs;}}
Index: trunk/expressoMail1_2/js/main.min.js
===================================================================
--- trunk/expressoMail1_2/js/main.min.js	(revision 7540)
+++ trunk/expressoMail1_2/js/main.min.js	(revision 7541)
@@ -1,1 +1,825 @@
-var time_refresh=300000;var check_services_interval=2000;var check_services_tryouts=1;var check_services_tryouts_limit=5;var autosave_time=40000;var results_search_messages="";var cabecalho='<h4>ExpressoLivre - ExpressoMail</h4>';var auxNotificationCriteriaVetor=[];var auxNotification;var countNewMessage=0;var notifyNewMessageFilter=[];var dynamicPersonalContacts=new Array();var dynamicPersonalGroups=new Array();var dynamicContacts=new Array();var topContact=0;DataLayer.get("folder",true);if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'')}}function mount_url_folder(folders){return folders.join(cyrus_delimiter)}function updateDynamicContact(userContacts){if(!userContacts)userContacts=REST.get("/usercontacts",false);if(userContacts.collection&&!userContacts.collection.error){dynamicData=normalizeContacts(userContacts.collection.itens)}else{dynamicData=[]}if(dynamicData){var dynamicContactsList=[];$.each(dynamicData,function(index,dynamic){var dataType=userContacts.collection.itens[index].dataType;dynamic['value']=(dynamic.name?dynamic.name+' - ':'')+dynamic.mail;dynamic['type']=dataType dynamic['typel']=(dataType.substring(0,7)=="/shared"?"/"+dataType.substring(7,dataType.length)+"s":dataType);topContact=dynamic.number_of_messages>topContact?dynamic.number_of_messages:topContact;dynamicContactsList.push(dynamic)})}dynamicData=dynamicContactsList}function updateDynamicPersonalContacts(){dynamicPersonalContacts=new Array();var personalContacts=REST.get("/personalContact");if(personalContacts.collection&&!personalContacts.collection.error){var contactsData=normalizeContacts(personalContacts.collection.itens);if(contactsData){$.each(contactsData,function(index,value){var contact={id:parseInt(value.id),name:value.name,email:value.email,value:value.name+" - "+value.email,type:"P"};dynamicPersonalContacts.push(contact)})}}}function updateDynamicPersonalGroups(){dynamicPersonalGroups=new Array();var groups=REST.get("/groups");if(groups.collection&&!groups.collection.error){var contactsData=normalizeContacts(groups.collection.itens);if(contactsData.collecion&&!contactsData.collecion.error){$.each(contactsData,function(index,value){var contact={id:parseInt(value.id),owner:value.owner,name:value.name,email:value.email,type:"G"};dynamicPersonalGroups.push(contact)})}}}function init(){if(!is_ie)Element('tableDivAppbox').width='100%';var save_gmtoffset=function(data){gmtoffset=data}var save_preferences=function(data){preferences=data;if(preferences.show_name_print_messages=="1"){var getUserName=document.getElementById("user_info");var userName=getUserName.innerHTML;var position=userName.indexOf("-");var userName=userName.substring(3,position);cabecalho='<h4>'+userName}current_folder="INBOX";if(ArchiveServices)expresso_mail_archive.Startup();else{if(preferences.use_local_messages=="1")write_msg(get_lang('Sorry, but Mail Archiver does not seems to be running or installed at this workstation. By now, we are turning off local messages!'))}cExecute("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1",handler_draw_box);$.ajax({async:false,url:"controller.php?"+$.param({action:"$this.imap_functions.getMessagesIds",folder:get_current_folder(),msg_range_begin:"0",msg_range_end:"0",sort_box_type:"SORTARRIVAL",search_box_type:search_box_type,sort_box_reverse:"1"}),success:function(data){data=connector.unserialize(data);if(data){var _data={};$.each(data,function(index,value){if(data[index]){_data[data[index]]=data[index]}});populateSelectedMsgs(_data)}},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}});if(preferences.hide_folders=="1")Element('divAppboxHeader').innerHTML=title_app_menu;if(preferences.delete_trash_messages_after_n_days!=0)cExecute("$this.imap_functions.automatic_trash_cleanness&before_date="+preferences.delete_trash_messages_after_n_days+"&cyrus_delimiter="+cyrus_delimiter,handler_automatic_trash_cleanness);if(preferences.use_signature_digital_cripto=='1'){loadApplet()}DataLayer.get("folder",true);cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);if($.cookie('collapse_folders')=="true"){if(!is_ie)$("#folderscol").addClass("hidden");else $("#folderscol").hide();$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-e").children().attr('title',"Expandir");refresh();resizeWindow()}else{$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-w").children().attr('title',"Ocultar");refresh();resizeWindow()}$(".collapse_folders_td").attr('title',"Ocultar/Expandir").click(function(){if($("#folderscol").css("display")!="none"){if(!is_ie)$("#folderscol").addClass("hidden");else $("#folderscol").hide();$(".collapse_folders").removeClass("ui-icon-triangle-1-w");$(".collapse_folders").addClass("ui-icon-triangle-1-e");$(".collapse_folders").parent().attr('title',"Expandir");$.cookie('collapse_folders',"true");refresh();resizeWindow()}else{if(!is_ie)$("#folderscol").removeClass("hidden");else $("#folderscol").show();$(".collapse_folders").removeClass("ui-icon-triangle-1-e");$(".collapse_folders").addClass("ui-icon-triangle-1-w");$(".collapse_folders").parent().attr('title',"Ocultar");$.cookie('collapse_folders',"false");refresh();resizeWindow()}resizeWindow()}).hover(function(){$(this).addClass("collapse_folders_td_over")},function(){$(this).removeClass("collapse_folders_td_over")});if(parseInt(preferences.use_dynamic_contacts)){var load_dynamics=function(){updateDynamicContact();updateDynamicPersonalContacts();updateDynamicPersonalGroups()};load_dynamics()}}var handler_automatic_trash_cleanness=function(data){if(data!=false){write_msg(data.length+' '+Element('txt_clear_trash').value)}}Element('divAppboxHeader').innerHTML=title_app;cyrus_delimiter=Element('cyrus_delimiter').value;cExecute("$this.functions.get_preferences",save_preferences);cExecute("phpgwapi.browser.isMobile",function(data){mobile_device=((data.constructor==Boolean)?data:(data==='true'))});DataLayer.get("folder",true);cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);setTimeout('auto_refresh()',time_refresh);$("#divAppbox").css("padding-left","0px")}function init_offline(){current_folder='local_Inbox';if(account_id!=null){if(!is_ie)Element('tableDivAppbox').width='100%';else connector.createXMLHTTP();Element('divStatusBar').innerHTML='<table height="16px" border=0 width=100% cellspacing=0 cellpadding=2>'+'<tr>'+'<td style="padding-left:17px" width=33% id="content_quota" align=left></td>'+'<td width=33% height=16px align=center nowrap><font face=Verdana, Arial, Helvetica, sans-serif color=#000066 size=2>'+'<b>ExpressoMail Offline</b><font size=1><b> - Versão 1.0</b></font></td>'+'<td width=33% id="div_menu_c3" align=right></td>'+'</tr></table>';draw_tree_folders();proxy_mensagens.messages_list('local_Inbox',1,preferences.max_email_per_page,'SORTARRIVAL',null,1,1,1,function handler(data){draw_box(data,'local_Inbox')})cyrus_delimiter=Element('cyrus_delimiter').value}}function loadApplet(){var search_div=Element('search_div');var applet=null;if(navigator.userAgent.match('MSIE')){applet=document.createElement('<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" '+'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"></object>');var parameters={type:'application/x-java-applet;version=1.5',code:'ExpressoSmimeApplet',codebase:'/security/',mayscript:'true',token:token_param,locale:locale,archive:'ExpressoCertMail.jar,'+'ExpressoCert.jar,'+'bcmail-jdk15-142.jar,'+'mail.jar,'+'activation.jar,'+'bcprov-jdk15-142.jar,'+'commons-codec-1.3.jar,'+'commons-httpclient-3.1.jar,'+'commons-logging-1.1.1.jar'}if(parameters!='undefined'&&parameters!=null){for(var parameter in parameters){var param=document.createElement("PARAM");param.setAttribute("name",parameter);param.setAttribute("value",parameters[parameter]);applet.appendChild(param)}}}else{applet=document.createElement('embed');applet.innerHTML='<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" code="ExpressoSmimeApplet.class" '+'codebase="/security/" locale="'+locale+'"'+'archive="ExpressoCertMail.jar,ExpressoCert.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar,commons-codec-1.3.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar" '+'token="'+token_param+'" '+'type="application/x-java-applet;version=1.5" mayscript > '+'<noembed> '+'No Java Support. '+'</noembed> '+'</embed> '}if(applet!=null){applet.style.top="-100px";applet.style.left="-100px";window.document.body.insertBefore(applet,document.body.lastChild)}}function disable_field(field,condition){var comando="if ("+condition+") { document.getElementById('"+field.id+"').disabled=true;} else { document.getElementById('"+field.id+"').disabled=false; }";eval(comando)}function remove_all_attachments(folder,msg_num){var call_back=function(data){if(!data.status){alert(data.msg)}else{msg_to_delete=Element(msg_num);change_tr_properties(msg_to_delete,data.msg_no);msg_to_delete.childNodes[1].innerHTML="";write_msg(get_lang("Attachments removed"));folderName=Base64.encode(folder);folderName=folderName.replace(/=/gi,'');delete_border(msg_num+'_r_'+folderName,'false')}};if(confirm(get_lang("delete all attachments confirmation")))cExecute("$this.imap_functions.remove_attachments&folder="+folder+"&msg_num="+msg_num,call_back)}function watch_changes_in_msg(border_id){if(document.getElementById('border_id_'+border_id)){function keypress_handler(){away=false;var save_link=content.find(".save");save_link.onclick=function onclick(event){openTab.toPreserve[border_id]=true;save_msg(border_id)};save_link.button({disabled:false});$(".header-button").button()};var content=$("#content_id_"+border_id);var subject_obj=content.find(".subject");if(subject_obj.addEventListener)subject_obj.addEventListener('keypress',keypress_handler,false);else if(subject_obj.attachEvent)subject_obj.attachEvent('onkeypress',keypress_handler);var to_obj=content.find('[name="input_to"]');if(to_obj.addEventListener)to_obj.addEventListener('keypress',keypress_handler,false);else if(to_obj.attachEvent)to_obj.attachEvent('onkeypress',keypress_handler);var cc_obj=content.find('[name="input_cc"]');if(cc_obj.addEventListener)cc_obj.addEventListener('keypress',keypress_handler,false);else if(cc_obj.attachEvent)cc_obj.attachEvent('onkeypress',keypress_handler);if(content.find('[name="input_cco"]').length){var cco_obj=content.find('[name="input_cco"]');if(cco_obj.addEventListener)cco_obj.addEventListener('keypress',keypress_handler,false);else if(cco_obj.attachEvent)cco_obj.attachEvent('onkeypress',keypress_handler)}var txtarea_obj=Element('body_'+border_id);if(txtarea_obj){if((preferences.plain_text_editor==1)||(Element('body_')+border_id).checked){if(txtarea_obj.addEventListener)txtarea_obj.addEventListener('keypress',keypress_handler,false);else if(txtarea_obj.attachEvent)txtarea_obj.attachEvent('onkeypress',keypress_handler)}}}}function show_msg_img(msg_number,folder){var call_back=function(data){data.showImg=true;if(!Element(data.msg_number)){trElement=document.createElement('DIV');trElement.id=data.msg_number;Element("tbody_box").appendChild(trElement)}show_msg(data)}proxy_mensagens.msg_img(msg_number,folder,call_back)}function show_msg(msg_info){if(!verify_session(msg_info))return;if(typeof(msg_info)!='object')alert(get_lang("Error in show_msg param is not object"));if(msg_info.status_get_msg_info=='false'){write_msg(get_lang("Problems reading your message")+".");return}var handler_sendNotification=function(data){if(data)write_msg(get_lang("A read confirmation was sent."));else write_msg(get_lang("Error in SMTP sending read confirmation."))}if(msg_info.source){if(!Element('cert_applet')){write_msg(get_lang('The preference "%1" isn\'t enabled.',get_lang('Enable digitally sign/cipher the message?')))}else{Element('cert_applet').doButtonClickAction('decript',msg_info.msg_number,msg_info.source,msg_info.msg_folder)}return}if(msg_info.status_get_msg_info=='false'){write_msg(get_lang("Problems reading your message")+".");return}if(msg_info.status=='false'){eval(msg_info.command_to_exec)}else{var ID=msg_info.original_ID?msg_info.original_ID:msg_info.msg_number;var folderName=msg_info.msg_folder;folderName=Base64.encode(folderName);folderName=folderName.replace(/=/gi,'');var id_msg_read=ID+"_r_"+folderName;if(Element("border_id_"+id_msg_read)&&currentTab>0)id_msg_read+="n";if(preferences.use_shortcuts=='1')select_msg(ID,'null');var isPartMsg=false;for(var ii=0;ii<partMsgs.length;ii++)if(partMsgs[ii]==ID)isPartMsg=true;if(msg_info.alarm==false){if((openTab.type[currentTab]==2||openTab.type[currentTab]==3)&&isPartMsg===false){delete_border(currentTab,'false')}}if(Element("border_id_"+id_msg_read)){alternate_border(id_msg_read);resizeWindow()}else{var border_id=create_border(msg_info.subject,id_msg_read);if(border_id){openTab.type[border_id]=2;openTab.imapBox[border_id]=msg_info.msg_folder;draw_message(msg_info,border_id);var unseen_sort=document.getElementById('span_flag_UNSEEN').getAttribute('onclick');unseen_sort=unseen_sort.toString();if(!(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'")<0)){var sort_type=sort_box_type;sort_box_type=null;sort_box('UNSEEN',sort_type,false);delete selectedPagingMsgs[msg_info.msg_number];totalFolderMsgs--}}else return}var domains="";if((msg_info.DispositionNotificationTo)&&(!msg_is_read(ID)||(msg_info.Recent=='N'))){if(preferences.notification_domains!=undefined&&preferences.notification_domains!=""){domains=preferences.notification_domains.split(',')}else{var confNotification=true}for(var i=0;i<domains.length;i++)if(Base64.decode(msg_info.DispositionNotificationTo).match("@"+domains[i])){var confNotification=true;break}if(confNotification==undefined)var confNotification=confirm(get_lang("The sender:\n%1\nwaits your notification of reading. Do you want to confirm this?",Base64.decode(msg_info.DispositionNotificationTo)),"");if(confNotification){if(preferences.confirm_read_message){$.Zebra_Dialog(get_lang("Would you like to send the read receipt?"),{'type':'question','title':get_lang('Read receipt'),'buttons':[get_lang("Yes"),get_lang("No")],'overlay_opacity':0.5,'onClose':function(caption){if(caption==get_lang("Yes"))cExecute("$this.imap_functions.send_notification&notificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject),handler_sendNotification);else write_msg(get_lang("Confirmation message is not sent"))}})}else cExecute("$this.imap_functions.send_notification&notificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject),handler_sendNotification)}}if(!msg_is_read(ID)){if(proxy_mensagens.is_local_folder(get_current_folder())){expresso_mail_archive.drawdata=null var tl=expresso_mail_archive.pattern.tagConfig('unseen',ID,1);expresso_mail_archive.taglist=tl;expresso_mail_archive.progressbar=window.setTimeout("expresso_mail_archive.tagMessage()",1)}set_msg_as_read(ID,true);if(msg_info.cacheHit||(!proxy_mensagens.is_local_folder(get_current_folder())&&msg_info.original_ID)){set_message_flag(ID,"seen")}}}setTimeout('resizeWindow()',300)}function auto_refresh(){refresh(preferences.alert_new_msg,preferences.notifications);setTimeout('auto_refresh()',time_refresh)}function auto_archiving(){expresso_mail_sync.start_sync();setTimeout('auto_archiving()',600000)}function notificationFilter(data,notifyCriteria){if(parseInt(notifyCriteria)&&data.length>0&&!activePage){var howManyCriteria=$('div.gray.filtersDeadline .message-list li').length;var differenceOfNewCriteria=data.length-howManyCriteria;if(differenceOfNewCriteria>0){for(var i=data.length-differenceOfNewCriteria;i<data.length;i++){desktopNotification.sentNotification("",get_lang("Filter criteria"),truncate(new Date(data[i].udate).toString('dd/MM HH:mm')+' - '+data[i].from+' - '+data[i].subject,75));desktopNotification.showNotification(false,function(){window.focus();this.cancel()})}}}}function refresh(alert_new_msg,notifyPermission){getFromAlertRules();var handler_refresh=function(data){handlerMessageFilter=function(data){notificationFilter(data,notifyPermission);alarmFollowupflagged('filtersAlarms',data)}cExecute("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules,handlerMessageFilter);if(data['msg_range_end'])if(data['msg_range_end']>0)current_page=data['msg_range_end']/preferences.max_email_per_page;if(!verify_session(data))return;var total_messages_element=Element('tot_m');var box=Element("tbody_box");if(box.childNodes.length==0)showEmptyBoxMsg(box);if(data.length>0||countNewMessage>0){for(var i=0;i<data.length;i++){if(!onceOpenedHeadersMessages[current_folder])onceOpenedHeadersMessages[current_folder]={};onceOpenedHeadersMessages[current_folder][data[i].msg_number]=data[i]}Element("table_message_header_box_0").emptyBody=false;table_element=Element("table_box");var msg_info=document.getElementById('msg_info');if(msg_info!=null){var msg_tr=msg_info.parentNode.parentNode;msg_tr.removeChild(msg_info.parentNode);if(!Element("colgroup_main_"+numBox)){var colgr_element=buildColGroup();colgr_element.setAttribute("id","colgroup_main_"+numBox);table_element.appendChild(colgr_element)}}var box=Element("tbody_box");if(!$("#colgroup_main_0").size()){$(table_element).append(Element("colgroup_main_"+numBox))}if(data.msgs_to_delete.length>0){for(var i=0;i<data.msgs_to_delete.length;i++){if((data.msgs_to_delete[i]!=undefined)&&(data.msgs_to_delete[i]!="")){removeAll(data.msgs_to_delete[i])}}}if(data[0].msg_folder!=current_folder)return false;totalFolderMsgs+=data.new_msgs;for(var i=0;i<data.length;i++){var existent=document.getElementById(data[i].msg_number);if(!existent){selectedPagingMsgs[data[i].msg_number]=false;totalFolderMsgs++;updateSelectedMsgs(false,data[i].msg_number);var new_msg=this.make_tr_message(data[i],current_folder,data.offsetToGMT);$(new_msg).draggable({start:function(){if($(".shared-folders").length){$(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({over:function(a,b){over=$(this);$(this).addClass("folder-over");if(($(this)[0]!=$(this).parent().find(".head_folder")[0]))if($(this).prev()[0])if($(this).parent().find(".expandable-hitarea")[0]==$(this).prev()[0]){setTimeout(function(){if(over.hasClass("folder-over"))over.prev().trigger("click")},500)}},out:function(){$(this).removeClass("folder-over")},drop:function(event,ui){$(this).css("border","");if($(this).parent().attr('id')==undefined){var folder_to='INBOX';var to_folder_title=get_lang("Inbox")}else{var folder_to=$(this).parent().attr('id');var to_folder_title=$(this).attr('title')}var folder_to_move=ui.draggable.parent().attr('id');var border_id=ui.draggable.find("input[type=hidden]").attr("name");if(folder_to_move=="tbody_box"){move_msgs2(get_current_folder(),'selected',0,folder_to,to_folder_title,true);return refresh()}}})}},stop:function(){$(".shared-folders").parent().find(".folder").droppable("destroy")},helper:function(event){$(this).addClass("selected_msg").find("input:checkbox").attr("checked",true);updateSelectedMsgs($(this).find("input:checkbox").is(':checked'),$(this).attr("id"));if($("#tbody_box .selected_shortcut_msg").length>1){$("#tbody_box .selected_shortcut_msg").addClass("selected_msg").find('.checkbox').attr('checked',true);$.each($(".selected_shortcut_msg"),function(index,value){updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id"))})}if(totalSelected()>1)return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:(totalSelected()+" mensagens selecionadas"),type:"messages"})+"</td></tr>");if($(this).find(".td_msg_subject").text().length>18)return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:$(this).find(".td_msg_subject").text().substring(0,18)+"...",type:"messages"})+"</td></tr>");else return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:$(this).find(".td_msg_subject").text(),type:"messages"})+"</td></tr>")},iframeFix:true,delay:150,cursorAt:{top:5,left:56},refreshPositions:true,containment:"#divAppbox"}).bind("contextmenu",function(){if(!(($(event.target).find('img').length>0)&&($(event.target).hasClass('td-label')))){if($(this).find("input:checkbox").attr("checked")!="checked"){$(this).find("input:checkbox").trigger('click');$(this).addClass("selected_msg")}updateSelectedMsgs($(this).find("input:checkbox").is(':checked'),$(this).attr("id"))}});if(data[i].next_msg_number!=undefined&&data[i].next_msg_number!=null){try{box.insertBefore(new_msg,box.childNodes[data[i].msg_key_position])}catch(e){box.insertBefore(new_msg,box.firstChild)}}else if(data[i].Recent=='N'){box.insertBefore(new_msg,box.firstChild)}else{box.appendChild(new_msg)}}}if(parseInt(preferences.use_shortcuts))select_msg("null","reload_msg","null");if(parseInt(alert_new_msg)&&data.new_msgs>0&&activePage)alert(data['new_msgs']>1?get_lang("You have %1 new messages",data['new_msgs'])+"!":get_lang("You have 1 new message")+"!");if(parseInt(notifyPermission)&&(data.new_msgs>0||!!countNewMessage)&&!activePage){countNewMessage+=data.length;desktopNotificationAux=desktopNotification.sentNotification("",get_lang("Notification"),countNewMessage>1?get_lang("You have %1 new messages",countNewMessage)+"!":get_lang("You have 1 new message")+"!");if(auxNotification!=='undefined')desktopNotification.cancelByReference(auxNotification);desktopNotification.showNotification(function(){countNewMessage=0},function(){window.focus();this.cancel();countNewMessage=0});auxNotification=desktopNotificationAux}build_quota(data['quota'])}if(data.new_msgs){total_messages_element.innerHTML=parseInt(total_messages_element.innerHTML)+data.new_msgs}else if(data.tot_msgs){total_messages_element.innerHTML=data.tot_msgs>=0?data.tot_msgs:0}var box=Element("tbody_box");if(box.childNodes.length>1){updateBoxBgColor(box.childNodes)}connector.purgeCache();cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);resizeMailList()}msg_range_end=(current_page*preferences.max_email_per_page);msg_range_begin=(msg_range_end-(preferences.max_email_per_page)+1);main=Element("tbody_box");if(!main)return;main_list=main.childNodes;var tmp='';var string_msgs_in_main='';var len=main_list.length;for(var j=0;j<len;j++)tmp+=main_list[j].id+',';string_msgs_in_main=tmp.substring(0,(tmp.length-1));if(!expresso_offline)$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.refresh',folder:current_folder,msgs_existent:string_msgs_in_main,msg_range_begin:msg_range_begin,msg_range_end:msg_range_end,sort_box_type:sort_box_type,search_box_type:search_box_type,sort_box_reverse:sort_box_reverse}),success:function(data){data=connector.unserialize(data);if(data)handler_refresh(data)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}});var msgs=$("#tbody_box tr");if(!msgs.hasClass("current_selected_shortcut_msg selected_shortcut_msg")){msgs.first().focus().addClass("current_selected_shortcut_msg selected_shortcut_msg")}}function delete_msgs(folder,msgs_number,border_ID,show_success_msg,archive){if(preferences.use_local_messages==1&&expresso_local_messages.isArchiving(msgs_number,folder)){alert("Impossivel deletar mensagens que estão ainda estão sendo arquivadas.");return}var userTrashFolder='';if(arguments.length<4)show_success_msg=true;if(folder=='null')folder=current_folder;if(folder.substr(0,4)=='user'){var arrayFolder=folder.split(cyrus_delimiter);userTrashFolder='user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Trash'];DataLayer.remove('folder',false);DataLayer.get('folder');var has_folder=DataLayer.get('folder',userTrashFolder);if(!has_folder){create_new_folder(special_folders['Trash'],'user'+cyrus_delimiter+arrayFolder[1])}}else userTrashFolder=mount_url_folder(["INBOX",special_folders["Trash"]]);if(openTab.type[currentTab]==1)return move_search_msgs('content_id_'+currentTab,userTrashFolder,special_folders['Trash']);if(currentTab.toString().indexOf("_r")!=-1)msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));if(!archive&&(parseInt(preferences.save_deleted_msg))&&(folder!=userTrashFolder)){move_msgs2(folder,""+msgs_number,border_ID,userTrashFolder,special_folders['Trash'],show_success_msg);return}var handler_delete_msgs=function(data){Element('chk_box_select_all_messages').checked=false;if(currentTab)mail_msg=Element("tbody_box_"+currentTab);else mail_msg=Element("tbody_box");if(preferences.use_shortcuts=='1'){if(mail_msg&&exist_className(mail_msg.childNodes[mail_msg.childNodes.length-1],'selected_shortcut_msg')){select_msg('null','up',true)}else{if(!select_msg('null','down',true)){select_msg('null','up',true)}}}if(data.status==false){write_msg(get_lang("You don't have permission for this operation in this shared folder!"));return false}if(preferences.use_local_messages==1){if(!expresso_mail_archive.isArchiveOperation){if(show_success_msg){if(data.msgs_number.length==1)write_msg(get_lang("The message was deleted."));else write_msg(get_lang("The messages were deleted."))}}}else{if(show_success_msg){if(data.msgs_number.length==1)write_msg(get_lang("The message was deleted."));else write_msg(get_lang("The messages were deleted."))}}if(openTab.type[currentTab]>1){var msg_to_delete=Element(msgs_number);if(parseInt(preferences.delete_and_show_previous_message)&&msg_to_delete){if(msg_to_delete.previousSibling){var previous_msg=msg_to_delete.previousSibling.id;$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:previous_msg,msg_folder:current_folder,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)show_msg(data)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}else{delete_border(currentTab,'false')}}else{delete_border(currentTab,'false')}}for(var i=0;i<data.msgs_number.length;i++){var msg_to_delete=Element(data.msgs_number[i]);if(msg_to_delete){removeAll(msg_to_delete.id);delete selectedPagingMsgs[data.msgs_number[i]]}totalFolderMsgs=totalFolderMsgs-data.msgs_number.length}$.each(data.msgs_number,function(index,value){msgFolder=Base64.encode(get_current_folder());tabToRemove=value+"_r_"+msgFolder.replace(/=/g,"");if($("#"+tabToRemove)){delete_border(tabToRemove,'false')}});Element('tot_m').innerHTML=parseInt(Element('tot_m').innerHTML)-data.msgs_number.length;refresh()}if(msgs_number.length>0||parseInt(msgs_number)>0)cExecute("$this.imap_functions.delete_msgs&folder="+folder+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse,handler_delete_msgs);else write_msg(get_lang('No selected message.'))}function move_search_msgs(border_id,new_folder,new_folder_name,action){var msg_to_delete="";var msg_to_move="";var selected_messages='';var temp_msg;var remove_currente_folder="";var id_border=currentTab.replace(/[a-zA-Z_]+/,"");if(currentTab.indexOf('search_local')!=-1||proxy_mensagens.is_local_folder(new_folder)){alert(get_lang("You cant manipulate local messages on search"));return}var delete_msg=false;if(new_folder_name==special_folders['Trash']){delete_msg=true}selected_messages=get_selected_messages_search();if(preferences.use_local_messages==1&&expresso_local_messages.isArchiving(selected_messages,folder)){alert("Impossivel mover mensagens que ainda estão sendo arquivadas.");return}var handler_move_search_msgs=function(data){if(!data||!data.msgs_number)return;else if(data.deleted){if(data.no_move&&data.move)alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission."));else if(data.msgs_number.length==1)write_msg(get_lang("The message was deleted."));else write_msg(get_lang("The messages were deleted."))}else if(data.status==false&&data.move){alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission."))}else if(data.status==false){alert(get_lang("You don't have permission for this operation in this shared folder!"));return false}else{if(data.msgs_number.length==1)write_msg(get_lang("The message was moved to folder ")+lang_folder(data.new_folder_name));else write_msg(get_lang("The messages were moved to folder ")+lang_folder(data.new_folder_name))}if(data.no_move){var no_remove=data.no_move.split(',');var continua=true;selected_messages=selected_messages.split(",");for(i=0;i<selected_messages.length;i++){for(j=0;j<no_remove.length;j++)if(selected_messages[i]==no_remove[j])continua=false;if(continua)removeAll(selected_messages[i]+'_s'+id_border);continua=true}}else{selected_messages=selected_messages.split(",");for(i=0;i<selected_messages.length;i++){removeAll(selected_messages[i]+'_s'+id_border)}}var box=Element("tbody_box_"+getNumBoxFromTabId(currentTab)).childNodes;if(box.length>1){updateBoxBgColor(box)}connector.purgeCache();if(remove_currente_folder!=""){var mail_msg=Element('tbody_box').childNodes;remove_currente_folder=remove_currente_folder.substring(0,(remove_currente_folder.length-1));remove_currente_folder=remove_currente_folder.split(",");for(i=0;i<remove_currente_folder.length;i++)removeAll(remove_currente_folder[i]);var box=Element("tbody_box");if(box.childNodes.length>0){updateBoxBgColor(box.childNodes)}if(folder==get_current_folder()){Element('tot_m').innerHTML=parseInt(Element('tot_m').innerHTML)-remove_currente_folder.length}}draw_new_tree_folder();EsearchE.refresh()}if(selected_messages){var selected_param="";if(selected_messages.indexOf(',')!=-1){selected_msg_array=selected_messages.split(",");for(i=0;i<selected_msg_array.length;i++){var tr=Element(selected_msg_array[i]+'_s'+id_border);if(tr.getAttribute('name')==current_folder)remove_currente_folder+=tr.id.replace(/_[a-zA-Z0-9]+/,"")+',';if((action=='delete'&&tr.getAttribute('name')==mount_url_folder(["INBOX",special_folders["Trash"]]))||!(parseInt(preferences.save_deleted_msg))){msg_to_delete+=','+special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"")}else if(!(tr.getAttribute('name')==new_folder&&action!='delete')){msg_to_move=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));selected_param+=','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"")}else{write_msg(get_lang('At least one message have the same origin'));return false}}}else{var tr=Element(selected_messages+'_s'+id_border);if(tr.getAttribute('name')==current_folder)remove_currente_folder+=tr.id.replace(/_[a-zA-Z0-9]+/,"")+',';if((action=='delete'&&tr.getAttribute('name')==mount_url_folder(["INBOX",special_folders["Trash"]]))||!(parseInt(preferences.save_deleted_msg))){msg_to_delete=special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"")}else if(!(tr.getAttribute('name')==new_folder&&action!='delete')){trfolder=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));selected_param=trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"")}else{write_msg(get_lang('The origin folder and the destination folder are the same.'));return false}}var params="";if(msg_to_delete!=""&&msg_to_move!=""){params+="&selected_messages_move="+url_encode(selected_param);params+="&new_folder_move="+url_encode(new_folder);params+="&new_folder_name_move="+url_encode(new_folder_name);new_folder=mount_url_folder(["INBOX",special_folders["Trash"]]);new_folder_name=special_folders['Trash'];params+="&selected_messages_delete="+url_encode(msg_to_delete);params+="&new_folder_delete="+url_encode(new_folder);cExecute("$this.imap_functions.move_delete_search_messages",handler_move_search_msgs,params)}else if(msg_to_delete!=""){new_folder=mount_url_folder(["INBOX",special_folders["Trash"]]);new_folder_name=special_folders['Trash'];params+="&delete=true";params+="&selected_messages="+url_encode(msg_to_delete);params+="&new_folder="+url_encode(new_folder);cExecute("$this.imap_functions.move_search_messages",handler_move_search_msgs,params)}else{params="&selected_messages="+url_encode(selected_param);params+="&delete=false";params+="&new_folder="+url_encode(new_folder);params+="&new_folder_name="+url_encode(new_folder_name);cExecute("$this.imap_functions.move_search_messages",handler_move_search_msgs,params)}}else write_msg(get_lang('No selected message.'))}function move_msgs2(folder,msgs_number,border_ID,new_folder,new_folder_name,show_success_msg,not_opem_previus){not_opem_previus=typeof(not_opem_previus)!='undefined'?not_opem_previus:false;var folder_error=new_folder_name;if(preferences.use_local_messages==1&&expresso_local_messages.isArchiving(msgs_number,folder)){alert("Impossivel mover mensagens que estão ainda estão sendo arquivadas.");return}if(!folder||folder=='null')folder=Element("input_folder_"+msgs_number+"_r")?Element("input_folder_"+msgs_number+"_r").value:(openTab.imapBox[currentTab]?openTab.imapBox[currentTab]:get_current_folder());if(openTab.type[currentTab]==1)return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name);var handler_move_msgs=function(data){if(typeof(data)=='string')if(data.match(/^(.*)TRYCREATE(.*)$/)){connector.loadScript('TreeS');var move_to_folder=data.match(/^(.*)Spam(.*)$/)?"Spam":special_folders['Trash'];alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.',folder_error));ttree.FOLDER='root';create_new_folder(move_to_folder,"INBOX");return false}else{write_msg(get_lang('Error moving message.')+" "+get_lang('Permission denied to folder "%1".',new_folder_name));if(new_folder_name=="Trash"&&folder.split("/")[1]==new_folder.split("/")[1]){alert(get_lang("You can not remove the message with the preference 'Send to Trash' enabled. There is no permission to move messages to the trash folder."))}return false}if(data.status==false){write_msg(get_lang("You don't have permission for this operation in this shared folder!"));return false}mail_msg=(Element("divScrollMain_"+numBox))?Element("divScrollMain_"+numBox).firstChild.firstChild:Element("divScrollMain_0").firstChild.firstChild;if(data.msgs_number.length==1){write_msg(get_lang("The message was moved to folder ")+lang_folder(data.new_folder_name))}else{write_msg(get_lang("The messages were moved to folder ")+lang_folder(data.new_folder_name))}if(openTab.type[currentTab]>1){msg_to_delete=Element(msgs_number);if(parseInt(preferences.delete_and_show_previous_message)&&msg_to_delete){if(msg_to_delete.previousSibling){var previous_msg=msg_to_delete.previousSibling.id;if(!not_opem_previus){$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:previous_msg,msg_folder:folder,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)show_msg(data)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}}else{if(current_page>1){$('#msg_opt_previous_'+msg_to_delete.getAttribute('id')+'_r').trigger('click')}else{var border_id=$("#border_id_"+currentTab).prev().attr("id").split("_").slice(2,3).join("")var folderName=current_folder;if(border_id){$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:border_id,msg_folder:folderName,decoded:true}),success:function(data){data=connector.unserialize(data);delete_border(currentTab,'false');if(data){show_msg(data)}},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}else{delete_border(currentTab,'false')}}}}else{if(msg_to_delete.id===String(currentTab).split('_')[0]){delete_border(currentTab,'false')}}if(msg_to_delete){mail_msg.removeChild(msg_to_delete)}var box=Element("tbody_box");if(box.childNodes.length>0){updateBoxBgColor(box.childNodes)}if(folder==get_current_folder()){Element('tot_m').innerHTML=parseInt(Element('tot_m').innerHTML)-1}return}Element('chk_box_select_all_messages').checked=false;if(!mail_msg)mail_msg=Element("tbody_box");data.msgs_number=data.msgs_number.split(",");var msg_to_delete;if(typeof(msgs_number)=='string')all_search_msg=msgs_number.split(',');else if(typeof(msgs_number)=='number')all_search_msg=msgs_number;for(var i=0;i<=all_search_msg.length;i++){msg_to_delete=Element(folder+';'+all_search_msg[i]);if(msg_to_delete)msg_to_delete.parentNode.removeChild(msg_to_delete)}if(preferences.use_shortcuts=='1'){var all_messages=Element('tbody_box').childNodes;var msg_list_shortcut=get_selected_messages_shortcut().split(',');if(data.msgs_number.length>0&&msg_list_shortcut.length>0&&data.msgs_number.toString()==msg_list_shortcut.toString()){if(exist_className(all_messages[all_messages.length-1],'selected_shortcut_msg')){select_msg('null','up',true)}else{if(!select_msg('null','down',true)){select_msg('null','up',true)}}}}for(var i=0;i<data.msgs_number.length;i++){msg_to_delete=Element(data.msgs_number[i]);if(msg_to_delete)mail_msg.removeChild(msg_to_delete)}if(data.msgs_number.length==1)write_msg(get_lang("The message was moved to folder ")+lang_folder(data.new_folder_name));else write_msg(get_lang("The messages were moved to folder ")+lang_folder(data.new_folder_name));if(data.border_ID.indexOf('r')!=-1){if(parseInt(preferences.delete_and_show_previous_message)&&folder==get_current_folder()){delete_border(data.border_ID,'false');show_msg(data.previous_msg)}else{delete_border(data.border_ID,'false')}}if(folder==get_current_folder()){var n_total_msg=parseInt(Element('tot_m').innerHTML)-data.msgs_number.length;n_total_msg=n_total_msg>=0?n_total_msg:0;draw_paging(n_total_msg);Element('tot_m').innerHTML=n_total_msg;totalFolderMsgs-=data.msgs_number.length}refresh()}if(folder==new_folder){write_msg(get_lang('The origin folder and the destination folder are the same.'));return}try{if(proxy_mensagens.is_local_folder(Element('input_folder_'+currentTab).getAttribute('value'))&&!border_ID){alert(get_lang("You cant manipulate local messages on search"));return}}catch(e){}if(currentTab==0&&msgs_number=="selected")msgs_number=get_selected_messages();else if(currentTab!=0&&msgs_number=="selected")msgs_number=currentTab.substr(0,currentTab.indexOf('_r'));if(openTab.type[currentTab]==1){return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name)}if(currentTab.toString().indexOf("_r")!=-1&&currentTab==border_ID){if(currentTab.toString().indexOf('_s')!=-1)msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf('_s'));else msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf('_r'))}if(msgs_number){refresh()}else{$("#"+get_current_folder()).find('span:first').addClass('selected')}if(proxy_mensagens.is_local_folder(folder)){expresso_mail_archive.update_counters=true;if(msgs_number=='selected'){msgs_number=get_selected_messages()}if(new_folder=='local_root'){alert(get_lang("Select a folder!"))}if(parseInt(msgs_number)>0||msgs_number.length>0){if(proxy_mensagens.is_local_folder(new_folder)){expresso_mail_archive.moveMessages(new_folder.replace('local_messages_',''),msgs_number);delete_border(border_ID)}else{if(!new_folder){new_folder='INBOX'}if(currentTab.toString().indexOf("_r")!=-1){msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"))}expresso_mail_archive.unarchieve(folder,new_folder,msgs_number);if(currentTab!=0)delete_border(border_ID)}}else{write_msg(get_lang('No selected message.'))}}else{if(proxy_mensagens.is_local_folder(new_folder)){if(msgs_number=='selected'){archive_msgs(folder,new_folder)}else{archive_msgs(folder,new_folder,msgs_number)}}else{if(parseInt(msgs_number)>0||msgs_number.length>0){var handler_removeFlag=function(){$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.move_messages',folder:folder,msgs_number:""+msgs_number,border_ID:border_ID,sort_box_type:sort_box_type,search_box_type:search_box_type,sort_box_reverse:sort_box_reverse,reuse_border:border_ID,new_folder:new_folder,new_folder_name:new_folder_name,get_previous_msg:(!not_opem_previus?preferences.delete_and_show_previous_message:false),decoded:true}),success:function(data){data=connector.unserialize(data);$.each(msgs_number.split(","),function(index,value){delete selectedPagingMsgs[value];msgFolder=Base64.encode(get_current_folder());tabToRemove=value+"_r_"+msgFolder.replace(/=/g,"");if($("#"+tabToRemove)){}});totalFolderMsgs-=msgs_number.split(",").length;selectAllFolderMsgs();$('.select-link').unbind('click');if(data)handler_move_msgs(data)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}var hasFolder=false;$.each(fromRules,function(index,value){if(value==folder){hasFolder=true;cExecute("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_number,handler_removeFlag);return false}});if(!hasFolder){handler_removeFlag()}}else write_msg(get_lang('No selected message.'))}}$.each(msgs_number.split(","),function(index,value){delete selectedPagingMsgs[value]});totalFolderMsgs=totalFolderMsgs-msgs_number.split(",").length;selectAllFolderMsgs(false);updateSelectedMsgs()}function move_msgs(folder,msgs_number,border_ID,new_folder,new_folder_name,not_opem_previus){move_msgs2(folder,msgs_number,border_ID,new_folder,new_folder_name,true,not_opem_previus)}function normalizeMsgNumber(msgNumber){if(msgNumber||msgNumber=='selected')msgNumber=get_selected_messages();if(currentTab.toString().indexOf("_r")!=-1){if(currentTab.toString().indexOf('_s')!=-1)msgNumber=currentTab.toString().substr(0,currentTab.toString().indexOf('_s'));else msgNumber=currentTab.toString().substr(0,currentTab.toString().indexOf('_r'))}if(parseInt(msgNumber)<=0||msgNumber.length<=0){write_msg(get_lang('No selected message.'));return(false)}return(msgNumber)}function archive_search_msgs(folder_dest){var id_msgs="";id_msgs=get_selected_messages_search();var msg_to_arquive="";var messages="";var id_border=currentTab.replace(/[a-zA-Z_]+/,"");if(parseInt(id_msgs)<=0||id_msgs.length<=0)return write_msg(get_lang('No selected message.'));if(folder_dest=='local_root'||folder_dest==null)folder_dest='local_Inbox';id_msgs=expresso_local_messages.checkArchived(id_msgs,folder_dest);if(!id_msgs){write_msg("Todas as mensagens já foram arquivadas anteriormente.");return}document.getElementById("overlay").style.visibility="visible";var handler_arquivar_mensagens=function(data){var msgs_info=[];for(var i=0;i<data.length;i++)msgs_info[i]=connector.unserialize(data[i]);var h=expresso_local_messages.has_local_mails();expresso_local_messages.insert_mails(msgs_info,folder_dest,function(s,f){complete_archiving(s,f,h)});document.getElementById("overlay").style.visibility="hidden"}id_msgs=id_msgs.split(',');for(i=0;i<id_msgs.length;i++){var tr=Element(id_msgs[i]+'_s'+id_border);msg_to_arquive=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));messages+=','+msg_to_arquive+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"")}$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:messages,msg_folder:folder_dest,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)handler_arquivar_mensagens(data)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}function archive_msgs(folder,folder_dest,id_msgs){if(typeof(currentTab)=="string"&&currentTab.indexOf("local")!=-1){alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais.");return true}write_msg(get_lang('Starting to archive messages'));if(currentTab.toString().indexOf("_r")!=-1){id_msgs=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"))}if(!id_msgs)id_msgs=get_selected_messages();if(folder_dest=='local_root'||folder_dest==null)folder_dest='local_inbox';if(parseInt(id_msgs)>0||id_msgs.length>0){window.setTimeout("expresso_mail_archive.Archive('"+folder+"','"+folder_dest+"','"+id_msgs+"')",1);selectAllFolderMsgs(false)}else write_msg(get_lang('No selected message.'))}function complete_archiving(success,fails,has_local_messages_before){var msgs_to_remove={};var target=mount_url_folder(["INBOX",special_folders["Trash"],'tmpMoveToLocal']);success=expresso_local_messages.select_mail(['original_id','original_folder'],success);for(var i=0;i<success.length;i++){var msg_info=success[i];Element('chk_box_select_all_messages').checked=false;if(Element("check_box_message_"+msg_info.original_id)){Element("check_box_message_"+msg_info.original_id).checked=false}if(Element(msg_info.original_id)){remove_className(Element(msg_info.original_id),'selected_msg')}msgs_to_remove[msg_info.original_folder]=msgs_to_remove[msg_info.original_folder]||[];msgs_to_remove[msg_info.original_folder].push(msg_info.original_id)}if(preferences.keep_archived_messages==0){for(var folder in msgs_to_remove){if(folder!='undefined')delete_msgs(folder,msgs_to_remove[folder],'null',false,true)}}if(!has_local_messages_before&&expresso_local_messages.has_local_mails())ttreeBox.update_folder();else update_menu()}function action_msg_selected_from_search(aba,evento){if(evento=="delete")move_search_msgs(aba,'INBOX/Trash','Trash','delete')}function get_all_messages_search(){var aba=document.getElementById('content_id_'+currentTab);var messages="";jQuery(function(){jQuery("#"+aba.id+" tr").each(function(i,main_list){messages+=main_list.id.replace(/_[a-zA-Z0-9]+/,"")+','})});if(messages.indexOf(',')==0)messages=messages.substring(1,(messages.length));return messages.substring(0,(messages.length-1))}function get_selected_messages_search(){var aba=document.getElementById('content_id_'+currentTab);var selected_messages="";jQuery("#"+aba.id+" tr").each(function(i,main_list){var check_box=main_list.firstChild.firstChild;if(check_box&&check_box.checked){selected_messages+=main_list.id.replace(/_[a-zA-Z0-9]+/,"")+','}});if(selected_messages!=""){if(selected_messages.indexOf(',')==0)selected_messages=selected_messages.substring(1,(selected_messages.length));selected_messages=selected_messages.substring(0,(selected_messages.length-1));return selected_messages}else{return false}}function get_selected_messages_search_role(){var aba=document.getElementById('content_id_'+currentTab);var selected_messages="";jQuery("#"+aba.id+" tr").each(function(i,main_list){var check_box=main_list.firstChild.firstChild;if(check_box&&check_box.checked&&check_box.id!='chk_box_select_all_messages_search'){selected_messages+=main_list.role+','}});if(selected_messages!=""){if(selected_messages.indexOf(',')==0)selected_messages=selected_messages.substring(1,(selected_messages.length));selected_messages=selected_messages.substring(0,(selected_messages.length-1));return selected_messages}else{return false}}function get_selected_messages_shortcut(){var main;try{main=document.getElementById("divScrollMain_"+numBox).firstChild.firstChild}catch(e){};if(!main)main=Element("tbody_box_"+numBox);if(!main)main=Element("tbody_box");var main_list=main.childNodes;var selected_messages_by_shortcuts='';var j=0;for(j;j<(main_list.length);j++){if(exist_className(Element(main_list[j].id),'selected_shortcut_msg')){selected_messages_by_shortcuts+=main_list[j].id+','}}selected_messages_by_shortcuts=selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1));return selected_messages_by_shortcuts}function get_selected_messages(){var selectedMsg=new Array();$.each(selectedPagingMsgs,function(index,value){if(value)selectedMsg.push(index)});return""+selectedMsg}function clear_selected_messages(){selectedPagingMsgs={}}function replaceAll(string,token,newtoken){while(string.indexOf(token)!=-1){string=string.replace(token,newtoken)}return string}function new_message_to(email){var new_border_ID=new_message('new','null');document.getElementById("to_"+new_border_ID).value=email}function new_message(type,border_ID,flagged){if(RichTextEditor.editorReady===false)return false;RichTextEditor.editorReady=false;if(Element('show_img_link_'+border_ID)){show_msg_img(border_ID.match(/^\d*/)[0],Element('input_folder_'+border_ID).value)}var new_border_ID=draw_new_message(parseInt(border_ID.replace('_r','')));if(typeof(openTab.type[new_border_ID])!="undefined"){if(tabTypes[type]==openTab.type[new_border_ID]){if(type!='edit'){delete_border(currentTab);new_border_ID=draw_new_message(parseInt(border_ID))}}else{var a_types={6:get_lang("Forward"),7:get_lang("Reply"),8:get_lang("Reply to all with history"),9:get_lang("Reply without history"),10:get_lang("Reply to all without history")};if(new_border_ID!=0)if(!confirm(get_lang("Your message to %1 has not been saved or sent. "+"To %2 will be necessary open it again. Discard your message?",a_types[openTab.type[new_border_ID]].toUpperCase(),a_types[tabTypes[type]].toUpperCase()))){return new_border_ID}else{delete_border(currentTab);new_border_ID=draw_new_message(parseInt(border_ID))}}}if(new_border_ID=='maximo'){RichTextEditor.editorReady=true;return false}if(new_border_ID==false){RichTextEditor.editorReady=true;setTimeout('new_message(\''+type+'\',\''+border_ID+'\',\''+flagged+'\');',500);return false}openTab.type[new_border_ID]=tabTypes[type];var folder_message=Element("input_folder_"+border_ID);if(folder_message){var input_current_folder=document.createElement('input');input_current_folder.id="new_input_folder_"+border_ID;input_current_folder.name="input_folder";input_current_folder.type="hidden";input_current_folder.value=folder_message.value;Element("content_id_"+new_border_ID).appendChild(input_current_folder)}var title='';data=[];if(Element("from_"+border_ID)){if(document.getElementById("reply_to_"+border_ID)){data.to=document.getElementById("reply_to_values_"+border_ID).value;data.to=data.to.replace(/&lt;/gi,"<");data.to=data.to.replace(/&gt;/gi,">")}else{if(document.getElementById("sender_values_"+border_ID)){data.to=document.getElementById("sender_values_"+border_ID).value;data.to=data.to.replace(/&lt;/gi,"<");data.to=data.to.replace(/&gt;/gi,">")}else if(document.getElementById("from_values_"+border_ID)){data.to=document.getElementById("from_values_"+border_ID).value;data.to=data.to.replace(/&lt;/gi,"<");data.to=data.to.replace(/&gt;/gi,">")}}if(document.getElementById("to_values_"+border_ID)){data.to_all=document.getElementById("to_values_"+border_ID).value;data.to_all_alternative=document.getElementById("user_email_alternative").value;data.to_all=data.to_all.replace(/\n/gi," ");data.to_all=data.to_all.replace(/&lt;/gi,"<");data.to_all=data.to_all.replace(/&gt;/gi,">");var _array_to_all=data.to_all.split(",");var _array_to_alternative=data.to_all_alternative.split(",")}}if(document.getElementById("cc_"+border_ID)){data.cc=document.getElementById("cc_values_"+border_ID).value;data.cc=data.cc.replace(/&lt;/gi,"<");data.cc=data.cc.replace(/&gt;/gi,">");var _array_cc=data.cc.split(",")}if(document.getElementById("cco_"+border_ID)){data.cco=document.getElementById("cco_values_"+border_ID).value;data.cco=data.cco.replace(/&lt;/gi,"<");data.cco=data.cco.replace(/&gt;/gi,">")}if($("#subject_"+border_ID))data.subject=$("#subject_"+border_ID).text();if(data.subject==get_lang("(no subject)   "))data.subject='';if(document.getElementById("body_"+border_ID))data.body=document.getElementById("body_"+border_ID).innerHTML;if(document.getElementById("from_values_"+border_ID))data.from=document.getElementById("from_values_"+border_ID).value;if(Element('date_'+border_ID)){data.date=Element('date_'+border_ID).innerHTML}if(Element('date_day_'+border_ID)){data.date_day=Element('date_day_'+border_ID).value}if(Element('date_hour_'+border_ID)){data.date_hour=Element('date_hour_'+border_ID).value}var signature=RichTextEditor.getSignatureDefault();if(type!="new"&&type!="edit"&&document.getElementById("is_local_"+border_ID)!=null)data.is_local_message=(document.getElementById("is_local_"+border_ID).value=="1")?true:false;if(typeof($.fn.elastic)=="undefined"){$.lazy({src:'../prototype/plugins/jquery-elastic/jquery.elastic.source.js',name:'elastic'})}var content=$("#content_id_"+new_border_ID);var btnSaveVerify=function(){$("#content_id_"+currentTab+" .save").button("disable");dataBtn=new Array(".to",".cc",".cco","input[name=input_subject]",".reply-to");for(var i in dataBtn){$("#content_id_"+currentTab+" "+dataBtn[i]).keydown(function(){$("#content_id_"+currentTab+" .save").button("enable")})}RichTextEditor.keydown(new_border_ID)}switch(type){case"reply_without_history":btnSaveVerify();RichTextEditor.replyController=true;content.find('[name="input_to"]').val(data.to);draw_reply_boxes_by_field("to",data.to,content);title="Re: "+html_entities(data.subject);content.find(".subject").val("Re: "+data.subject);useOriginalAttachments(new_border_ID,border_ID);content.find('[name="msg_reply_from"]').val($("#msg_number_"+border_ID).val());if(preferences.use_signature=="1"){RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature,true)}break;case"reply_with_history":btnSaveVerify();RichTextEditor.replyController=true;title="Re: "+html_entities(data.subject);content.find(".subject").val("Re: "+data.subject);content.find('[name="input_to"]').val(data.to);draw_reply_boxes_by_field("to",data.to,content);content.find('[name="msg_reply_from"]').val($("#msg_number_"+border_ID).val());block_quoted_body=make_body_reply(data.body,data.from,data.date_day,data.date_hour);useOriginalAttachments(new_border_ID,border_ID);if(preferences.use_signature=="1"){RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature+'<div><br type="_moz"></div>'+block_quoted_body,true)}else{RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+block_quoted_body,true)}break;case"reply_to_all_without_history":btnSaveVerify();RichTextEditor.replyController=true;data.to_all=new Array();data.to_all=removeUserEmail(_array_to_all);data.to_all=removeAlternative(data.to_all,_array_to_alternative);content.find('[name="msg_reply_from"]').val($("#msg_number_"+border_ID).val());data.to_all=data.to_all.join(",");title="Re: "+html_entities(data.subject);content.find(".subject").val("Re: "+data.subject);if(data.to.indexOf(Element("user_email").value)>0){draw_reply_boxes_by_field("to",data.to_all,content);content.find('[name="input_to"]').val(data.to_all)}else{draw_reply_boxes_by_field("to",data.to+','+data.to_all,content);content.find('[name="input_to"]').val(data.to+','+data.to_all)}if(data.cc){data.cc=new Array();data.cc=removeUserEmail(_array_cc);data.cc=removeAlternative(data.cc,_array_to_alternative);if(data.cc!=get_lang("undisclosed-recipient"))data.cc=data.cc.join(",");else data.cc="";if(data.cc!=""){content.find('[name="input_cc"]').val(data.cc);input_binds(content.find('[name="input_cc"]').parent(),new_border_ID);content.find(".cc-tr").show();content.find(".cc-button").toggleClass("expressomail-button-icon-ative");content.find(".cc-button").find("span").html("Remover CC");draw_reply_boxes_by_field("cc",data.cc,content)}}useOriginalAttachments(new_border_ID,border_ID);if(preferences.use_signature=="1"){RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature,true)}break;case"reply_to_all_with_history":btnSaveVerify();RichTextEditor.replyController=true;data.to_all=new Array();data.to_all=removeUserEmail(_array_to_all);data.to_all=removeAlternative(data.to_all,_array_to_alternative);content.find('[name="msg_reply_from"]').val($("#msg_number_"+border_ID).val());if(data.to_all!=get_lang("undisclosed-recipient"))data.to_all=data.to_all.join(",");else data.to_all="";title="Re: "+html_entities(data.subject);if(data.to.indexOf(Element("user_email").value)>0){draw_reply_boxes_by_field("to",data.to_all,content);content.find('[name="input_to"]').val(data.to_all)}else{draw_reply_boxes_by_field("to",data.to+','+data.to_all,content);content.find('[name="input_to"]').val(data.to+','+data.to_all)}if(data.cc){data.cc=new Array();data.cc=removeUserEmail(_array_cc);data.cc=removeAlternative(data.cc,_array_to_alternative);if(data.cc!=get_lang("undisclosed-recipient"))data.cc=data.cc.join(",");else data.cc="";if(data.cc!=""){content.find('[name="input_cc"]').val(data.cc);input_binds(content.find('[name="input_aux_cc"]').parent(),new_border_ID);content.find(".cc-tr").show();content.find(".cc-button").toggleClass("expressomail-button-icon-ative");content.find(".cc-button").find("span").html("Remover CC");draw_reply_boxes_by_field("cc",data.cc,content)}}content.find(".subject").val("Re: "+data.subject);block_quoted_body=make_body_reply(data.body,data.from,data.date_day,data.date_hour);useOriginalAttachments(new_border_ID,border_ID);if(preferences.use_signature=="1"){RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div><div><br type="_moz"></div>'+signature+'<div><br type="_moz"></div>'+block_quoted_body,true)}else{RichTextEditor.setInitData(new_border_ID,block_quoted_body,true)}break;case"forward":btnSaveVerify();title="Fw: "+html_entities(data.subject);content.find(".subject").val("Fw: "+data.subject);var divFiles=Element("divFiles_"+new_border_ID);var campo_arquivo;content.find('[name="msg_forward_from"]').val($("#msg_number_"+border_ID).val());if(Element("attachments_"+border_ID))addOriginalAttachments(new_border_ID,border_ID);if(preferences.use_signature=="1"){$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>'+signature+'<div><br type="_moz"></div>'+make_forward_body(data.body,data.to,data.date,data.subject,data.to_all,data.cc));RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature+'<div><br type="_moz"></div>'+make_forward_body(data.body,data.to,data.date,data.subject,data.to_all,data.cc));content.find(".to").focus()}else{RichTextEditor.setInitData(new_border_ID,make_forward_body(data.body,data.to,data.date,data.subject,data.to_all,data.cc));$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>'+make_forward_body(data.body,data.to,data.date,data.subject,data.to_all,data.cc));content.find(".to").focus()}break;case"new":btnSaveVerify();title=get_lang("New Message");if(Element('msg_number').value){var _to=Element('msg_number').value;var reEmail=/^[A-Za-z\d_-]+(\.[A-Za-z\d_-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;if(!reEmail.test(_to)){var array_contacts=contacts.split(',');for(i=0;i<array_contacts.length;i++){if(array_contacts[i].lastIndexOf(_to)!="-1"){var _group=array_contacts[i].split(";");_to='"'+_group[0]+'" <'+_group[1]+'>';break}}}content.find('[name="input_to"]').val(_to+',');draw_email_box(_to,content.find(".to").filter("input"));Element('msg_number').value=''}if(preferences.use_signature=="1"){$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>'+signature);RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature);content.find(".to").focus()}else content.find('[name="input_to"]').focus();break;case"edit":btnSaveVerify();if(flagged=='F')$(".important").addClass("expressomail-button-icon-ative");openTab.imapBox[new_border_ID]=folder_message.value;document.getElementById('font_border_id_'+new_border_ID).innerHTML=data.subject;title="Edição: "+html_entities(data.subject);data.to=Element("to_values_"+border_ID).value;if(data.to!=get_lang("without destination")){data.to=data.to.replace(/&lt;/gi,"<");data.to=data.to.replace(/&gt;/gi,">")}else{data.to=""}draw_reply_boxes_by_field("to",data.to,content);content.find('[name="input_to"]').val(data.to);if(data.cc){data.cc=data.cc.replace(/&lt;/gi,"<");data.cc=data.cc.replace(/&gt;/gi,">");content.find('[name="input_cc"]').val(data.cc);input_binds(content.find('[name="input_cc"]').parent(),new_border_ID);content.find(".cc-tr").show();content.find(".cc-button").toggleClass("expressomail-button-icon-ative");content.find(".cc-button").find("span").html(get_lang('Remove CC'));draw_reply_boxes_by_field("cc",data.cc,content)}if(data.cco){if(content.find('[name="input_cco"]').length){content.find('[name="input_cco"]').val(data.cco);content.find(".cco-tr").show();content.find(".cco-button").toggleClass("expressomail-button-icon-ative");content.find(".cco-button").find("span").html(get_lang('Remove CCo'));input_binds(content.find('[name="input_cco"]').parent(),new_border_ID);draw_reply_boxes_by_field("cco",data.cco,content)}}content.find(".subject").val(data.subject);if($("#disposition_notification_"+border_ID).length){content.find('[name="input_return_receipt"]').attr("checked",true);content.find(".return-recept").toggleClass("expressomail-button-icon-ative")}var element_important_message=Element("important_message_"+new_border_ID);if(element_important_message){if($("#disposition_important_"+border_ID).length){content.find('[name="input_important_message"]').attr("checked",true);content.find(".important").toggleClass("expressomail-button-icon-ative")}}if(Element("attachments_"+border_ID))addOriginalAttachments(new_border_ID,border_ID);RichTextEditor.setInitData(new_border_ID,data.body,'edit');uidsSave[new_border_ID].push(new_border_ID);close_delete(border_ID);break;default:}content.find('[name="input_to"]').trigger("update");var txtarea=$('#body_'+new_border_ID);var height=document.body.scrollHeight-330;txtarea.css("overflowY","auto");txtarea.css("height",height);$("#border_id_"+new_border_ID).attr("title",title);set_border_caption("border_id_"+new_border_ID,title);resizeWindow();return new_border_ID}function draw_reply_boxes_by_field(field,value,context){array=break_comma(value);$.each(array,function(index,value){draw_email_box(value,context.find("."+field).filter("textarea:first"))})}function removeUserEmail(emailList){var userEmail=Element("user_email").value;var array_emails=Array();var j=0;for(var i=0;i<emailList.length;i++){if(emailList[i].indexOf(userEmail)<0){array_emails[j++]=emailList[i]}}return array_emails}function removeAlternative(value_to_all,_array_to_alternative){for(i=0;i<_array_to_alternative.length;i++){for(k=0;k<value_to_all.length;k++){if(value_to_all[k].match(/<([^<]*)>[\s]*$/)){if(value_to_all[k].match(/<([^<]*)>[\s]*$/)[1].toLowerCase()==_array_to_alternative[i].toLowerCase()){value_to_all.splice(k,1);k--}}else if(value_to_all[k].replace(/^\s+|\s+$/g,"").toLowerCase()==_array_to_alternative[i].toLowerCase()){value_to_all.splice(k,1);k--}}}return value_to_all}function useOriginalAttachments(new_border_ID,old_id_border){if(Element("attachments_"+old_id_border)){var fileUploadMSG=$('#fileupload_msg'+new_border_ID);var attachments=$("#attachments_"+old_id_border).find("a");if(openTab.imapBox[new_border_ID].split("local").length>1&&attachments.length>0){alert("Não é possivel utilizar os anexos das mensagens locais, favor desarquivar para ter acesso aos anexos");return false}var imagens=block_quoted_body.match(/<img[^>]*>/g);var arrayAttachments=[];var arrayAttachmentsA=[];for(var i=0;i<attachments.length;i++){if((attachments[i].tagName=="SPAN")||(attachments[i].tagName=="IMG")||((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1)))continue;if(attachments[i].href.split("local")>1){var arrayAtt=attachments[i].href.replace("javascript:download_local_attachment(","").replace(")","").split(',')}else{var arrayAtt=attachments[i].href.replace("javascript:download_attachments(","").replace(")","").split(',')}var att=new Object();var regex=new RegExp("'","g");att.folder=utf8_decoder(Base64.decode(arrayAtt[0].replace(regex,"")));att.uid=arrayAtt[1].replace(regex,"");att.part=arrayAtt[3].replace(regex,"");att.type='imapPart';var idATT=JSON.stringify(att);if(block_quoted_body.indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&amp;msgNumber='+att.uid+'&amp;indexPart='+att.part+'"')!==-1){addAttachment(new_border_ID,idATT);var attach={};attach.fileName=attachments[i].text.substring(0,attachments[i].text.lastIndexOf('('));attach.fullFileName=attach.fileName;if(attach.fileName.length>20)attach.fileName=attach.fileName.substr(0,17)+" ... "+attach.fileName.substr(attach.fileName.length-9,attach.fileName.length);attach.fileSize=attachments[i].text.substring((attachments[i].text.lastIndexOf('(')+1),attachments[i].text.lastIndexOf(')'));attach.error=false;fileUploadMSG.find(' .attachments-list').show();var upload=$(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs",{file:attach}));upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>');upload.find(".att-box-loading").remove();upload.find('.att-box-delete').click(function(){var idAttach=$(this).parent().find('input[name="fileId[]"]').val();var content_body=RichTextEditor.getData('body_'+new_border_ID);var imagens=content_body.match(/<img[^>]*>/g);var att=JSON.parse(idAttach);if(imagens!=null){for(var x=0;x<imagens.length;x++)if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&amp;msgNumber='+att.uid+'&amp;indexPart='+att.part)!==-1)content_body=content_body.replace(imagens[x],'');RichTextEditor.setData('body_'+new_border_ID,content_body)}fileUploadMSG.find('.attachments-list').find('input[value="'+idAttach+'"]');delAttachment(new_border_ID,idAttach);$(this).parent().qtip("destroy");$(this).parent().remove();if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){fileUploadMSG.find(' .attachments-list').hide()}});fileUploadMSG.find('.attachments-list').append(upload);fileUploadMSG.find('.attachments-list .att-box:last').qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true,screen:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:3,textAlign:'left',tip:true,name:'blue'}})}else{arrayAttachments.push(idATT);arrayAttachmentsA.push(attachments[i])}}if(arrayAttachments.length>0){var orignialAtt=fileUploadMSG.find('.button-files-upload').append(' <button tabindex="-1" class="message-add-original-att button small">Anexar arquivos originais</button>').find(".message-add-original-att").button();orignialAtt.click(function(event){for(var i=0;i<arrayAttachments.length;i++){var att=JSON.parse(arrayAttachments[i]);addAttachment(new_border_ID,arrayAttachments[i]);var attach={};attach.fileName=arrayAttachmentsA[i].text.substring(0,arrayAttachmentsA[i].text.lastIndexOf('('));attach.fullFileName=attach.fileName;if(attach.fileName.length>20)attach.fileName=attach.fileName.substr(0,17)+" ... "+attach.fileName.substr(attach.fileName.length-9,attach.fileName.length);attach.fileSize=arrayAttachmentsA[i].text.substring((arrayAttachmentsA[i].text.lastIndexOf('(')+1),arrayAttachmentsA[i].text.lastIndexOf(')'));attach.error=false;fileUploadMSG.find(' .attachments-list').show();var upload=$(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs",{file:attach}));upload.find('.att-box-loading').remove();upload.append('<input type="hidden" name="fileId[]" value=\''+arrayAttachments[i]+'\'/>');upload.find('.att-box-delete').click(function(){var idAttach=$(this).parent().find('input[name="fileId[]"]').val();var content_body=RichTextEditor.getData('body_'+new_border_ID);var imagens=content_body.match(/<img[^>]*>/g);var att=JSON.parse(idAttach);if(imagens!=null){for(var x=0;x<imagens.length;x++)if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&amp;msgNumber='+att.uid+'&amp;indexPart='+att.part)!==-1)content_body=content_body.replace(imagens[x],'');RichTextEditor.setData('body_'+new_border_ID,content_body)}fileUploadMSG.find('.attachments-list').find('input[value="'+idAttach+'"]');delAttachment(new_border_ID,idAttach);$(this).parent().qtip("destroy");$(this).parent().remove();if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){fileUploadMSG.find(' .attachments-list').hide()}});fileUploadMSG.find('.attachments-list').append(upload);fileUploadMSG.find('.attachments-list .att-box:last').qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true,screen:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:3,textAlign:'left',tip:true,name:'blue'}})}$(this).remove()})}}}function addOriginalAttachments(new_border_ID,old_id_border){var fileUploadMSG=$('#fileupload_msg'+new_border_ID);var attachments=$("#attachments_"+old_id_border).find("a");if(openTab.imapBox[new_border_ID].split("local").length>1&&attachments.length>0){alert("Não é possivel utilizar os anexos das mensagens locais, favor desarquivar para ter acesso aos anexos");return false}for(var i=0;i<attachments.length;i++){if((attachments[i].tagName=="SPAN")||(attachments[i].tagName=="IMG")||((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1)))continue;fileUploadMSG.find(' .attachments-list').show();if(attachments[i].href.split("local").length>1){var arrayAtt=attachments[i].href.replace("javascript:download_local_attachment(","").replace(")","").split(',')}else{var arrayAtt=attachments[i].href.replace("javascript:download_attachments(","").replace(")","").split(',')}var att=new Object();var regex=new RegExp("'","g");att.folder=utf8_decoder(Base64.decode(arrayAtt[0].replace(regex,"")));att.uid=arrayAtt[1].replace(regex,"");att.part=arrayAtt[3].replace(regex,"");att.type='imapPart';var idATT=JSON.stringify(att);addAttachment(new_border_ID,idATT);var attach={};var attachText=(is_ie?attachments[i].innerText:attachments[i].text);attach.fileName=attachText.substring(0,attachText.lastIndexOf('('));attach.fullFileName=attach.fileName;if(attach.fileName.length>20)attach.fileName=attach.fileName.substr(0,17)+" ... "+attach.fileName.substr(attach.fileName.length-9,attach.fileName.length);attach.fileSize=attachText.substring((attachText.lastIndexOf('(')+1),attachText.lastIndexOf(')'));attach.error=false;var upload=$(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs",{file:attach}));upload.find('.att-box-loading').remove();upload.find('.att-box-delete').click(function(){var idAttach=$(this).parent().find('input[name="fileId[]"]').val();var content_body=RichTextEditor.getData('body_'+new_border_ID);var imagens=content_body.match(/<img[^>]*>/g);var att=JSON.parse(idAttach);if(imagens!=null){for(var x=0;x<imagens.length;x++)if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&amp;msgNumber='+att.uid+'&amp;indexPart='+att.part)!==-1)content_body=content_body.replace(imagens[x],'');RichTextEditor.setData('body_'+new_border_ID,content_body)}fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]');delAttachment(new_border_ID,idAttach);$(this).parent().qtip("destroy");$(this).parent().remove();if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){fileUploadMSG.find(' .attachments-list').hide()}});upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>');fileUploadMSG.find('.attachments-list').append(upload);fileUploadMSG.find('.attachments-list .att-box:last').qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true,screen:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:3,textAlign:'left',tip:true,name:'blue'}})}}function send_message_return(data,ID){if(typeof(data)=='object'&&data.load){cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu)}watch_changes_in_msg(ID);var content=$("#content_id_"+ID);var sign=false;var crypt=false;var reComplexEmail=/<([^<]*)>[\s]*$/;if((preferences.use_assinar_criptografar!='0')&&(preferences.use_signature_digital_cripto!='0')){var checkSign=document.getElementById('return_digital_'+ID)if(checkSign.checked){sign=true}var checkCript=document.getElementById('return_cripto_'+ID);if(checkCript.checked){crypt=true}}if(typeof(data)=='object'&&!data.success){connector=new cConnector();if(sign||crypt){var operation='';if(sign){operation='sign'}else{operation='nop'}}if(data.body){Element('cert_applet').doButtonClickAction(operation,ID,data.body)}else{alert(data.error)}return}if(data&&data.success==true){var msg_number_replied=content.find('[name="msg_reply_from"]');var msg_number_forwarded=content.find('[name="msg_forward_from"]');if(msg_number_replied.val()){proxy_mensagens.proxy_set_message_flag(msg_number_replied.val(),'answered')}else if(msg_number_forwarded.val()){proxy_mensagens.proxy_set_message_flag(msg_number_forwarded.val(),'forwarded')}if(expresso_offline){write_msg(get_lang('Your message was sent to queue'));delete_border(ID,'true');return}else{if(wfolders.alert){write_msg(get_lang('Your message was sent and save.'));wfolders.alert=false}else{write_msg(get_lang('Your message was sent.'))}}delete_border(ID,'true');var arrayTo=content.find(".to-tr").find(".box").clone();save_dynamic_contacts(arrayTo);var arrayCC=content.find(".cc-tr").find(".box").clone();save_dynamic_contacts(arrayCC);var arrayCCo=content.find(".cco-tr").find(".box").clone();save_dynamic_contacts(arrayCCo);if(parseInt(preferences.use_dynamic_contacts))updateDynamicContact();cache=new Array()}else{if(data=='Post-Content-Length')write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',Element('upload_max_filesize').value));else if(data){var error_mail=$.trim(data.split(":")[data.split(":").length-1]);var array=content.find(".to-tr").find(".box");$.each(array,function(index,value){if(error_mail==$(value).find("input").val().match(reComplexEmail)[1])$(value).addClass("invalid-email-box")});if(content.find('[name="input_cco"]').length){if(content.find(".cco-tr").css("display")!="none"){var array=content.find(".cco-tr").find(".box");$.each(array,function(index,value){if(error_mail==$(value).find("input").val().match(reComplexEmail)[1])$(value).addClass("invalid-email-box")})}}if(content.find(".cc-tr").css("display")!="none"){var array=content.find(".cc-tr").find(".box");$.each(array,function(index,value){if(error_mail==$(value).find("input").val().match(reComplexEmail)[1])$(value).addClass("invalid-email-box")})}write_msg(data)}else write_msg(get_lang("Connection failed with %1 Server. Try later.","Web"));var save_link=$("#content_id_"+ID).find(".save")[0];save_link.onclick=function onclick(event){openTab.toPreserve[ID]=true;save_msg(ID)};$("#save_message_options_"+ID).button({disabled:false})}if(!expresso_offline)connector.hideProgressBar()}function save_dynamic_contacts(array){if(parseInt(preferences.use_dynamic_contacts)){$.each(array,function(i,value){var stop=false;$.each(dynamicPersonalContacts,function(x,valuex){if(valuex.email==$(value).find("input").val().match(reComplexEmail)[1]){stop=true;return false}});$.each(dynamicPersonalGroups,function(x,valuex){if(valuex.email==$(value).find("input").val().match(reComplexEmail)[1]){stop=true;return false}});if(!stop){var exist=0;$.each(dynamicData,function(x,valuex){if(valuex.mail==$(value).find("input").val().match(reComplexEmail)[1]){exist=valuex.id;return false}});if(exist){REST.put("/dynamiccontact/"+exist,{name:$(value).find("input").val().split('"')[1],mail:$(value).find("input").val().match(reComplexEmail)[1]})}else{REST.post("/dynamiccontacts",{name:$(value).find("input").val().split('"')[1],mail:$(value).find("input").val().match(reComplexEmail)[1]})}}})}}function appletReturn(smime,ID,operation,folder){if(!smime){connector=new cConnector();connector.hideProgressBar();return}if(operation=='decript'){var handler=function(data){if(data.msg_day==''){header=expresso_local_messages.get_msg_date(data.original_ID,proxy_mensagens.is_local_folder(get_current_folder()));data.fulldate=header.fulldate;data.smalldate=header.smalldate;data.msg_day=header.msg_day;data.msg_hour=header.msg_hour}this.show_msg(data)}para="&source="+smime+"&ID="+ID+"&folder="+folder;cExecute("$this.imap_functions.show_decript&",handler,para)}else{ID_tmp=ID;var handler_send_smime=function(data){send_message_return(data,this.ID_tmp)};var textArea=document.createElement("TEXTAREA");textArea.style.display='none';textArea.id='smime';textArea.name="smime";textArea.value+=smime;if(is_ie){var i=0;while(document.forms(i).name!="form_message_"+ID){i++}form=document.forms(i)}else form=document.forms["form_message_"+ID];form.appendChild(textArea);cExecuteForm("$this.imap_functions.send_mail",form,handler_send_smime,ID)}}function verifyBodyWords(body,words){for(i=0;i<words.length;i++){if(body.search(words[i])!=-1){return words[i]}}return false}function send_message(ID,folder,folder_name){var content_body=RichTextEditor.getData('body_'+ID);if(language=="pt-br")var words=['anexo','anexos','anexada','anexado','anexei','anexando','anexaste','anexastes','anexamos','anexaram'];else if(language=="es-es")var words=['anexo','adjunto','adjuntos','adjuntado','adjuntamos'];else var words=['attach','attachment','attached','annex','appending'];if($('#fileupload_msg'+ID).find('.att-box').length==0&&preferences.alert_message_attachment=='1'){var bodyWord=verifyBodyWords(content_body,words);if(bodyWord){$.Zebra_Dialog(get_lang('You wrote "%1" in your message, but there are no files attached. Send it anyway?',bodyWord),{'type':'question','overlay_opacity':'0.5','buttons':['OK','Cancelar'],'width':500,'onClose':function(clicked){if(clicked=='OK'){send_valided_message(ID,folder,folder_name);return}else{return}}})}else send_valided_message(ID,folder,folder_name)}else if(!zebraDiscardEventDialog&&$('#fileupload_msg'+ID).find('.att-box-loading').length){zebraDiscardEventDialog=true;window.setTimeout(function(){$.Zebra_Dialog('Existem anexos sendo enviados para o servidor. Caso envie sua mensagem agora estes arquivos serão perdidos.',{'type':'question','overlay_opacity':'0.5','buttons':['Descartar anexos e enviar','Continuar editando e esperar anexos'],'width':500,'onClose':function(clicked){if(clicked=='Descartar anexos e enviar'){$.each($('#fileupload_msg'+ID).find('.att-box'),function(index,value){if($(value).find(".att-box-loading").length)$(value).find('.att-box-delete').trigger("click")});send_valided_message(ID,folder,folder_name)}window.setTimeout(function(){zebraDiscardEventDialog=false},500)}})},300)}else{send_valided_message(ID,folder,folder_name)}}function send_valided_message(ID,folder,folder_name){if(preferences.auto_save_draft==1)autoSaveControl.status[ID]=true;var content=$("#content_id_"+ID);var save_link=$("#content_id_"+ID).find(".save");var onClick=save_link.onclick;save_link.onclick='';save_link.button({disabled:true});var _subject=trim(content.find(".subject").val());if((_subject.length==0)&&!confirm(get_lang("Send this message without a subject?"))){save_link.click(onClick);content.find(".subject").focus();return}var stringReply="";draw_email_box(content.find(".reply-to-tr").find("textarea:first").val(),content.find(".reply-to-tr").find("textarea:first"));content.find(".reply-to-tr").find("textarea:first").val("");var array=content.find(".reply-to-tr").find(".box");$.each(array,function(index,value){stringReply+=$(value).find("input").val()+","});var stringToEmail="";draw_email_box(content.find(".to-tr").find("textarea:first").val()||content.find(".to-tr").find("input:visible").val(),content.find(".to-tr").find("textarea:first"));content.find(".to-tr").find("textarea:first").val("");content.find(".to-tr").find("input:visible").val("");var array=content.find(".to-tr").find(".box");$.each(array,function(index,value){stringToEmail+=$(value).find("input").val()+","});var stringEmail="";stringEmail=stringToEmail;var stringCCoEmail="";if(content.find('[name="input_cco"]').length){if(content.find(".cco-tr").css("display")!="none"){draw_email_box(content.find(".cco-tr").find("textarea:first").val()||content.find(".cco-tr").find("input:visible").val(),content.find(".cco-tr").find("textarea:first"));content.find(".cco-tr").find("textarea:first").val("");content.find(".cco-tr").find("input:visible").val("");var array=content.find(".cco-tr").find(".box");$.each(array,function(index,value){stringCCoEmail+=$(value).find("input").val()+","})}}stringEmail+=stringCCoEmail;var stringCCEmail="";if(content.find(".cc-tr").css("display")!="none"){draw_email_box(content.find(".cc-tr").find("textarea:first").val()||content.find(".cc-tr").find("input:visible").val(),content.find(".cc-tr").find("textarea:first"));content.find(".cc-tr").find("textarea:first").val("");content.find(".cc-tr").find("input:visible").val("");var array=content.find(".cc-tr").find(".box");$.each(array,function(index,value){stringCCEmail+=$(value).find("input").val()+","})}stringEmail+=stringCCEmail;var mailData=new Object();mailData.body=Base64.encode(RichTextEditor.getData('body_'+ID));mailData.folder=folder;mailData.type=RichTextEditor.plain[ID]?'plain':'html';mailData.uids_save=uidsSave[ID].toString();mailData.save_folder=(openTab.imapBox[ID]&&openTab.type[ID]<6)?openTab.imapBox[ID]:"INBOX"+cyrus_delimiter+draftsfolder;mailData.attachments=listAttachment(ID);mailData.messageNum=currentTab;mailData.input_subject=trim(content.find(".subject").val());mailData.input_reply_to=stringReply;mailData.input_to=stringToEmail;mailData.input_cco=stringCCoEmail;mailData.input_cc=stringCCEmail;mailData.input_cc=stringCCEmail;mailData.abaID=$(content).find('[name="abaID"]').val();mailData.input_important_message=$(content).find('input:checkbox:checked[name="input_important_message"]').val();mailData.input_return_receipt=$(content).find('input:checkbox:checked[name="input_return_receipt"]').val();mailData.msg_forward_from=$(content).find('[name="msg_forward_from"]').val();mailData.msg_reply_from=$(content).find('[name="msg_reply_from"]').val();if($(content).find('select[name="input_from"]').val())mailData.input_from=$(content).find('select[name="input_from"]').val();if(stringEmail!=""){$.ajax({url:"controller.php?action=$this.imap_functions.send_mail",data:mailData,type:'POST',success:function(data){send_message_return(connector.unserialize(data),ID)},error:function(){write_msg("Erro ao tentar enviar a mensagem. Nova tentativa em alguns segundos...");var interval=setInterval(function(){send_valided_message(ID,folder,folder_name);clearInterval(interval)},15000);return}})}else{write_msg(get_lang("message without receiver"));return}}function is_valid_email(campo){var invalidEmail=searchEmail(campo);var semicolon=campo.split(";");if((campo.replace(/^\s+|\s+$/g,""))!=""){if(invalidEmail[0]==true){write_msg("Erro de SMTP: Os endereços de destinatário a seguir falharam: "+invalidEmail[1]);return false}else{if(semicolon.length>1){var stringError="Erro de SMTP: Os endereços devem ser separados apenas por vígula: ";for(var i=0;i<semicolon.length;i++){stringError=stringError+semicolon[i];if(i+1<semicolon.length)stringError=stringError+" ; "}write_msg(stringError);return false}else{return true}}}else{write_msg(get_lang("Message without receiver"));return false}}function change_tr_properties(tr_element,newUid,newSubject){message_id=tr_element.id;var td_from=document.getElementById('td_from_'+message_id);if(typeof(newSubject)!='undefined')td_from.nextSibling.innerHTML=newSubject;tr_element.id=newUid;var openNewMessage=function(){$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:newUid,msg_folder:current_folder,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)show_msg(data)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})};for(var i=2;i<10;i++){if(typeof(tr_element.childNodes[i].id)!="undefined")tr_element.childNodes[i].id=tr_element.childNodes[i].id.replace(message_id,newUid);tr_element.childNodes[i].onclick=openNewMessage}}function autoSave(ID){var content=$("#content_id_"+border_id);content.find(".save").button('option','disabled',true);saveButtonDisabled=$("#content_id_"+ID).find(".save").button('option','disabled');if(autoSaveControl.status[ID]===false&&!saveButtonDisabled)save_msg(ID);refresh()}function save_msg(border_id){if(preferences.auto_save_draft==1)autoSaveControl.status[border_id]=true;var content=$("#content_id_"+border_id);content.find(".save").button('option','disabled',true);var array=content.find(".reply-to-tr").find(".box");var stringReplyToEmail="";$.each(array,function(index,value){stringReplyToEmail+=$(value).find("input").val()+","});content.find('[name="input_reply_to"]').val(stringReplyToEmail);var stringEmail="";var array=content.find(".to-tr").find(".box");$.each(array,function(index,value){stringEmail+=$(value).find("input").val()+","});content.find('[name="input_to"]').val(stringEmail);stringEmail="";if(content.find('[name="input_cco"]').length){if(content.find(".cco-tr").css("display")!="none"){var array=content.find(".cco-tr").find(".box");$.each(array,function(index,value){stringEmail+=$(value).find("input").val()+","});content.find('[name="input_cco"]').val(stringEmail)}}stringEmail="";if(content.find(".cc-tr").css("display")!="none"){var array=content.find(".cc-tr").find(".box");$.each(array,function(index,value){stringEmail+=$(value).find("input").val()+","});content.find('[name="input_cc"]').val(stringEmail)}var idJavascript=saveBorderError[border_id];if(saveBorderError[border_id]!==false)DataLayer.put('message',DataLayer.merge(DataLayer.form("#form_message_"+border_id),{id:idJavascript}));else idJavascript=DataLayer.put('message',DataLayer.form("#form_message_"+border_id));uidsSave[border_id]=[];DataLayer.commit(false,false,function(data){if(data!=null&&data['message://'+idJavascript]!==undefined&&data['message://'+idJavascript].id!==undefined){uidsSave[border_id].push(data['message://'+idJavascript].id);saveBorderError[border_id]=false;write_msg('Mensagem salva com sucesso!')}else{saveBorderError[border_id]=idJavascript;write_msg('Erro ao salvar sua mensagem! Nova tentativa em alguns segundos.')}})}function set_messages_flag_search_local(flag){}function set_messages_flag_search(flag){var id_border=currentTab.replace(/[a-zA-Z_]+/,"");var msgs_flag=this.get_selected_messages_search();if(!msgs_flag){write_msg(get_lang('No selected message.'));return}var selected_param="";msgs_to_flag=msgs_flag.split(",");search=true;for(i=0;i<msgs_to_flag.length;i++){var tr=Element(msgs_to_flag[i]+'_s'+id_border);var msg_to_flag=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));selected_param+=','+msg_to_flag+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"")}var handler_set_messages_flag=function(data){var errors=false;var notErrors=false;for(var i=0;i<data.length;i++){var notArray=true;if(data[i].msgs_to_set!=''){var msgs=[];if(data[i].msgs_to_set.indexOf(',')>0){msgs=data[i].msgs_to_set.split(',')notArray=false}else msgs[0]=data[i].msgs_to_set;for(var j=0;j<msgs.length;j++){switch(data[i].flag){case"unseen":set_msg_as_unread(msgs[j]+'_s'+id_border,true);Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked=false;break;case"seen":set_msg_as_read(msgs[j]+'_s'+id_border,true);Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked=false;break;case"flagged":set_msg_as_flagged(msgs[j]+'_s'+id_border,true);document.getElementById("search_"+id_border+"_check_box_message_"+msgs[j]).checked=false;break;case"unflagged":set_msg_as_unflagged(msgs[j]+'_s'+id_border,true);Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked=false;break}notErrors=true}}else{errors=true}}draw_tree_folders();Element('chk_box_select_all_messages_search').checked=false;refresh();if(errors&&notErrors)write_msg(get_lang('Some messages were not marked with success!'));else if(notErrors)write_msg(get_lang('The messages were marked with success!'));else write_msg(get_lang('Error marking messages.'))}cExecute("$this.imap_functions.set_messages_flag_from_search&msg_to_flag="+selected_param+"&flag="+flag,handler_set_messages_flag)}function set_messages_flag(flag,msgs_to_set){if(currentTab!=0&&currentTab.indexOf("search_local")>=0){return set_messages_flag_search_local(flag)}if(currentTab!=0&&currentTab.indexOf("search_")>=0){return set_messages_flag_search(flag)}var handler_set_messages_flag=function(data){if(!verify_session(data))return;var msgs_to_set=data.msgs_to_set.split(",");if(data.disposition_notification_to){$.Zebra_Dialog(data.disposition_notification_to.length==1?get_lang('One of his messages can not be marked as read, because it contains a read confirmation.'):data.disposition_notification_to.length+get_lang(' of its messages could not be marked as read, because it contains a read confirmation.'),{'type':'warning','overlay_opacity':'0.5','buttons':['Fechar']})}if(!data.status){write_msg(data.msg);Element('chk_box_select_all_messages').checked=false;for(var i=0;i<msgs_to_set.length;i++){Element("check_box_message_"+msgs_to_set[i]).checked=false;remove_className(Element(msgs_to_set[i]),'selected_msg')}if(!data.msgs_unflageds)return;else if(data.msgs_not_to_set!="")write_msg(get_lang("Error processing some messages."));msgs_to_set=data.msgs_unflageds.split(",")}for(var i=0;i<msgs_to_set.length;i++){if(preferences.use_cache=='True'){if(current_folder=='')current_folder='INBOX';var setFlag=function(msgObj){switch(data.flag){case"unseen":msgObj.Unseen="U";break;case"seen":msgObj.Unseen="";break;case"flagged":msgObj.Flagged="F";break;case"unflagged":msgObj.Flagged="";break}}}if(Element("check_box_message_"+msgs_to_set[i])){switch(data.flag){case"unseen":set_msg_as_unread(msgs_to_set[i]);if(results_search_messages!="")set_msg_as_unread(results_search_messages,true);Element("check_box_message_"+msgs_to_set[i]).checked=false;break;case"seen":set_msg_as_read(msgs_to_set[i],false);if(results_search_messages!="")set_msg_as_read(results_search_messages,false,true);Element("check_box_message_"+msgs_to_set[i]).checked=false;$.each(fromRules,function(index,value){if(value==folder){cExecute("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_to_set,function(){});return false}});break;case"flagged":set_msg_as_flagged(msgs_to_set[i]);if(results_search_messages!="")set_msg_as_flagged(results_search_messages,true);document.getElementById("check_box_message_"+msgs_to_set[i]).checked=false;break;case"unflagged":set_msg_as_unflagged(msgs_to_set[i]);if(results_search_messages!="")set_msg_as_unflagged(results_search_messages,true);Element("check_box_message_"+msgs_to_set[i]).checked=false;break}}}Element('chk_box_select_all_messages').checked=false}var folder=get_current_folder();if(msgs_to_set=='get_selected_messages')var msgs_to_set=this.get_selected_messages();else folder=Element("input_folder_"+msgs_to_set+"_r").value;if(msgs_to_set)$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.set_messages_flag',folder:folder,msgs_to_set:msgs_to_set,flag:flag,decoded:true}),success:function(data){data=connector.unserialize(data);selectAllFolderMsgs();$('.select-link').unbind('click');if(data)handler_set_messages_flag(data)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}});else write_msg(get_lang('No selected message.'))}function set_message_flag(msg_number,flag,func_after_flag_change){var msg_number_folder=Element("new_input_folder_"+msg_number+"_r");if(!msg_number_folder)var msg_number_folder=Element("input_folder_"+msg_number+"_r");var handler_set_messages_flag=function(data){if(!verify_session(data))return;if(!data.status){write_msg(get_lang("this message cant be marked as normal"));return}else if(func_after_flag_change){func_after_flag_change(true)}if(data.status&&Element("td_message_answered_"+msg_number)){switch(flag){case"unseen":set_msg_as_unread(msg_number);break;case"seen":set_msg_as_read(msg_number);break;case"flagged":set_msg_as_flagged(msg_number);break;case"unflagged":set_msg_as_unflagged(msg_number);break;case"answered":Element("td_message_answered_"+msg_number).innerHTML='<img src=templates/'+template+'/images/answered.png title=Respondida>';break;case"forwarded":Element("td_message_answered_"+msg_number).innerHTML='<img src=templates/'+template+'/images/forwarded.png title=Encaminhada>';break}}else{refresh()}}$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.set_messages_flag',folder:(msg_number_folder?msg_number_folder.value:get_current_folder()),msgs_to_set:msg_number,flag:flag,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)handler_set_messages_flag(data)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}function print_search_msg(){var folder="<h2>&nbsp;Resultado da Pesquisa&nbsp;<font color=\"#505050\" face=\"Verdana\" size=\"1\"></h2>";msgs_number=get_selected_messages_search();var tbody=Element('divScrollMain_'+numBox).firstChild.firstChild.innerHTML;var id_border=currentTab.replace(/[a-zA-Z_]+/,"");if(msgs_number){msgs_number=msgs_number.split(",");var tbody="";for(var i=0;i<msgs_number.length;i++){tbody+="<tr id=\""+msgs_number[i]+"_s"+id_border+"\" class=\"tr_msg_unread tr_msg_read2\">"+Element(msgs_number[i]+'_s'+id_border).innerHTML+"</tr>"}}else{msgs_number=get_all_messages_search();msgs_number=msgs_number.split(",");var tbody="";for(var i=0;i<msgs_number.length;i++){tbody+="<tr id=\""+msgs_number[i]+"_s"+id_border+"\" class=\"tr_msg_unread tr_msg_read2\">"+Element(msgs_number[i]+'_s'+id_border).innerHTML+"</tr>"}}var print_width=screen.width-200;var x=((screen.width-print_width)/2);var y=((screen.height-400)/2)-35;var window_print=window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);seekDot=(is_ie?/width=24/gi:/width="24"/gi);var thead="<tr class=\"message_header\">    <td width=\"3%\"></td><td width=\"2%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"2%\"></td><td id=\"message_header_FOLDER_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">Pasta</td><td id=\"message_header_SORTFROM_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">De</td><td id=\"message_header_SORTSUBJECT_0\" class=\"th_resizable\" align=\"left\" width=\"*\">Assunto</td><td id=\"message_header_SORTARRIVAL_0\" class=\"th_resizable\" align=\"center\" width=\"11%\"><b>Data</b><img src=\"templates/default/images/arrow_descendant.gif\"></td><td id=\"message_header_SORTSIZE_0\" class=\"th_resizable\" align=\"left\" width=\"11%\">Tamanho</td></tr>";tbody=tbody.replace(seekDot,"style='display:none'");seekDot=(is_ie?/width=16/gi:/width="16"/gi);tbody=tbody.replace(seekDot,"style='display:none'");seekDot=(is_ie?/width=12/gi:/width="12"/gi);tbody=tbody.replace(seekDot,"style='display:none'");while(1){try{window_print.document.open();var html='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>'+'<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>'+cabecalho+'</h4><hr>'+'<h2>'+folder+'</h2><hr/><blockquote><font size="2">'+'<table width="100%" cellpadding="0" cellspacing="0">'+'<thead>'+thead+'</thead><tbody>'+tbody+'</tbody>'+'</table></font></blockquote></body></html>';window_print.document.write(html);window_print.document.close();break}catch(e){}}window_print.document.close();window_print.print()}function print_messages_bodies(){var messages={};messages[get_current_folder()]=get_selected_messages().split(',');var print_bodies=function(data){var print_width=screen.width-200;var x=((screen.width-print_width)/2);var y=((screen.height-400)/2)-35;var window_print=window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);if(window_print==null){alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname));return}var header='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>'+'<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>';window_print.document.write(header);var printData='<body style="overflow:auto">'+cabecalho+'</h4><hr>';window_print.document.write(printData);var newRow=function(label,data){return"<tr><td width=7%><font size='2'><b>"+label+" </b></font></td><td><font size='2'>"+data+"</font></td></tr>"}$.each(data,function(index,message){var html="<table><tbody>";if(message.sender)for(var i=0;i<message.sender.length;i++){html+=newRow(get_lang('Sent by')+":",message.sender[i])}if(message.from)for(var i=0;i<message.from.length;i++){html+=newRow(get_lang('From')+":",message.from[i])}if(message.toaddress2){html+=newRow(get_lang('To')+":",message.toaddress2)}if(message.cc){html+=newRow(get_lang('Cc')+":",message.cc)}if(message.bcc){html+=newRow(get_lang('Cco')+":",message.bcc)}if(message.smalldate)html+=newRow(get_lang('Date')+":",message.smalldate);else if(message.udate){var norm=function(arg){return(arg<10?'0'+arg:arg)};var weekDays=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];var today=new Date();today.setHours(23);today.setMinutes(59);today.setSeconds(59);today.setMilliseconds(999);udate_local=message.udate*1000+today.getTimezoneOffset()*60*1000;date_msg=new Date(udate_local);if(preferences.show_date_numerical==0||typeof(preferences.show_date_numerical)=='undefined'){if(today.getTime()-date_msg.getTime()<86400000)html+=newRow(get_lang('Date')+":",norm(date_msg.getHours())+':'+norm(date_msg.getMinutes()));else if(today.getTime()-date_msg.getTime()<172800000)newRow(get_lang('Date')+":",get_lang('Yesterday'));else if(today.getTime()-date_msg.getTime()<259200000)html+=newRow(get_lang('Date')+":",get_lang(weekDays[date_msg.getDay()]));else html+=newRow(get_lang('Date')+":",norm(date_msg.getDate())+'/'+norm(date_msg.getMonth()+1)+'/'+date_msg.getFullYear())}else html+=newRow(get_lang('Date')+":",norm(date_msg.getDate())+'/'+norm(date_msg.getMonth()+1)+'/'+date_msg.getFullYear())}html+=newRow(get_lang('Subject')+":",message.subject);if(message.attachments&&message.attachments.length){var img='<img style="margin-bottom : -5px; cursor : pointer;" src="templates/'+template+'/images/new.png">';var atts="";$.each(message.attachments,function(index,attach){atts+=" | "+attach.name+"("+formatBytes(attach.fsize)+") "+img+" | "});html+=newRow(get_lang('Attachments: '),atts)}else if(message.attachment&&message.attachment.number_attachments>0){var img='<img style="margin-bottom : -5px; cursor : pointer;" src="templates/'+template+'/images/new.png">';var atts="";$.each(message.attachment.names.split(','),function(index,attach){atts+=" | "+attach+img+" |"});html+=newRow(get_lang('Attachments: '),atts)}html+='</tbody></table>';if(message.body){html+="<hr>"+message.body}else if(message._return){html+="<hr>"+message._return}html+="<hr>";window_print.document.write(html)});window_print.document.close();window_print.print()}if(proxy_mensagens.is_local_folder(get_current_folder())){var msgs=Array();var _msg={};$.each(get_selected_messages().split(','),function(index,value){_msg.header=expresso_mail_archive.getMessageHeaders(value);_msg.body=expresso_mail_archive.getMessageBodies([value]);msgs.push($.extend({},_msg.header,_msg.body[0]))});print_bodies(msgs)}else{$.ajax({url:"controller.php?"+$.param({action:"$this.imap_functions.getMessages",details:"all",messages:messages,}),success:function(data){data=connector.unserialize(data);if(data){print_bodies(data[get_current_folder()])}},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}}function newTbody(messages){var tbody=$("<tbody>");$.each(messages,function(index,msg){var newTr=make_tr_message(msg,get_current_folder());if(msg.attachments&&msg.attachments.length){$(newTr).find('td').eq(1).html("<img src ='templates/"+template+"/images/clip.gif'>")}tbody.append(newTr)});return tbody.html()}function print_messages_list(){var print_list=function(tbody,folder){var print_width=screen.width-200;var x=((screen.width-print_width)/2);var y=((screen.height-400)/2)-35;var window_print=window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);seekDot=(is_ie?/width=24/gi:/width="24"/gi);var thead="<tr class=\"message_header\"> <td width=\"3%\"></td><td width=\"2%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"2%\"></td><td width=\"2%\"></td><td width=\"2%\"></td><td id=\"message_header_SORTFROM_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">De</td><td id=\"message_header_SORTSUBJECT_0\" class=\"th_resizable\" align=\"left\" width=\"*\">Assunto</td><td id=\"message_header_SORTARRIVAL_0\" class=\"th_resizable\" align=\"center\" width=\"11%\"><b>Data</b><img src=\"templates/default/images/arrow_descendant.gif\"></td><td id=\"message_header_SORTSIZE_0\" class=\"th_resizable\" align=\"left\" width=\"11%\">Tamanho</td></tr>";tbody=tbody.replace(seekDot,"style='display:none'");seekDot=(is_ie?/width=16/gi:/width="16"/gi);tbody=tbody.replace(seekDot,"style='display:none'");seekDot=(is_ie?/width=12/gi:/width="12"/gi);tbody=tbody.replace(seekDot,"style='display:none'");while(1){try{window_print.document.open();var html='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>'+'<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>'+cabecalho+'</h4><hr>'+'<h2>'+$('#border_id_0').html()+'</h2><hr/><blockquote><font size="2">'+'<table width="100%" cellpadding="0" cellspacing="0">'+'<thead>'+thead+'</thead><tbody>'+tbody+'</tbody>'+'</table></font></blockquote></body></html>';window_print.document.write(html);window_print.document.close();break}catch(e){}}window_print.document.close();window_print.print()}msgs_number=get_selected_messages();if(msgs_number==false){var tbody=Element('divScrollMain_0').firstChild.firstChild.innerHTML;print_list(tbody)}else{var messages={};messages[get_current_folder()]=msgs_number.split(',');if(proxy_mensagens.is_local_folder(get_current_folder())){var msgs=Array();$.each(msgs_number.split(','),function(index,value){msgs.push(expresso_mail_archive.getMessageHeaders(value))});print_list(newTbody(msgs))}else{$.ajax({url:"controller.php?"+$.param({action:"$this.imap_functions.getMessages",details:"all",messages:messages,}),success:function(data){data=connector.unserialize(data);if(data){data=data[get_current_folder()];print_list(newTbody(data))}},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}}}function print_all(){if(typeof(currentTab)=="string"&&currentTab.indexOf("local")!=-1){alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais.");return true}if(openTab.type[currentTab]==2)return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab);if(currentTab!=0&&currentTab.indexOf("search_")>=0){return print_search_msg()}if(get_selected_messages()==false){return print_messages_list()}var msg='Algumas mensagens foram selecionadas para impressão. Deseja imprimir o conteúdo de cada uma delas? Caso contrário, apenas uma lista das mensagens selecionadas será impressa.';$.Zebra_Dialog(msg,{'type':'question','buttons':['Sim','Não'],'overlay_opacity':'0.5','onClose':function(caption){if(caption=='Sim'){return print_messages_bodies()}else{return print_messages_list()}}})}function print_msg(msg_folder,msg_number,border_ID){var div_toaddress_full=Element("div_toaddress_full_"+border_ID);var div_ccaddress_full=Element("div_ccaddress_full_"+border_ID);var div_ccoaddress_full=Element("div_ccoaddress_full_"+border_ID);var printListTO=(div_toaddress_full&&div_toaddress_full.style.display!='none')||toaddress_array[border_ID].length==1?true:false;var printListCC=(div_ccaddress_full&&div_ccaddress_full.style.display!='none')||!div_ccaddress_full?true:false;var printListCCO=(div_ccoaddress_full&&div_ccoaddress_full.style.display!='none')||!div_ccoaddress_full?true:false;var sender=Element('sender_values_'+border_ID)?Element('sender_values_'+border_ID).value:null;var from=Element('from_values_'+border_ID)?Element('from_values_'+border_ID).value:null;var to=Element('to_values_'+border_ID)?Element('to_values_'+border_ID).value:null;var cco=Element('cco_values_'+border_ID)?Element('cco_values_'+border_ID).value:null;var cc=Element('cc_values_'+border_ID)?Element('cc_values_'+border_ID).value:null;var date=Element('date_'+border_ID);var subject=Element('subject_'+border_ID);var attachments=Element('attachments_'+border_ID);var body=Element('body_'+border_ID);var att='';var countAtt=0;if(attachments!==null){countAtt=attachments.getElementsByTagName('a').length;if(countAtt===1)att=attachments.getElementsByTagName('a')[0].innerHTML;else if(countAtt>1)for(var i=1;i<attachments.getElementsByTagName('a').length;i++)att+=" | "+attachments.getElementsByTagName('a')[i].innerHTML}var body=Element('body_'+border_ID);var print_width=screen.width-200;var x=((screen.width-print_width)/2);var y=((screen.height-400)/2)-35;var window_print=window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);if(window_print==null){alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname));return}if(attachments!=null){var a=attachments.childNodes;var attachs="";var show_attachs="";var ii=a.length>2?2:1;for(i=ii;i<a.length;i++){if(a[i].tagName&&a[i].tagName=="A"){attachs+=a[i].innerHTML}}show_attachs="<tr><td width=7%><font size='2'>"+get_lang('Attachments: ')+" </font></td><td><font size='2'>"+attachs+"</font></td></tr>"}else{show_attachs=""}var current_path=window.location.href.substr(0,window.location.href.lastIndexOf("/"));var head='<head><title></title><link href="'+current_path+'/templates/default/main.css" type="text/css" rel="stylesheet"></head>';window_print.document.write(head);while(1){try{var html='<body style="overflow:auto">';html+=cabecalho+'</h4><hr>';html+='<table><tbody>';if(sender)html+="<tr><td width=7% noWrap><font size='2'>"+get_lang('Sent by')+": </font></td><td><font size='2'>"+sender+"</font></td></tr>";if(from)html+="<tr><td width=7%><font size='2'>"+get_lang('From')+": </font></td><td><font size='2'>"+from+"</font></td></tr>";if(to){if(!printListTO)to='Os destinatários não estão sendo exibidos para esta impressão';html+="<tr><td width=7%><font size='2'>"+get_lang('To')+": </font></td><td><font size='2'>"+to+"</font></td></tr>"}if(cc){if(!printListCC)cc='Os destinatários não estão sendo exibidos para esta impressão';html+="<tr><td width=7%><font size='2'>"+get_lang('Cc')+": </font></td><td><font size='2'>"+cc+"</font></td></tr>"}if(cco){if(!printListCCO)cco='Os destinatários não estão sendo exibidos para esta impressão';html+="<tr><td width=7%><font size='2'>"+get_lang('Cco')+": </font></td><td><font size='2'>"+cco+"</font></td></tr>"}if(date)html+="<tr><td width=7%><font size='2'>"+get_lang('Date')+": </font></td><td><font size='2'>"+date.innerHTML+"</font></td></tr>";html+="<tr><td width=7%><font size='2'>"+get_lang('Subject')+": </font></td><td><font size='2'>"+subject.innerHTML+"</font></td></tr>";if(countAtt>0){html+="<tr><td width=7%><font size='2'>"+get_lang('Attachments: ')+"</font></td><td><font size='2'>"+att+"</font></td></tr>"}html+="</tbody></table><hr>";window_print.document.write(html+body.innerHTML);var tab_tags=window_print.document.getElementsByTagName("IMG");var link=location.href.replace(/\/expressoMail1_2\/(.*)/,"");for(var i=0;i<tab_tags.length;i++){var _img=tab_tags[i].cloneNode(true);if(tab_tags[i].src.toUpperCase().indexOf('INC/GET_ARCHIVE.PHP?MSGFOLDER=')>-1)_img.src=link+'/expressoMail1_2/'+tab_tags[i].src.substr(tab_tags[i].src.toUpperCase().indexOf('INC/GET_ARCHIVE.PHP?MSGFOLDER='));tab_tags[i].parentNode.replaceChild(_img,tab_tags[i])}break}catch(e){}}window_print.document.close();window_print.print()}function empty_trash_imap(shared,button,type){if(shared){var folder_part=$(button).parents("li:first").attr("id").split(cyrus_delimiter);var folder=folder_part[0]+cyrus_delimiter+folder_part[1]}var handler_empty_trash=function(data){Element('chk_box_select_all_messages').checked=false;if(!verify_session(data))return;update_quota(get_current_folder());draw_new_tree_folder();draw_tree_labels();if(data){if(typeof(data)=="object"){if(data[1]=="Permission denied"){cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);return write_msg(get_lang("Permission denied"))}}write_msg(get_lang('Your Trash folder was empty.'));if(get_current_folder()==mount_url_folder(["INBOX",special_folders["Trash"]])){draw_paging(0);remove_rows(document.getElementById("table_box"));Element('tot_m').innerHTML=0;Element('new_m').innerHTML=0}}else write_msg(get_lang('ERROR emptying your Trash folder.'))}$.Zebra_Dialog(get_lang('Do you really want to empty your trash folder?'),{'type':'question','title':get_lang('Empty Trash'),'buttons':[get_lang("Yes"),get_lang("No")],'overlay_opacity':0.5,'onClose':function(caption){if(caption==get_lang("Yes")){if(type.id=="local_messages_trash"){expresso_mail_archive.deleteAllMessages(type.id);cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu)}else{cExecute("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultTrashFolder"+(shared?"&shared="+folder:""),handler_empty_trash)}}}})}function empty_spam_imap(shared,button,type){if(shared){var folder_part=$(button).parents("li:first").attr("id").split(cyrus_delimiter);var folder=folder_part[0]+cyrus_delimiter+folder_part[1]}var handler_empty_spam=function(data){Element('chk_box_select_all_messages').checked=false;if(!verify_session(data))return;if(get_current_folder()==mount_url_folder(["INBOX",special_folders["Spam"]])){draw_paging(0);remove_rows(document.getElementById("table_box"))}draw_new_tree_folder();draw_tree_labels();update_quota(get_current_folder());if(data){if(typeof(data)=="object"){if(data[1]=="Permission denied"){cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);return write_msg(get_lang("Permission denied"))}else{write_msg(get_lang('Your Spam folder was empty.'))}}else{write_msg(get_lang('Your Spam folder was empty.'))}}else write_msg(get_lang('ERROR emptying your Spam folder.'))}$.Zebra_Dialog(get_lang('Do you really want to empty your spam folder?'),{'type':'question','title':get_lang('Empty Spam'),'buttons':[get_lang("Yes"),get_lang("No")],'overlay_opacity':0.5,'onClose':function(caption){if(caption==get_lang("Yes")){if(type.id=="local_messages_spam"){expresso_mail_archive.deleteAllMessages(type.id);cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu)}else{cExecute("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultSpamFolder"+(shared?"&shared="+folder:""),handler_empty_spam)}}}})}function buildExportArchiver(msgsArchive,name_box){var hand_export=function(data){if(!data){write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.'))}else if(data["empty_folder"]||data=="empty_folder"){write_msg(get_lang("The selected folder is empty."))}else download_attachments(null,null,data,null,null,get_current_folder().split("_")[2]+'.zip')}var array=new Array();for(var i=0;i<msgsArchive.length;i++){eachMsg={'ContentType':msgsArchive[i].ContentType,'from':{'email':msgsArchive[i].from.email,'full':msgsArchive[i].from.full,'name':msgsArchive[i].from.name},'msg_sample':msgsArchive[i].msg_sample,'subject':msgsArchive[i].subject,'to':{'email':msgsArchive[i].to.email,'full':msgsArchive[i].to.full,'name':msgsArchive[i].to.name},'toaddress2':msgsArchive[i].toaddress2,'msg_number':msgsArchive[i].msg_number,'date':new Date(msgsArchive[i].timestamp).toString()};array.push(eachMsg)}$.ajax({type:"POST",url:"controller.php?action=$this.exporteml.export_all_byLocalFolder",data:{folder:name_box,type:"msg_local",messages:array}}).done(function(msg){hand_export(msg.split('"')[1])})}function export_all_selected_msgs(){if(get_current_folder().split("_")[0]=="local"){if(get_selected_messages().indexOf(",")!=-1){expresso_mail_archive.getSomeMsgs(get_selected_messages().split(","))}else{expresso_mail_archive.getSomeMsgs([get_selected_messages()])}buildExportArchiver(expresso_mail_archive.getSomeMsg,get_current_folder().split("_")[2])}else{if(openTab.type[currentTab]>1){source_msg(currentTab,openTab.imapBox[currentTab]);return}var search=false;if(currentTab!=0&&currentTab.indexOf("search_")>=0){var id_border=currentTab.replace(/[a-zA-Z_]+/,"");var msgs_to_export=this.get_selected_messages_search();if(!msgs_to_export){write_msg(get_lang('No selected message.'));return}var selected_param="";msgs_to_export=msgs_to_export.split(",");search=true;for(i=0;i<msgs_to_export.length;i++){var tr=Element(msgs_to_export[i]+'_s'+id_border);msg_to_move=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));selected_param+=','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"")}}else{var msgs_to_export=this.get_selected_messages()}var handler_export_all_selected_msgs=function(data){if(!data){write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.'))}else{var filename='mensagens.zip';if(data[0].match(/\.eml$/gi)){filename=data[1]+'.eml'}download_attachments(null,null,data[0],null,null,filename)}}if(search){cExecute("$this.exporteml.makeAll",handler_export_all_selected_msgs,"folder=false&msgs_to_export="+selected_param)}else if(msgs_to_export){cExecute("$this.exporteml.makeAll",handler_export_all_selected_msgs,"folder="+get_current_folder()+"&msgs_to_export="+msgs_to_export);write_msg(get_lang('You must wait while the messages will be exported...'))}else write_msg(get_lang('No selected message.'))}}function select_all_search_messages(select,aba){if(select){jQuery("#"+aba+" tr").each(function(i,o){o.firstChild.firstChild.checked=true;add_className(o,'selected_msg')})}else{jQuery("#"+aba+" tr").each(function(i,o){o.firstChild.firstChild.checked=false;remove_className(o,'selected_msg')})}}function verify_session(data){if(data&&data.imap_error){if(data.imap_error=="nosession")write_msg(get_lang("your session could not be verified."));else write_msg(data.imap_error);return false}else return true}function save_image(e,thumb,file_type){file_type=file_type.replace("/",".");thumb.oncontextmenu=function(e){return false}var _button=is_ie?window.event.button:e.which;var _target=is_ie?event.srcElement:e.target;if(_button==2||_button==3){var _params=_target.id.split(";;");download_attachments(Base64.encode(_params[0]),_params[1],_params[2],_params[3],_params[4],file_type);if($(_target).parent().attr("href").split("http").length>1){var part_find=thumb.toString().split("#");var part2_find=part_find[1].split("/temp");var part_id_dwl=part2_find[0]+'/temp/download'+part2_find[1];download_local_attachment(part_id_dwl);return}else{var _params=_target.id.split(";;");download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type)}}}function save_image2(info){var obj=jQuery.parseJSON(unescape(info));download_attachments(obj.folder,obj.message,obj.thumbIndex,obj.pid,obj.encoding,obj.type.replace("/","."))}function nospam(msgs_number,border_ID,folder){if(folder=='null')folder=get_current_folder();var new_folder='';if(folder.substr(0,4)=='user'){arrayFolder=folder.split(cyrus_delimiter);new_folder='user'+cyrus_delimiter+arrayFolder[1]}else{new_folder='INBOX'}var new_folder_name=get_lang('INBOX');var handler_move_msgs=function(data){if(msgs_number=='selected')set_messages_flag("unseen","get_selected_messages");else proxy_mensagens.proxy_set_message_flag(msgs_number,"unseen");proxy_mensagens.proxy_move_messages(folder,msgs_number,border_ID,new_folder,new_folder_name);if(openTab.type[currentTab]>1)delete_border(currentTab,'false')}if(currentTab.toString().indexOf("_r")!=-1)msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));else if(msgs_number=='selected')msgs_number=get_selected_messages();if(currentTab==0)msgs_number=get_selected_messages();if(typeof currentTab=="string"&&currentTab.indexOf("search_")!="-1"){msgs_number="";var checked=$("#divScrollMain_"+currentTab.substr(currentTab.indexOf('_')+1,255)).find("tr input:checked");$.each(checked,function(index,value){if(value){if(index==0)msgs_number=$(value).parents("tr").attr("id");else msgs_number+=","+$(value).parents("tr").attr("id")}})}if(parseInt(msgs_number)>0||msgs_number.length>0)cExecute("$this.imap_functions.spam&folder="+folder+"&spam=false"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+0+"&cyrus_delimiter="+cyrus_delimiter,handler_move_msgs);else write_msg(get_lang('No selected message.'))}function spam(folder,msgs_number,border_ID){if(folder=='null')folder=get_current_folder();var new_folder='';if(folder.substr(0,4)=='user'){arrayFolder=folder.split(cyrus_delimiter);new_folder='user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Spam']}else{new_folder=mount_url_folder(["INBOX",special_folders["Spam"]])}var new_folder_name='Spam';var not_opem_previus=true;var handler_move_msgs=function(data){proxy_mensagens.proxy_move_messages(folder,msgs_number,border_ID,new_folder,new_folder_name,not_opem_previus);if(openTab.type[currentTab]>1){if(preferences.delete_and_show_previous_message==1)delete_border(currentTab,'false')}}if(currentTab.toString().indexOf("_r")!=-1)msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));else if(currentTab!=0&&currentTab.indexOf("search_")>=0){var content_search=document.getElementById('content_id_'+currentTab);mount_url_folder(["INBOX",special_folders['Trash']]),'Trash',move_search_msgs('content_id_'+currentTab,mount_url_folder(["INBOX",special_folders["Spam"]]),special_folders['Spam']);refresh();return}else if(msgs_number=='selected')msgs_number=get_selected_messages();if(currentTab==0)msgs_number=get_selected_messages();if(parseInt(msgs_number)>0||msgs_number.length>0)cExecute("$this.imap_functions.spam&folder="+folder+"&spam=true"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+0+"&cyrus_delimiter="+cyrus_delimiter,handler_move_msgs);else write_msg(get_lang('No selected message.'))}function import_window(){if(typeof(currentTab)=="string"&&currentTab.indexOf("local")!=-1){alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais.");return true}var folder={};var importEmails=$("#importEmails");importEmails.html(DataLayer.render(BASE_PATH+"modules/mail/templates/importEmails.ejs",{}));importEmails.dialog({height:280,width:500,resizable:false,title:get_lang('zip mails to import'),modal:true,buttons:[{text:get_lang("Close"),click:function(){importEmails.dialog("close").dialog("destroy")}},{text:get_lang("Import"),click:function(){var input_file=importEmails.find("input[type=file]");var input_hidden=importEmails.find("input[name=folder]");if(input_file.attr("value")==""){$.Zebra_Dialog(get_lang("You must choose a file")+" !",{'type':'warning','overlay_opacity':'0.5','onClose':function(){$("#importMessageAccordion").accordion('activate',0)}})}else{if(input_hidden.attr("value")=="")$.Zebra_Dialog(get_lang("You must choose a folder")+" !",{'type':'warning','overlay_opacity':'0.5','onClose':function(){$("#importMessageAccordion").accordion('activate',1)}});else{var handler_return=function(data){write_msg(get_lang('The import was executed successfully.'));return_import_msgs(data,folder)}var formSend=document.getElementById("importFileMessages");importEmails.dialog("destroy");write_msg(get_lang('You must wait while the messages will be imported...'));cExecuteForm('$this.imap_functions.import_msgs',formSend,handler_return)}}}}],open:function(event,ui){if(typeof(shortcut)!='undefined')shortcut.disabled=true},close:function(event,ui){if(typeof(shortcut)!='undefined')shortcut.disabled=false}});importEmails.css("overflow","hidden");importEmails.find("input[type=file]").change(function(){var deniedExtension=true;var fileExtension=["eml","zip"];var fileName=importEmails.find("input[type=file]").attr('value');fileName=fileName.split(".");if(fileName[1]){for(var i in fileExtension){if(fileExtension[i].toUpperCase()===fileName[1].toUpperCase()){deniedExtension=false;break}}}if(deniedExtension){$.Zebra_Dialog(get_lang('File extension forbidden or invalid file'),{'type':'warning','overlay_opacity':'0.5'})}$("#lblFileName").html((!deniedExtension)?importEmails.find("input[type=file]").attr('value'):"")});$("#importMessageAccordion").accordion();var foldersTree=jQuery("#foldertree-container-importMessage").removeClass('empty-container').html(DataLayer.render(BASE_PATH+'api/templates/foldertree.ejs',{folders:[cp_tree1,cp_tree2,[]]})).find("#foldertree").treeview().click(function(event){var target=$(event.target);if(target.is('.collapsable-hitarea, .expandable-hitarea, .lastCollapsable, .lastExpandable, .treeview'))return;if(!target.attr('id'))target=target.parent();if(target.attr('id')=="foldertree")return;folder.id=target.attr('id');folder.child=target.find('.folder');folder.caption=target.find('span').attr('title');$('#foldertree-container-importMessage .filetree span.folder.selected').removeClass('selected');if(!target.is('#foldertree > .expandable, #foldertree > .collapsable'))$(target).children('.folder').addClass('selected');selectedFolder={id:folder.id,name:folder.child.attr('title'),'class':folder.child.attr('class')};importEmails.find("input[name=folder]").attr("value",folder.id)});$("#lblFileName").prev().css("margin-left","10px");$("#lblFileName").prev().css("font-weight","bold")}function return_import_msgs(data,folder){if(data&&data.error){write_msg(data.error)}else{if(data=='Post-Content-Length')write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',preferences.max_attachment_size?preferences.max_attachment_size:Element('upload_max_filesize').value));else{var er=/^local_/;if(er.test(folder.id)){alert("Mensagens não podem ser importadas em pastas locais")}else{if(openTab.imapBox[0]==folder.id){openTab.imapBox[0]='';change_folder(folder.id,folder.caption)}refresh()}}}}function decodeCreateSchedulable(type,ID){var startEvent=new Date();if(startEvent.toString('mm')<30)startEvent.add({minutes:(30-parseInt(startEvent.toString('mm')))});else startEvent.add({hours:1,minutes:'-'+startEvent.toString('mm')});var endEvent=function(date){if(!!User.preferences.defaultCalendar){return new Date(parseInt(date.getTime())+(!!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration?(Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration*60000):(User.preferences.defaultDuration*60000)))}else return new Date(parseInt(date.getTime())+(User.preferences.defaultDuration*60000))};var emails=$("#to_values_"+ID).val().split(',');var schedulable={};schedulable={acl:{inviteGuests:true,organization:true,participationRequired:false,read:true,write:true},alarms:[],allDay:false,attachments:[],isAttendee:true,attendee:'',category:'','class':'1',delegatedFrom:{},endDate:startEvent.toString(User.preferences.dateFormat),startDate:endEvent(startEvent).toString(User.preferences.dateFormat),startHour:startEvent.toString(User.preferences.hourFormat),endHour:endEvent(startEvent).toString(User.preferences.hourFormat),timezone:User.preferences.defaultCalendar?Calendar.signatureOf[User.preferences.defaultCalendar].calendar.timezone:User.preferences.timezone,summary:$("#subject_"+ID).text(),description:$("#body_"+ID).text(),startTime:startEvent.getTime(),endTime:endEvent(startEvent),timezones:Timezone.timezones,me:{name:User.me.name,mail:User.me.mail,acl:'rowi',status:'1',delegatedFrom:'0',id:User.me.id},organizer:{name:User.me.name,mail:User.me.mail,acl:'rowi',status:'1',delegatedFrom:'0',id:User.me.id},statusParticipants:{accepted:0,cancelled:0,tentative:0,unanswered:emails.length},location:'',attendee:$.map(emails,function(mail){var contact=false;var decoded=Encoder.htmlDecode(mail);var newAttendeeName="";var name=decoded.match(/"([^"]*)"/)?decoded.match(/"([^"]*)"/)[1]:'';var mail=decoded.match(/<([^<]*)>[\s]*$/)?decoded.match(/<([^<]*)>[\s]*$/)[1].toLowerCase():decoded;var user=DataLayer.get('user',["=","mail",mail],true);if($.type(user)=="array")user=user[0];if(user!=''){if(User.me.mail==user.mail)return(null);user.isExternal=(!!user&&!(!!user.isExternal))?0:1;return DataLayer.merge({name:user.name,mail:user.mail,acl:'r',delegatedFrom:'0',status:'4',isExternal:user.isExternal},!!user.id?{id:DataLayer.put('participant',{user:user.id,isExternal:user.isExternal})}:{id:DataLayer.put('participant',{user:user})})}else if(mail.match(/[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])/)){var userId=DataLayer.put('user',{name:name,mail:mail,isExternal:'1'});var newAttendeeId=DataLayer.put('participant',{user:userId,isExternal:'1'});return{id:newAttendeeId,name:name,mail:mail,acl:'r',delegatedFrom:'0',status:'4',isExternal:'1'}}else return(null)})};schedulable=DataLayer.merge(schedulable,type=='event'?{calendar:User.preferences.defaultCalendar?User.preferences.defaultCalendar:Calendar.calendars[0],calendars:Calendar.calendars}:{group:Calendar.groups[0].id,groups:Calendar.groups,percentage:0,isOrganizer:true});return schedulable}function import_implements_calendar(){if(typeof(Encoder)=="undefined"){$.ajax({url:"../prototype/modules/calendar/js/load.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/modules/calendar/js/map.disponibility.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/modules/calendar/js/helpers.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/modules/calendar/js/task.helpers.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/plugins/encoder/encoder.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/plugins/jquery.spinner/jquery.spinner.min.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/plugins/fullcalendar/fullcalendar.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});DataLayer.dispatchPath="../prototype/"}}function select_import_folder(){var imgExtensions=new Array("eml","zip");var inputFile=document.form_import.file_1;if(!inputFile.value){alert(get_lang('File extension forbidden or invalid file')+'.');return false}var fileExtension=inputFile.value.split(".");fileExtension=fileExtension[(fileExtension.length-1)];var deniedExtension=true;for(var i=0;i<imgExtensions.length;i++){if(imgExtensions[i].toUpperCase()==fileExtension.toUpperCase()){deniedExtension=false;break}}if(deniedExtension){alert(get_lang('File extension forbidden or invalid file')+'.');return false}arrayJSWin['import_window'].close();connector.loadScript('wfolders');if(typeof(wfolders)=="undefined")setTimeout('select_import_folder()',500);else wfolders.makeWindow('null','import')}function decodeOwner(){owner=User.me.id;var imapBox=openTab.imapBox[currentTab].split(cyrus_delimiter);if(imapBox.length>1){var user=DataLayer.get('user',{filter:['=','uid',imapBox[1]]});owner=$.isArray(user)?user[0].id:user.id}return owner}function import_calendar(data){var import_url='$this.db_functions.import_vcard&msg_folder='+data;var logUser;var up;var owner;function handler_import_calendar(data){if(data===true){write_msg(get_lang("The event was imported successfully."))}else if(data['url']){var form=document.createElement("form");form.setAttribute("action",DEFAULT_URL+data['url']+'&isPost=true');form.setAttribute("method","POST");document.body.appendChild(form);form.submit()}else write_msg(get_lang(data))}if(defaultCalendar=="expressoCalendar"&&$("#expressoCalendarid")[0]){import_implements_calendar();$("#import-dialog").dialog({autoOpen:false,height:220,modal:true,resizable:false,open:function(event,ui){if(typeof(shortcut)!='undefined')shortcut.disabled=true},close:function(event,ui){event.stopPropagation();if(typeof(shortcut)!='undefined')shortcut.disabled=false},closeOnEscape:true});$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(),async:false,success:function(data){data=connector.unserialize(data);var createDialog=function(typeImport,propaget){if(typeof(typeImport)=="object"){var calendarIds=!!typeImport.calendar?typeImport.calendar:Calendar[typeImport.type];typeImport=typeImport.action}switch(parseInt(typeImport)){case 1:case 7:case 10:$("#select-agenda").html('');var options='';if(calendarIds){for(var i=0;i<calendarIds.length;i++)options+='<option value="'+calendarIds[i]+'">'+Calendar.signatureOf[calendarIds[i]].calendar.name+'</option>'}$("#select-agenda").append(options);$("#select-agenda").css("display","block");$("#import-dialog").dialog({buttons:{Cancel:function(){$(this).dialog("close")},"Importar":function(){$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner()+'&cirus_delimiter='+cyrus_delimiter,success:function(msg){var alt=((msg=connector.unserialize(msg))=="ok")?"Importado com sucesso para ":"Ocorreu um erro ao importar o evento/tarefa para a agenda ";alert(alt+$("#select-agenda option:selected").text())}});$(this).dialog("close")}}});if(typeImport==7){$("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change');$("#import-dialog").find('#select-status').attr('disabled','disabled')}break;case 3:$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&selected=true',success:function(msg){alert(((connector.unserialize(msg))=="ok")?"Seu evento/tarefa foi removido ":"Ocorreu um erro ao remover o evento/tarefa")}});return;break;case 5:$.ajax({url:'controller.php?action='+import_url+'&from_ajax=true&selected=true&cirus_delimiter='+cyrus_delimiter,success:function(msg){alert(((connector.unserialize(msg))=="ok")?"Seu evento/tarefa foi Atualizado com sucesso":"Ocorreu um erro ao atualizar evento/tarefa")}});return;break;case 6:var acceptedSuggestion=confirm("Deseja atualizar o evento/tarefa de acordo com a sugestão ?");$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value+'&uidAccount='+decodeOwner(),success:function(msg){if(acceptedSuggestion)alert(((connector.unserialize(msg))=="ok")?"Evento/tarefa atualizado com sucesso ":"Ocorreu um erro ao atualizar o evento")}});return;break;case 9:alert('Seu evento/tarefa não possui alterações!');return;break;case 11:alert('Este evento/tarefa já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!');return;break;default:up=true;$("#select-agenda").css("display","none");$("#import-dialog").children("p:first-child").css("display","none");$("#import-dialog").dialog({height:160,title:'Atualizar Evento/Tarefa',buttons:{Cancel:function(){$(this).dialog("close")},"Atualizar":function(){$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&cirus_delimiter='+cyrus_delimiter+'&selected='+(parseInt(typeImport)==2||parseInt(typeImport)==4?'true':$("#select-agenda option:selected").val())+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(),success:function(msg){alert(((msg=connector.unserialize(msg))=="ok")?"Atualizado com sucesso":"Ocorreu um erro ao atualizar o evento")}});$(this).dialog("close")}},close:function(event,ui){if(typeof(shortcut)!='undefined')shortcut.disabled=false},open:function(event,ui){if(typeof(shortcut)!='undefined')shortcut.disabled=true}});$(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar")}$("#import-dialog").dialog("open")};createDialog(data,true)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}else{if(confirm(get_lang("Do you confirm this import to your Calendar?"))){cExecute(import_url+"&from_ajax=true",handler_import_calendar)}}}function open_msg_part(data){var handler_open_msg_part=function(data){if(data.append==1){proxy_mensagens.get_msg(data.msg_number,data.msg_folder,false,show_msg);partMsgs.push(data.msg_number)}else write_msg(data.append)}cExecute('$this.imap_functions.ope_msg_part&msg_folder='+data+'&save_folder=INBOX'+cyrus_delimiter+special_folders['Trash'],handler_open_msg_part)}function hack_sent_queue(data,rowid_message){if(data.success!=true){queue_send_errors=true;expresso_local_messages.set_problem_on_sent(rowid_message,data)}else{expresso_local_messages.set_as_sent(rowid_message);if(document.getElementById('_action')){el=document.getElementById('_action');father=el.parentNode;father.removeChild(el)}send_mail_from_queue(false)}}function send_mail_from_queue(first_pass){if(first_pass)modal('send_queue');var num_msgs=expresso_local_messages.get_num_msgs_to_send();if(num_msgs<=0){close_lightbox();return}document.getElementById('text_send_queue').innerHTML=get_lang('Number of messages to send:')+' '+num_msgs;var handler_send_queue_message=function(data,rowid_message){hack_sent_queue(data,this.ID_tmp)}var msg_to_send=expresso_local_messages.get_form_msg_to_send();if(!is_ie)ID_tmp=msg_to_send.rowid.value;else{for(var i=0;i<msg_to_send.length;i++){if(msg_to_send.elements[i].name=='rowid'){ID_tmp=msg_to_send.elements[i].value;break}}}expresso_local_messages.set_as_sent(ID_tmp);cExecuteForm("$this.imap_functions.send_mail",msg_to_send,handler_send_queue_message,"queue_"+ID_tmp);send_mail_from_queue(false)}function check_mail_in_queue(){var num_msgs=expresso_local_messages.get_num_msgs_to_send();if(num_msgs>0){control=confirm(get_lang('You have messages to send. Want you to send them now?'));if(control){send_mail_from_queue(true)}return true}else{return false}}function force_check_queue(){if(!check_mail_in_queue()){write_msg(get_lang("No messages to send"))}}function create_new_local_folder(parentFolderId,name){parentFolderId=parentFolderId.split("_");var parentName=parentFolderId[2];expresso_mail_archive.createFolder(parentName,name)}function create_new_folder(name_folder,base_path){if(preferences.imap_max_folders){if(cp_tree1.length==parseInt(preferences.imap_max_folders)){$(".folders-loading").removeClass("folders-loading");cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);return write_msg(get_lang("Limit reached folders"))}}$.ajax({url:"controller.php?action=$this.imap_functions.create_mailbox",type:"POST",async:false,data:"newp="+name_folder+"&base_path="+base_path,success:function(data){data=connector.unserialize(data);if(data=="Mailbox already exists"){write_msg(get_lang("Mailbox already exists"))}else if(data.substring(data.indexOf("Permission"),data.length)=="Permission denied"){$(".folders-loading").removeClass("folders-loading");cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);return write_msg(get_lang("Permission denied"))}cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu)},beforeSend:function(jqXHR,settings){connector.showProgressBar()},complete:function(jqXHR,settings){connector.hideProgressBar()}})}function searchEmail(emailString){var arrayInvalidEmails=new Array();arrayInvalidEmails[1]='';var email;var arrayEmailsFull=new Array();arrayEmailsFull=emailString.split(',');var er_Email=new RegExp("<(.*?)>");var er_ValidaEmail=new RegExp("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$");for(i=0;i<arrayEmailsFull.length;i++){email=er_Email.exec(arrayEmailsFull[i]);tempEmail=email==null?arrayEmailsFull[i]:email[1];tempEmail=tempEmail.replace(/^\s+|\s+$/g,"");if(tempEmail!=''){singleEmail=er_ValidaEmail.exec(tempEmail);if(singleEmail==null){arrayInvalidEmails[0]=true;arrayInvalidEmails[1]+=(email==null?arrayEmailsFull[i]:email[1])+""}}}return arrayInvalidEmails}function reports_window(currentTab){ID_msg=currentTab.substr(0,currentTab.indexOf("_"));report_wind.make_report_window(ID_msg)}DataLayer.codec("message","detail",{decoder:function(form){var border_id=form.abaID;var user_selected=$('#content_id_'+border_id).find('.from-select option:selected').text();var str_begin_name=user_selected.indexOf('<')+1;var str_end_name=user_selected.indexOf('@');var user_selected_name=user_selected.substring(str_begin_name,str_end_name);if(user_selected.length>0)var user_selected_email=user_selected.match(/<([^<]*)>[\s]*$/)[1];else var user_selected_email=User.me.mail;if(user_selected_email==User.me.mail){var prefix='INBOX'}else{var prefix='user'+cyrus_delimiter+user_selected_name;DataLayer.remove('folder',false);DataLayer.get('folder');var has_folder=DataLayer.get('folder',prefix+cyrus_delimiter+draftsfolder);if(!has_folder){create_new_folder(draftsfolder,prefix)}}var folder_id=(openTab.imapBox[border_id]&&openTab.type[border_id]<6)?openTab.imapBox[border_id]:prefix+cyrus_delimiter+draftsfolder;form.folder=folder_id;form.body=RichTextEditor.getData("body_"+border_id);form.type=RichTextEditor.plain[border_id]?'plain':'html';form.attachments=listAttachment(border_id);form.uidsSave=uidsSave[border_id].toString();return(form)},encoder:function(pref){return(pref)}});DataLayer.codec("mailAttachment","detail",{decoder:function(evtObj){if(notArray=$.type(evtObj)!=="array")evtObj=[evtObj];var res=$.map(evtObj,function(form){return[$.map(form.files,function(files){return{source:files,disposition:form['attDisposition'+form.abaID]}})]});return notArray?res[0]:res},encoder:function(){}});function formatBytes(bytes){if(bytes>=1000000000){return(bytes/1000000000).toFixed(2)+' GB'}if(bytes>=1000000){return(bytes/1000000).toFixed(2)+' MB'}if(bytes>=1000){return(bytes/1000).toFixed(2)+' KB'}return bytes+' B'};function truncate(text,size){var result=text;if(text.length>size){result=text.substring(0,size)+'...'}return result}function break_comma(originalText){var quotesMarks=false;var completeString="";var brokenEmails=new Array();originalText+=",";for(i=0;i<originalText.length;i++){var character=originalText.substr(i,1);if(character=="\""){quotesMarks=!quotesMarks}if(!quotesMarks){if(character==","){brokenEmails.push(completeString);completeString=""}else completeString+=character}else completeString+=character}return brokenEmails}DataLayer.links('message');DataLayer.poll('message',30);function services_retry(){try{connector.purgeCache();if((expresso_mail_archive.enabled==null)&&(expresso_mail_archive.timer==null)&&(expresso_mail_archive.counter>0)){connector.hideProgressBar();write_msg(get_lang('Sorry, but you need to reload this web page. Click at reload page at web browsing top navigation.'));return}if(arguments.length==0){write_msg(get_lang('Trying to communicate with Mail Archiver...'))}connector.showProgressBar();var head=document.getElementById('send_queue');var script_xdr=document.createElement('script');var script_xdr_tag_id='mail_archiver_retry_xdr';var script_request=document.createElement('script');var script_request_tag_id='mail_archiver_retry_request';var script_cors=document.createElement('script');var script_cors_tag_id='mail_archiver_retry_cors';var script_utils=document.createElement('script');var script_utils_tag_id='mail_archiver_retry_utils';if(document.getElementById(script_xdr_tag_id)){document.getElementById(script_xdr_tag_id).parentNode.removeChild(document.getElementById(script_xdr_tag_id))}if(document.getElementById(script_request_tag_id)){document.getElementById(script_request_tag_id).parentNode.removeChild(document.getElementById(script_request_tag_id))}if(document.getElementById(script_cors_tag_id)){document.getElementById(script_cors_tag_id).parentNode.removeChild(document.getElementById(script_cors_tag_id))}if(document.getElementById(script_utils_tag_id)){document.getElementById(script_utils_tag_id).parentNode.removeChild(document.getElementById(script_utils_tag_id))}script_xdr.type='text/javascript';script_xdr.src=mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/arcservutil/cxf-addon-xdr-adapter.js';script_xdr.id=script_xdr_tag_id;head.appendChild(script_xdr);script_request.type='text/javascript';script_request.src=mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/arcservutil/cxf-addon-cors-request-object.js';script_request.id=script_request_tag_id;head.appendChild(script_request);script_cors.type='text/javascript';script_cors.src=mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/arcservutil/cxf-addon-cors-utils.js';script_cors.id=script_cors_tag_id;head.appendChild(script_cors);script_utils.type='text/javascript';script_utils.src=mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/arcserv/ArchiveServices?js&nojsutils';script_utils.id=script_utils_tag_id;head.appendChild(script_utils);ttintval=window.setTimeout('check_services_restart()',1000)}catch(e){write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));connector.hideProgressBar();check_services_tryouts=1}}function check_services_restart(){try{write_msg(get_lang('Wait: attempt %1 from %2...',check_services_tryouts,check_services_tryouts_limit));if(check_services_tryouts<=5){try{ArchiveServices=new web_service_mailarchiver_serpro__ArchiveServices();ArchiveServices.url=mail_archive_protocol+"://"+mail_archive_host+":"+mail_archive_port+"/arcserv/ArchiveServices";window.clearInterval(ttintval);expresso_mail_archive.Restart(expresso_mail_archive)}catch(e){check_services_tryouts++;window.clearInterval(ttintval);ttintval=window.setTimeout('services_retry(true)',1)}}else{write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));connector.hideProgressBar();check_services_tryouts=1}}catch(e){write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));connector.hideProgressBar();check_services_tryouts=1}}
+
+var time_refresh=300000;var check_services_interval=2000;var check_services_tryouts=1;var check_services_tryouts_limit=5;var autosave_time=40000;var results_search_messages="";var cabecalho='<h4>ExpressoLivre - ExpressoMail</h4>';var auxNotificationCriteriaVetor=[];var auxNotification;var countNewMessage=0;var notifyNewMessageFilter=[];var dynamicPersonalContacts=new Array();var dynamicPersonalGroups=new Array();var dynamicContacts=new Array();var topContact=0;DataLayer.get("folder",true);if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'');}}
+function mount_url_folder(folders){return folders.join(cyrus_delimiter);}
+function updateDynamicContact(userContacts){if(!userContacts)
+userContacts=REST.get("/usercontacts",false);if(userContacts.collection&&!userContacts.collection.error){dynamicData=normalizeContacts(userContacts.collection.itens);}else{dynamicData=[];}
+if(dynamicData){var dynamicContactsList=[];$.each(dynamicData,function(index,dynamic){var dataType=userContacts.collection.itens[index].dataType;dynamic['value']=(dynamic.name?dynamic.name+' - ':'')+dynamic.mail;dynamic['type']=dataType
+dynamic['typel']=(dataType.substring(0,7)=="/shared"?"/"+dataType.substring(7,dataType.length)+"s":dataType);topContact=dynamic.number_of_messages>topContact?dynamic.number_of_messages:topContact;dynamicContactsList.push(dynamic);});}
+dynamicData=dynamicContactsList;}
+function updateDynamicPersonalContacts(){dynamicPersonalContacts=new Array();var personalContacts=REST.get("/personalContact");if(personalContacts.collection&&!personalContacts.collection.error){var contactsData=normalizeContacts(personalContacts.collection.itens);if(contactsData){$.each(contactsData,function(index,value){var contact={id:parseInt(value.id),name:value.name,email:value.email,value:value.name+" - "+value.email,type:"P"};dynamicPersonalContacts.push(contact);});}}}
+function updateDynamicPersonalGroups(){dynamicPersonalGroups=new Array();var groups=REST.get("/groups");if(groups.collection&&!groups.collection.error){var contactsData=normalizeContacts(groups.collection.itens);if(contactsData.collecion&&!contactsData.collecion.error){$.each(contactsData,function(index,value){var contact={id:parseInt(value.id),owner:value.owner,name:value.name,email:value.email,type:"G"};dynamicPersonalGroups.push(contact);});}}}
+function init(){if(!is_ie)
+Element('tableDivAppbox').width='100%';var save_gmtoffset=function(data){gmtoffset=data;}
+var save_preferences=function(data){preferences=data;if(preferences.show_name_print_messages=="1"){var getUserName=document.getElementById("user_info");var userName=getUserName.innerHTML;var position=userName.indexOf("-");var userName=userName.substring(3,position);cabecalho='<h4>'+userName;}
+current_folder="INBOX";if(ArchiveServices)
+expresso_mail_archive.Startup();else{if(preferences.use_local_messages=="1")
+write_msg(get_lang('Sorry, but Mail Archiver does not seems to be running or installed at this workstation. By now, we are turning off local messages!'));}
+cExecute("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1",handler_draw_box);$.ajax({async:false,url:"controller.php?"+$.param({action:"$this.imap_functions.getMessagesIds",folder:get_current_folder(),msg_range_begin:"0",msg_range_end:"0",sort_box_type:"SORTARRIVAL",search_box_type:search_box_type,sort_box_reverse:"1"}),success:function(data){data=connector.unserialize(data);if(data){var _data={};$.each(data,function(index,value){if(data[index]){_data[data[index]]=data[index];}});populateSelectedMsgs(_data);}},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});if(preferences.hide_folders=="1")
+Element('divAppboxHeader').innerHTML=title_app_menu;if(preferences.delete_trash_messages_after_n_days!=0)
+cExecute("$this.imap_functions.automatic_trash_cleanness&before_date="+preferences.delete_trash_messages_after_n_days+"&cyrus_delimiter="+cyrus_delimiter,handler_automatic_trash_cleanness);if(preferences.use_signature_digital_cripto=='1'){loadApplet();}
+DataLayer.get("folder",true);cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);if($.cookie('collapse_folders')=="true"){if(!is_ie)
+$("#folderscol").addClass("hidden");else
+$("#folderscol").hide();$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-e").children().attr('title',"Expandir");refresh();resizeWindow();}
+else{$(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-w").children().attr('title',"Ocultar");refresh();resizeWindow();}
+$(".collapse_folders_td").attr('title',"Ocultar/Expandir").click(function(){if($("#folderscol").css("display")!="none"){if(!is_ie)
+$("#folderscol").addClass("hidden");else
+$("#folderscol").hide();$(".collapse_folders").removeClass("ui-icon-triangle-1-w");$(".collapse_folders").addClass("ui-icon-triangle-1-e");$(".collapse_folders").parent().attr('title',"Expandir");$.cookie('collapse_folders',"true");refresh();resizeWindow();}else{if(!is_ie)
+$("#folderscol").removeClass("hidden");else
+$("#folderscol").show();$(".collapse_folders").removeClass("ui-icon-triangle-1-e");$(".collapse_folders").addClass("ui-icon-triangle-1-w");$(".collapse_folders").parent().attr('title',"Ocultar");$.cookie('collapse_folders',"false");refresh();resizeWindow();}
+resizeWindow();}).hover(function(){$(this).addClass("collapse_folders_td_over");},function(){$(this).removeClass("collapse_folders_td_over");});if(parseInt(preferences.use_dynamic_contacts)){var load_dynamics=function(){updateDynamicContact();updateDynamicPersonalContacts();updateDynamicPersonalGroups();};load_dynamics();}}
+var handler_automatic_trash_cleanness=function(data){if(data!=false){write_msg(data.length+' '+Element('txt_clear_trash').value);}}
+Element('divAppboxHeader').innerHTML=title_app;cyrus_delimiter=Element('cyrus_delimiter').value;cExecute("$this.functions.get_preferences",save_preferences);cExecute("phpgwapi.browser.isMobile",function(data){mobile_device=((data.constructor==Boolean)?data:(data==='true'));});DataLayer.get("folder",true);cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);setTimeout('auto_refresh()',time_refresh);$("#divAppbox").css("padding-left","0px");}
+function init_offline(){current_folder='local_Inbox';if(account_id!=null){if(!is_ie)
+Element('tableDivAppbox').width='100%';else
+connector.createXMLHTTP();Element('divStatusBar').innerHTML='<table height="16px" border=0 width=100% cellspacing=0 cellpadding=2>'+'<tr>'+'<td style="padding-left:17px" width=33% id="content_quota" align=left></td>'+'<td width=33% height=16px align=center nowrap><font face=Verdana, Arial, Helvetica, sans-serif color=#000066 size=2>'+'<b>ExpressoMail Offline</b><font size=1><b> - Versão 1.0</b></font></td>'+'<td width=33% id="div_menu_c3" align=right></td>'+'</tr></table>';draw_tree_folders();proxy_mensagens.messages_list('local_Inbox',1,preferences.max_email_per_page,'SORTARRIVAL',null,1,1,1,function handler(data){draw_box(data,'local_Inbox');})
+cyrus_delimiter=Element('cyrus_delimiter').value;}}
+function loadApplet(){var search_div=Element('search_div');var applet=null;if(navigator.userAgent.match('MSIE')){applet=document.createElement('<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" '+'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"></object>');var parameters={type:'application/x-java-applet;version=1.5',code:'ExpressoSmimeApplet',codebase:'/security/',mayscript:'true',token:token_param,locale:locale,archive:'ExpressoCertMail.jar,'+'ExpressoCert.jar,'+'bcmail-jdk15-142.jar,'+'mail.jar,'+'activation.jar,'+'bcprov-jdk15-142.jar,'+'commons-codec-1.3.jar,'+'commons-httpclient-3.1.jar,'+'commons-logging-1.1.1.jar'}
+if(parameters!='undefined'&&parameters!=null){for(var parameter in parameters){var param=document.createElement("PARAM");param.setAttribute("name",parameter);param.setAttribute("value",parameters[parameter]);applet.appendChild(param);}}}
+else
+{applet=document.createElement('embed');applet.innerHTML='<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" code="ExpressoSmimeApplet.class" '+'codebase="/security/" locale="'+locale+'"'+'archive="ExpressoCertMail.jar,ExpressoCert.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar,commons-codec-1.3.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar" '+'token="'+token_param+'" '+'type="application/x-java-applet;version=1.5" mayscript > '+'<noembed> '+'No Java Support. '+'</noembed> '+'</embed> ';}
+if(applet!=null)
+{applet.style.top="-100px";applet.style.left="-100px";window.document.body.insertBefore(applet,document.body.lastChild);}}
+function disable_field(field,condition){var comando="if ("+condition+") { document.getElementById('"+field.id+"').disabled=true;} else { document.getElementById('"+field.id+"').disabled=false; }";eval(comando);}
+function remove_all_attachments(folder,msg_num){var call_back=function(data){if(!data.status){alert(data.msg);}
+else{msg_to_delete=Element(msg_num);change_tr_properties(msg_to_delete,data.msg_no);msg_to_delete.childNodes[1].innerHTML="";write_msg(get_lang("Attachments removed"));folderName=Base64.encode(folder);folderName=folderName.replace(/=/gi,'');delete_border(msg_num+'_r_'+folderName,'false');}};if(confirm(get_lang("delete all attachments confirmation")))
+cExecute("$this.imap_functions.remove_attachments&folder="
++folder+"&msg_num="+msg_num,call_back);}
+function watch_changes_in_msg(border_id)
+{if(document.getElementById('border_id_'+border_id))
+{function keypress_handler()
+{away=false;var save_link=content.find(".save");save_link.onclick=function onclick(event){openTab.toPreserve[border_id]=true;save_msg(border_id);};save_link.button({disabled:false});$(".header-button").button();};var content=$("#content_id_"+border_id);var subject_obj=content.find(".subject");if(subject_obj.addEventListener)
+subject_obj.addEventListener('keypress',keypress_handler,false);else if(subject_obj.attachEvent)
+subject_obj.attachEvent('onkeypress',keypress_handler);var to_obj=content.find('[name="input_to"]');if(to_obj.addEventListener)
+to_obj.addEventListener('keypress',keypress_handler,false);else if(to_obj.attachEvent)
+to_obj.attachEvent('onkeypress',keypress_handler);var cc_obj=content.find('[name="input_cc"]');if(cc_obj.addEventListener)
+cc_obj.addEventListener('keypress',keypress_handler,false);else if(cc_obj.attachEvent)
+cc_obj.attachEvent('onkeypress',keypress_handler);if(content.find('[name="input_cco"]').length){var cco_obj=content.find('[name="input_cco"]');if(cco_obj.addEventListener)
+cco_obj.addEventListener('keypress',keypress_handler,false);else if(cco_obj.attachEvent)
+cco_obj.attachEvent('onkeypress',keypress_handler);}
+var txtarea_obj=Element('body_'+border_id);if(txtarea_obj){if((preferences.plain_text_editor==1)||(Element('body_')+border_id).checked){if(txtarea_obj.addEventListener)
+txtarea_obj.addEventListener('keypress',keypress_handler,false);else if(txtarea_obj.attachEvent)
+txtarea_obj.attachEvent('onkeypress',keypress_handler);}}}}
+function show_msg_img(msg_number,folder){var call_back=function(data){data.showImg=true;if(!Element(data.msg_number)){trElement=document.createElement('DIV');trElement.id=data.msg_number;Element("tbody_box").appendChild(trElement);}
+show_msg(data);}
+proxy_mensagens.msg_img(msg_number,folder,call_back);}
+function show_msg(msg_info){if(!verify_session(msg_info))
+return;if(typeof(msg_info)!='object')
+alert(get_lang("Error in show_msg param is not object"));if(msg_info.status_get_msg_info=='false')
+{write_msg(get_lang("Problems reading your message")+".");return;}
+var handler_sendNotification=function(data){if(data)
+write_msg(get_lang("A read confirmation was sent."));else
+write_msg(get_lang("Error in SMTP sending read confirmation."));}
+if(msg_info.source)
+{if(!Element('cert_applet')){write_msg(get_lang('The preference "%1" isn\'t enabled.',get_lang('Enable digitally sign/cipher the message?')));}else{Element('cert_applet').doButtonClickAction('decript',msg_info.msg_number,msg_info.source,msg_info.msg_folder);}
+return;}
+if(msg_info.status_get_msg_info=='false')
+{write_msg(get_lang("Problems reading your message")+".");return;}
+if(msg_info.status=='false'){eval(msg_info.command_to_exec);}
+else{var ID=msg_info.original_ID?msg_info.original_ID:msg_info.msg_number;var folderName=msg_info.msg_folder;folderName=Base64.encode(folderName);folderName=folderName.replace(/=/gi,'');var id_msg_read=ID+"_r_"+folderName;if(Element("border_id_"+id_msg_read)&&currentTab>0)
+id_msg_read+="n";if(preferences.use_shortcuts=='1')
+select_msg(ID,'null');var isPartMsg=false;for(var ii=0;ii<partMsgs.length;ii++)
+if(partMsgs[ii]==ID)isPartMsg=true;if(msg_info.alarm==false){if((openTab.type[currentTab]==2||openTab.type[currentTab]==3)&&isPartMsg===false){delete_border(currentTab,'false');}}
+if(Element("border_id_"+id_msg_read)){alternate_border(id_msg_read);resizeWindow();}
+else{var border_id=create_border(msg_info.subject,id_msg_read);if(border_id)
+{openTab.type[border_id]=2;openTab.imapBox[border_id]=msg_info.msg_folder;draw_message(msg_info,border_id);var unseen_sort=document.getElementById('span_flag_UNSEEN').getAttribute('onclick');unseen_sort=unseen_sort.toString();if(!(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'")<0))
+{var sort_type=sort_box_type;sort_box_type=null;sort_box('UNSEEN',sort_type,false);delete selectedPagingMsgs[msg_info.msg_number];totalFolderMsgs--;}}
+else
+return;}
+var domains="";if((msg_info.DispositionNotificationTo)&&(!msg_is_read(ID)||(msg_info.Recent=='N')))
+{if(preferences.notification_domains!=undefined&&preferences.notification_domains!="")
+{domains=preferences.notification_domains.split(',');}
+else
+{var confNotification=true;}
+for(var i=0;i<domains.length;i++)
+if(Base64.decode(msg_info.DispositionNotificationTo).match("@"+domains[i]))
+{var confNotification=true;break;}
+if(confNotification==undefined)
+var confNotification=confirm(get_lang("The sender:\n%1\nwaits your notification of reading. Do you want to confirm this?",Base64.decode(msg_info.DispositionNotificationTo)),"");if(confNotification){if(preferences.confirm_read_message){$.Zebra_Dialog(get_lang("Would you like to send the read receipt?"),{'type':'question','title':get_lang('Read receipt'),'buttons':[get_lang("Yes"),get_lang("No")],'overlay_opacity':0.5,'onClose':function(caption){if(caption==get_lang("Yes"))
+cExecute("$this.imap_functions.send_notification&notificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject),handler_sendNotification);else
+write_msg(get_lang("Confirmation message is not sent"));}});}
+else
+cExecute("$this.imap_functions.send_notification&notificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject),handler_sendNotification);}}
+if(!msg_is_read(ID))
+{if(proxy_mensagens.is_local_folder(get_current_folder())){expresso_mail_archive.drawdata=null
+var tl=expresso_mail_archive.pattern.tagConfig('unseen',ID,1);expresso_mail_archive.taglist=tl;expresso_mail_archive.progressbar=window.setTimeout("expresso_mail_archive.tagMessage()",1);}
+set_msg_as_read(ID,true);if(msg_info.cacheHit||(!proxy_mensagens.is_local_folder(get_current_folder())&&msg_info.original_ID))
+{set_message_flag(ID,"seen");}}}
+setTimeout('resizeWindow()',300);}
+function auto_refresh(){refresh(preferences.alert_new_msg,preferences.notifications);setTimeout('auto_refresh()',time_refresh);}
+function auto_archiving(){expresso_mail_sync.start_sync();setTimeout('auto_archiving()',600000);}
+function notificationFilter(data,notifyCriteria){if(parseInt(notifyCriteria)&&data.length>0&&!activePage){var howManyCriteria=$('div.gray.filtersDeadline .message-list li').length;var differenceOfNewCriteria=data.length-howManyCriteria;if(differenceOfNewCriteria>0){for(var i=data.length-differenceOfNewCriteria;i<data.length;i++){desktopNotification.sentNotification("",get_lang("Filter criteria"),truncate(new Date(data[i].udate).toString('dd/MM HH:mm')+' - '+data[i].from+' - '+data[i].subject,75));desktopNotification.showNotification(false,function(){window.focus();this.cancel();});}}}}
+function refresh(alert_new_msg,notifyPermission){getFromAlertRules();var handler_refresh=function(data){handlerMessageFilter=function(data){notificationFilter(data,notifyPermission);alarmFollowupflagged('filtersAlarms',data);}
+cExecute("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules,handlerMessageFilter);if(data['msg_range_end'])
+if(data['msg_range_end']>0)
+current_page=data['msg_range_end']/preferences.max_email_per_page;if(!verify_session(data))
+return;var total_messages_element=Element('tot_m');var box=Element("tbody_box");if(box.childNodes.length==0)
+showEmptyBoxMsg(box);if(data.length>0||countNewMessage>0){for(var i=0;i<data.length;i++){if(!onceOpenedHeadersMessages[current_folder])
+onceOpenedHeadersMessages[current_folder]={};onceOpenedHeadersMessages[current_folder][data[i].msg_number]=data[i];}
+Element("table_message_header_box_0").emptyBody=false;table_element=Element("table_box");var msg_info=document.getElementById('msg_info');if(msg_info!=null)
+{var msg_tr=msg_info.parentNode.parentNode;msg_tr.removeChild(msg_info.parentNode);if(!Element("colgroup_main_"+numBox)){var colgr_element=buildColGroup();colgr_element.setAttribute("id","colgroup_main_"+numBox);table_element.appendChild(colgr_element);}}
+var box=Element("tbody_box");if(!$("#colgroup_main_0").size()){$(table_element).append(Element("colgroup_main_"+numBox));}
+if(data.msgs_to_delete.length>0){for(var i=0;i<data.msgs_to_delete.length;i++){if((data.msgs_to_delete[i]!=undefined)&&(data.msgs_to_delete[i]!="")){removeAll(data.msgs_to_delete[i]);}}}
+if(data[0].msg_folder!=current_folder)
+return false;totalFolderMsgs+=data.new_msgs;for(var i=0;i<data.length;i++){var existent=document.getElementById(data[i].msg_number);if(!existent)
+{selectedPagingMsgs[data[i].msg_number]=false;totalFolderMsgs++;updateSelectedMsgs(false,data[i].msg_number);var new_msg=this.make_tr_message(data[i],current_folder,data.offsetToGMT);$(new_msg).draggable({start:function(){if($(".shared-folders").length){$(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({over:function(a,b){over=$(this);$(this).addClass("folder-over");if(($(this)[0]!=$(this).parent().find(".head_folder")[0]))
+if($(this).prev()[0])
+if($(this).parent().find(".expandable-hitarea")[0]==$(this).prev()[0]){setTimeout(function(){if(over.hasClass("folder-over"))
+over.prev().trigger("click");},500);}},out:function(){$(this).removeClass("folder-over");},drop:function(event,ui){$(this).css("border","");if($(this).parent().attr('id')==undefined){var folder_to='INBOX';var to_folder_title=get_lang("Inbox");}else{var folder_to=$(this).parent().attr('id');var to_folder_title=$(this).attr('title');}
+var folder_to_move=ui.draggable.parent().attr('id');var border_id=ui.draggable.find("input[type=hidden]").attr("name");if(folder_to_move=="tbody_box"){move_msgs2(get_current_folder(),'selected',0,folder_to,to_folder_title,true);return refresh();}}});}},stop:function(){$(".shared-folders").parent().find(".folder").droppable("destroy");},helper:function(event){$(this).addClass("selected_msg").find("input:checkbox").attr("checked",true);updateSelectedMsgs($(this).find("input:checkbox").is(':checked'),$(this).attr("id"));if($("#tbody_box .selected_shortcut_msg").length>1){$("#tbody_box .selected_shortcut_msg").addClass("selected_msg").find('.checkbox').attr('checked',true);$.each($(".selected_shortcut_msg"),function(index,value){updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id"));});}
+if(totalSelected()>1)
+return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:(totalSelected()+" mensagens selecionadas"),type:"messages"})+"</td></tr>");if($(this).find(".td_msg_subject").text().length>18)
+return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:$(this).find(".td_msg_subject").text().substring(0,18)+"...",type:"messages"})+"</td></tr>");else
+return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs',{texto:$(this).find(".td_msg_subject").text(),type:"messages"})+"</td></tr>");},iframeFix:true,delay:150,cursorAt:{top:5,left:56},refreshPositions:true,containment:"#divAppbox"}).bind("contextmenu",function(){if(!(($(event.target).find('img').length>0)&&($(event.target).hasClass('td-label')))){if($(this).find("input:checkbox").attr("checked")!="checked"){$(this).find("input:checkbox").trigger('click');$(this).addClass("selected_msg");}
+updateSelectedMsgs($(this).find("input:checkbox").is(':checked'),$(this).attr("id"));}});if(data[i].next_msg_number!=undefined&&data[i].next_msg_number!=null){try{box.insertBefore(new_msg,box.childNodes[data[i].msg_key_position]);}
+catch(e){box.insertBefore(new_msg,box.firstChild);}}
+else if(data[i].Recent=='N'){box.insertBefore(new_msg,box.firstChild);}
+else{box.appendChild(new_msg);}}}
+if(parseInt(preferences.use_shortcuts))
+select_msg("null","reload_msg","null");if(parseInt(alert_new_msg)&&data.new_msgs>0&&activePage)
+alert(data['new_msgs']>1?get_lang("You have %1 new messages",data['new_msgs'])+"!":get_lang("You have 1 new message")+"!");if(parseInt(notifyPermission)&&(data.new_msgs>0||!!countNewMessage)&&!activePage){countNewMessage+=data.length;desktopNotificationAux=desktopNotification.sentNotification("",get_lang("Notification"),countNewMessage>1?get_lang("You have %1 new messages",countNewMessage)+"!":get_lang("You have 1 new message")+"!");if(auxNotification!=='undefined')
+desktopNotification.cancelByReference(auxNotification);desktopNotification.showNotification(function(){countNewMessage=0;},function(){window.focus();this.cancel();countNewMessage=0;});auxNotification=desktopNotificationAux;}
+build_quota(data['quota']);}
+if(data.new_msgs){total_messages_element.innerHTML=parseInt(total_messages_element.innerHTML)+data.new_msgs;}else if(data.tot_msgs){total_messages_element.innerHTML=data.tot_msgs>=0?data.tot_msgs:0;}
+var box=Element("tbody_box");if(box.childNodes.length>1){updateBoxBgColor(box.childNodes);}
+connector.purgeCache();cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);resizeMailList();}
+msg_range_end=(current_page*preferences.max_email_per_page);msg_range_begin=(msg_range_end-(preferences.max_email_per_page)+1);main=Element("tbody_box");if(!main)
+return;main_list=main.childNodes;var tmp='';var string_msgs_in_main='';var len=main_list.length;for(var j=0;j<len;j++)
+tmp+=main_list[j].id+',';string_msgs_in_main=tmp.substring(0,(tmp.length-1));if(!expresso_offline)
+$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.refresh',folder:current_folder,msgs_existent:string_msgs_in_main,msg_range_begin:msg_range_begin,msg_range_end:msg_range_end,sort_box_type:sort_box_type,search_box_type:search_box_type,sort_box_reverse:sort_box_reverse}),success:function(data){data=connector.unserialize(data);if(data)
+handler_refresh(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});var msgs=$("#tbody_box tr");if(!msgs.hasClass("current_selected_shortcut_msg selected_shortcut_msg"))
+{msgs.first().focus().addClass("current_selected_shortcut_msg selected_shortcut_msg");}}
+function delete_msgs(folder,msgs_number,border_ID,show_success_msg,archive){if(preferences.use_local_messages==1&&expresso_local_messages.isArchiving(msgs_number,folder)){alert("Impossivel deletar mensagens que estão ainda estão sendo arquivadas.");return;}
+var userTrashFolder='';if(arguments.length<4)show_success_msg=true;if(folder=='null')folder=current_folder;if(folder.substr(0,4)=='user')
+{var arrayFolder=folder.split(cyrus_delimiter);userTrashFolder='user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Trash'];DataLayer.remove('folder',false);DataLayer.get('folder');var has_folder=DataLayer.get('folder',userTrashFolder);if(!has_folder){create_new_folder(special_folders['Trash'],'user'+cyrus_delimiter+arrayFolder[1]);}}
+else userTrashFolder=mount_url_folder(["INBOX",special_folders["Trash"]]);if(openTab.type[currentTab]==1)
+return move_search_msgs('content_id_'+currentTab,userTrashFolder,special_folders['Trash']);if(currentTab.toString().indexOf("_r")!=-1)
+msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));if(!archive&&(parseInt(preferences.save_deleted_msg))&&(folder!=userTrashFolder)){move_msgs2(folder,""+msgs_number,border_ID,userTrashFolder,special_folders['Trash'],show_success_msg);return;}
+var handler_delete_msgs=function(data){Element('chk_box_select_all_messages').checked=false;if(currentTab)
+mail_msg=Element("tbody_box_"+currentTab);else
+mail_msg=Element("tbody_box");if(preferences.use_shortcuts=='1'){if(mail_msg&&exist_className(mail_msg.childNodes[mail_msg.childNodes.length-1],'selected_shortcut_msg')){select_msg('null','up',true);}
+else{if(!select_msg('null','down',true)){select_msg('null','up',true);}}}
+if(data.status==false){write_msg(get_lang("You don't have permission for this operation in this shared folder!"));return false;}
+if(preferences.use_local_messages==1){if(!expresso_mail_archive.isArchiveOperation){if(show_success_msg){if(data.msgs_number.length==1)
+write_msg(get_lang("The message was deleted."));else
+write_msg(get_lang("The messages were deleted."));}}}
+else{if(show_success_msg){if(data.msgs_number.length==1)
+write_msg(get_lang("The message was deleted."));else
+write_msg(get_lang("The messages were deleted."));}}
+if(openTab.type[currentTab]>1){var msg_to_delete=Element(msgs_number);if(parseInt(preferences.delete_and_show_previous_message)&&msg_to_delete){if(msg_to_delete.previousSibling){var previous_msg=msg_to_delete.previousSibling.id;$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:previous_msg,msg_folder:current_folder,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)
+show_msg(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+else{delete_border(currentTab,'false');}}
+else{delete_border(currentTab,'false');}}
+for(var i=0;i<data.msgs_number.length;i++){var msg_to_delete=Element(data.msgs_number[i]);if(msg_to_delete){removeAll(msg_to_delete.id);delete selectedPagingMsgs[data.msgs_number[i]];}
+totalFolderMsgs=totalFolderMsgs-data.msgs_number.length;}
+$.each(data.msgs_number,function(index,value){msgFolder=Base64.encode(get_current_folder());tabToRemove=value+"_r_"+msgFolder.replace(/=/g,"");if($("#"+tabToRemove)){delete_border(tabToRemove,'false');}});Element('tot_m').innerHTML=parseInt(Element('tot_m').innerHTML)-data.msgs_number.length;refresh();}
+if(msgs_number.length>0||parseInt(msgs_number)>0)
+cExecute("$this.imap_functions.delete_msgs&folder="+folder+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse,handler_delete_msgs);else
+write_msg(get_lang('No selected message.'));}
+function move_search_msgs(border_id,new_folder,new_folder_name,action){var msg_to_delete="";var msg_to_move="";var selected_messages='';var temp_msg;var remove_currente_folder="";var id_border=currentTab.replace(/[a-zA-Z_]+/,"");if(currentTab.indexOf('search_local')!=-1||proxy_mensagens.is_local_folder(new_folder))
+{alert(get_lang("You cant manipulate local messages on search"));return;}
+var delete_msg=false;if(new_folder_name==special_folders['Trash']){delete_msg=true;}
+selected_messages=get_selected_messages_search();if(preferences.use_local_messages==1&&expresso_local_messages.isArchiving(selected_messages,folder)){alert("Impossivel mover mensagens que ainda estão sendo arquivadas.");return;}
+var handler_move_search_msgs=function(data){if(!data||!data.msgs_number)
+return;else if(data.deleted){if(data.no_move&&data.move)
+alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission."));else if(data.msgs_number.length==1)
+write_msg(get_lang("The message was deleted."));else
+write_msg(get_lang("The messages were deleted."));}else if(data.status==false&&data.move){alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission."));}else if(data.status==false){alert(get_lang("You don't have permission for this operation in this shared folder!"));return false;}else{if(data.msgs_number.length==1)
+write_msg(get_lang("The message was moved to folder ")+lang_folder(data.new_folder_name));else
+write_msg(get_lang("The messages were moved to folder ")+lang_folder(data.new_folder_name));}
+if(data.no_move){var no_remove=data.no_move.split(',');var continua=true;selected_messages=selected_messages.split(",");for(i=0;i<selected_messages.length;i++){for(j=0;j<no_remove.length;j++)
+if(selected_messages[i]==no_remove[j])
+continua=false;if(continua)
+removeAll(selected_messages[i]+'_s'+id_border);continua=true;}}else{selected_messages=selected_messages.split(",");for(i=0;i<selected_messages.length;i++){removeAll(selected_messages[i]+'_s'+id_border);}}
+var box=Element("tbody_box_"+getNumBoxFromTabId(currentTab)).childNodes;if(box.length>1){updateBoxBgColor(box);}
+connector.purgeCache();if(remove_currente_folder!=""){var mail_msg=Element('tbody_box').childNodes;remove_currente_folder=remove_currente_folder.substring(0,(remove_currente_folder.length-1));remove_currente_folder=remove_currente_folder.split(",");for(i=0;i<remove_currente_folder.length;i++)
+removeAll(remove_currente_folder[i]);var box=Element("tbody_box");if(box.childNodes.length>0){updateBoxBgColor(box.childNodes);}
+if(folder==get_current_folder()){Element('tot_m').innerHTML=parseInt(Element('tot_m').innerHTML)-remove_currente_folder.length;}}
+draw_new_tree_folder();EsearchE.refresh();}
+if(selected_messages){var selected_param="";if(selected_messages.indexOf(',')!=-1)
+{selected_msg_array=selected_messages.split(",");for(i=0;i<selected_msg_array.length;i++){var tr=Element(selected_msg_array[i]+'_s'+id_border);if(tr.getAttribute('name')==current_folder)
+remove_currente_folder+=tr.id.replace(/_[a-zA-Z0-9]+/,"")+',';if((action=='delete'&&tr.getAttribute('name')==mount_url_folder(["INBOX",special_folders["Trash"]]))||!(parseInt(preferences.save_deleted_msg)))
+{msg_to_delete+=','+special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");}
+else if(!(tr.getAttribute('name')==new_folder&&action!='delete'))
+{msg_to_move=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));selected_param+=','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");}else{write_msg(get_lang('At least one message have the same origin'));return false;}}}
+else
+{var tr=Element(selected_messages+'_s'+id_border);if(tr.getAttribute('name')==current_folder)
+remove_currente_folder+=tr.id.replace(/_[a-zA-Z0-9]+/,"")+',';if((action=='delete'&&tr.getAttribute('name')==mount_url_folder(["INBOX",special_folders["Trash"]]))||!(parseInt(preferences.save_deleted_msg))){msg_to_delete=special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");}else if(!(tr.getAttribute('name')==new_folder&&action!='delete')){trfolder=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));selected_param=trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");}else{write_msg(get_lang('The origin folder and the destination folder are the same.'));return false;}}
+var params="";if(msg_to_delete!=""&&msg_to_move!=""){params+="&selected_messages_move="+url_encode(selected_param);params+="&new_folder_move="+url_encode(new_folder);params+="&new_folder_name_move="+url_encode(new_folder_name);new_folder=mount_url_folder(["INBOX",special_folders["Trash"]]);new_folder_name=special_folders['Trash'];params+="&selected_messages_delete="+url_encode(msg_to_delete);params+="&new_folder_delete="+url_encode(new_folder);cExecute("$this.imap_functions.move_delete_search_messages",handler_move_search_msgs,params);}else if(msg_to_delete!=""){new_folder=mount_url_folder(["INBOX",special_folders["Trash"]]);new_folder_name=special_folders['Trash'];params+="&delete=true";params+="&selected_messages="+url_encode(msg_to_delete);params+="&new_folder="+url_encode(new_folder);cExecute("$this.imap_functions.move_search_messages",handler_move_search_msgs,params);}else{params="&selected_messages="+url_encode(selected_param);params+="&delete=false";params+="&new_folder="+url_encode(new_folder);params+="&new_folder_name="+url_encode(new_folder_name);cExecute("$this.imap_functions.move_search_messages",handler_move_search_msgs,params);}}
+else
+write_msg(get_lang('No selected message.'));}
+function move_msgs2(folder,msgs_number,border_ID,new_folder,new_folder_name,show_success_msg,not_opem_previus){not_opem_previus=typeof(not_opem_previus)!='undefined'?not_opem_previus:false;var folder_error=new_folder_name;if(preferences.use_local_messages==1&&expresso_local_messages.isArchiving(msgs_number,folder)){alert("Impossivel mover mensagens que estão ainda estão sendo arquivadas.");return;}
+if(!folder||folder=='null')
+folder=Element("input_folder_"+msgs_number+"_r")?Element("input_folder_"+msgs_number+"_r").value:(openTab.imapBox[currentTab]?openTab.imapBox[currentTab]:get_current_folder());if(openTab.type[currentTab]==1)
+return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name);var handler_move_msgs=function(data){if(typeof(data)=='string')
+if(data.match(/^(.*)TRYCREATE(.*)$/)){connector.loadScript('TreeS');var move_to_folder=data.match(/^(.*)Spam(.*)$/)?"Spam":special_folders['Trash'];alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.',folder_error));ttree.FOLDER='root';create_new_folder(move_to_folder,"INBOX");return false;}else{write_msg(get_lang('Error moving message.')+" "+get_lang('Permission denied to folder "%1".',new_folder_name));if(new_folder_name=="Trash"&&folder.split("/")[1]==new_folder.split("/")[1]){alert(get_lang("You can not remove the message with the preference 'Send to Trash' enabled. There is no permission to move messages to the trash folder."));}
+return false;}
+if(data.status==false){write_msg(get_lang("You don't have permission for this operation in this shared folder!"));return false;}
+mail_msg=(Element("divScrollMain_"+numBox))?Element("divScrollMain_"+numBox).firstChild.firstChild:Element("divScrollMain_0").firstChild.firstChild;if(data.msgs_number.length==1){write_msg(get_lang("The message was moved to folder ")+lang_folder(data.new_folder_name));}
+else{write_msg(get_lang("The messages were moved to folder ")+lang_folder(data.new_folder_name));}
+if(openTab.type[currentTab]>1)
+{msg_to_delete=Element(msgs_number);if(parseInt(preferences.delete_and_show_previous_message)&&msg_to_delete)
+{if(msg_to_delete.previousSibling)
+{var previous_msg=msg_to_delete.previousSibling.id;if(!not_opem_previus){$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:previous_msg,msg_folder:folder,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)
+show_msg(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}}
+else
+{if(current_page>1)
+{$('#msg_opt_previous_'+msg_to_delete.getAttribute('id')+'_r').trigger('click');}
+else
+{var border_id=$("#border_id_"+currentTab).prev().attr("id").split("_").slice(2,3).join("")
+var folderName=current_folder;if(border_id)
+{$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:border_id,msg_folder:folderName,decoded:true}),success:function(data){data=connector.unserialize(data);delete_border(currentTab,'false');if(data)
+{show_msg(data);}},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+else
+{delete_border(currentTab,'false');}}}}
+else
+{if(msg_to_delete.id===String(currentTab).split('_')[0])
+{delete_border(currentTab,'false');}}
+if(msg_to_delete)
+{mail_msg.removeChild(msg_to_delete);}
+var box=Element("tbody_box");if(box.childNodes.length>0)
+{updateBoxBgColor(box.childNodes);}
+if(folder==get_current_folder())
+{Element('tot_m').innerHTML=parseInt(Element('tot_m').innerHTML)-1;}
+return;}
+Element('chk_box_select_all_messages').checked=false;if(!mail_msg)
+mail_msg=Element("tbody_box");data.msgs_number=data.msgs_number.split(",");var msg_to_delete;if(typeof(msgs_number)=='string')
+all_search_msg=msgs_number.split(',');else if(typeof(msgs_number)=='number')
+all_search_msg=msgs_number;for(var i=0;i<=all_search_msg.length;i++)
+{msg_to_delete=Element(folder+';'+all_search_msg[i]);if(msg_to_delete)
+msg_to_delete.parentNode.removeChild(msg_to_delete);}
+if(preferences.use_shortcuts=='1'){var all_messages=Element('tbody_box').childNodes;var msg_list_shortcut=get_selected_messages_shortcut().split(',');if(data.msgs_number.length>0&&msg_list_shortcut.length>0&&data.msgs_number.toString()==msg_list_shortcut.toString()){if(exist_className(all_messages[all_messages.length-1],'selected_shortcut_msg')){select_msg('null','up',true);}
+else{if(!select_msg('null','down',true)){select_msg('null','up',true);}}}}
+for(var i=0;i<data.msgs_number.length;i++)
+{msg_to_delete=Element(data.msgs_number[i]);if(msg_to_delete)
+mail_msg.removeChild(msg_to_delete);}
+if(data.msgs_number.length==1)
+write_msg(get_lang("The message was moved to folder ")+lang_folder(data.new_folder_name));else
+write_msg(get_lang("The messages were moved to folder ")+lang_folder(data.new_folder_name));if(data.border_ID.indexOf('r')!=-1){if(parseInt(preferences.delete_and_show_previous_message)&&folder==get_current_folder()){delete_border(data.border_ID,'false');show_msg(data.previous_msg);}
+else{delete_border(data.border_ID,'false');}}
+if(folder==get_current_folder()){var n_total_msg=parseInt(Element('tot_m').innerHTML)-data.msgs_number.length;n_total_msg=n_total_msg>=0?n_total_msg:0;draw_paging(n_total_msg);Element('tot_m').innerHTML=n_total_msg;totalFolderMsgs-=data.msgs_number.length;}
+refresh();}
+if(folder==new_folder){write_msg(get_lang('The origin folder and the destination folder are the same.'));return;}
+try{if(proxy_mensagens.is_local_folder(Element('input_folder_'+currentTab).getAttribute('value'))&&!border_ID){alert(get_lang("You cant manipulate local messages on search"));return;}}catch(e){}
+if(currentTab==0&&msgs_number=="selected")
+msgs_number=get_selected_messages();else if(currentTab!=0&&msgs_number=="selected")
+msgs_number=currentTab.substr(0,currentTab.indexOf('_r'));if(openTab.type[currentTab]==1){return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name);}
+if(currentTab.toString().indexOf("_r")!=-1&&currentTab==border_ID)
+{if(currentTab.toString().indexOf('_s')!=-1)
+msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf('_s'));else
+msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf('_r'));}
+if(msgs_number){refresh();}
+else{$("#"+get_current_folder()).find('span:first').addClass('selected');}
+if(proxy_mensagens.is_local_folder(folder)){expresso_mail_archive.update_counters=true;if(msgs_number=='selected'){msgs_number=get_selected_messages();}
+if(new_folder=='local_root'){alert(get_lang("Select a folder!"));}
+if(parseInt(msgs_number)>0||msgs_number.length>0){if(proxy_mensagens.is_local_folder(new_folder)){expresso_mail_archive.moveMessages(new_folder.replace('local_messages_',''),msgs_number);delete_border(border_ID);}
+else{if(!new_folder){new_folder='INBOX';}
+if(currentTab.toString().indexOf("_r")!=-1){msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));}
+expresso_mail_archive.unarchieve(folder,new_folder,msgs_number);if(currentTab!=0)
+delete_border(border_ID);}}
+else{write_msg(get_lang('No selected message.'));}}
+else{if(proxy_mensagens.is_local_folder(new_folder)){if(msgs_number=='selected'){archive_msgs(folder,new_folder);}
+else{archive_msgs(folder,new_folder,msgs_number);}}
+else{if(parseInt(msgs_number)>0||msgs_number.length>0){var handler_removeFlag=function(){$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.move_messages',folder:folder,msgs_number:""+msgs_number,border_ID:border_ID,sort_box_type:sort_box_type,search_box_type:search_box_type,sort_box_reverse:sort_box_reverse,reuse_border:border_ID,new_folder:new_folder,new_folder_name:new_folder_name,get_previous_msg:(!not_opem_previus?preferences.delete_and_show_previous_message:false),decoded:true}),success:function(data){data=connector.unserialize(data);$.each(msgs_number.split(","),function(index,value){delete selectedPagingMsgs[value];msgFolder=Base64.encode(get_current_folder());tabToRemove=value+"_r_"+msgFolder.replace(/=/g,"");if($("#"+tabToRemove)){}});totalFolderMsgs-=msgs_number.split(",").length;selectAllFolderMsgs();$('.select-link').unbind('click');if(data)
+handler_move_msgs(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+var hasFolder=false;$.each(fromRules,function(index,value){if(value==folder){hasFolder=true;cExecute("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_number,handler_removeFlag);return false;}});if(!hasFolder){handler_removeFlag();}}else
+write_msg(get_lang('No selected message.'));}}
+$.each(msgs_number.split(","),function(index,value){delete selectedPagingMsgs[value];});totalFolderMsgs=totalFolderMsgs-msgs_number.split(",").length;selectAllFolderMsgs(false);updateSelectedMsgs();}
+function move_msgs(folder,msgs_number,border_ID,new_folder,new_folder_name,not_opem_previus){move_msgs2(folder,msgs_number,border_ID,new_folder,new_folder_name,true,not_opem_previus);}
+function normalizeMsgNumber(msgNumber){if(msgNumber||msgNumber=='selected')
+msgNumber=get_selected_messages();if(currentTab.toString().indexOf("_r")!=-1)
+{if(currentTab.toString().indexOf('_s')!=-1)
+msgNumber=currentTab.toString().substr(0,currentTab.toString().indexOf('_s'));else
+msgNumber=currentTab.toString().substr(0,currentTab.toString().indexOf('_r'));}
+if(parseInt(msgNumber)<=0||msgNumber.length<=0){write_msg(get_lang('No selected message.'));return(false);}
+return(msgNumber);}
+function archive_search_msgs(folder_dest){var id_msgs="";id_msgs=get_selected_messages_search();var msg_to_arquive="";var messages="";var id_border=currentTab.replace(/[a-zA-Z_]+/,"");if(parseInt(id_msgs)<=0||id_msgs.length<=0)
+return write_msg(get_lang('No selected message.'));if(folder_dest=='local_root'||folder_dest==null)
+folder_dest='local_Inbox';id_msgs=expresso_local_messages.checkArchived(id_msgs,folder_dest);if(!id_msgs){write_msg("Todas as mensagens já foram arquivadas anteriormente.");return;}
+document.getElementById("overlay").style.visibility="visible";var handler_arquivar_mensagens=function(data){var msgs_info=[];for(var i=0;i<data.length;i++)
+msgs_info[i]=connector.unserialize(data[i]);var h=expresso_local_messages.has_local_mails();expresso_local_messages.insert_mails(msgs_info,folder_dest,function(s,f){complete_archiving(s,f,h)});document.getElementById("overlay").style.visibility="hidden";}
+id_msgs=id_msgs.split(',');for(i=0;i<id_msgs.length;i++){var tr=Element(id_msgs[i]+'_s'+id_border);msg_to_arquive=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));messages+=','+msg_to_arquive+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");}
+$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:messages,msg_folder:folder_dest,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)
+handler_arquivar_mensagens(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+function archive_msgs(folder,folder_dest,id_msgs){if(typeof(currentTab)=="string"&&currentTab.indexOf("local")!=-1){alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais.");return true;}
+write_msg(get_lang('Starting to archive messages'));if(currentTab.toString().indexOf("_r")!=-1){id_msgs=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));}
+if(!id_msgs)
+id_msgs=get_selected_messages();if(folder_dest=='local_root'||folder_dest==null)
+folder_dest='local_inbox';if(parseInt(id_msgs)>0||id_msgs.length>0){window.setTimeout("expresso_mail_archive.Archive('"+folder+"','"+folder_dest+"','"+id_msgs+"')",1);selectAllFolderMsgs(false);}
+else
+write_msg(get_lang('No selected message.'));}
+function complete_archiving(success,fails,has_local_messages_before)
+{var msgs_to_remove={};var target=mount_url_folder(["INBOX",special_folders["Trash"],'tmpMoveToLocal']);success=expresso_local_messages.select_mail(['original_id','original_folder'],success);for(var i=0;i<success.length;i++){var msg_info=success[i];Element('chk_box_select_all_messages').checked=false;if(Element("check_box_message_"+msg_info.original_id))
+{Element("check_box_message_"+msg_info.original_id).checked=false;}
+if(Element(msg_info.original_id))
+{remove_className(Element(msg_info.original_id),'selected_msg');}
+msgs_to_remove[msg_info.original_folder]=msgs_to_remove[msg_info.original_folder]||[];msgs_to_remove[msg_info.original_folder].push(msg_info.original_id);}
+if(preferences.keep_archived_messages==0){for(var folder in msgs_to_remove){if(folder!='undefined')
+delete_msgs(folder,msgs_to_remove[folder],'null',false,true);}}
+if(!has_local_messages_before&&expresso_local_messages.has_local_mails())
+ttreeBox.update_folder();else
+update_menu();}
+function action_msg_selected_from_search(aba,evento){if(evento=="delete")
+move_search_msgs(aba,'INBOX/Trash','Trash','delete');}
+function get_all_messages_search(){var aba=document.getElementById('content_id_'+currentTab);var messages="";jQuery(function(){jQuery("#"+aba.id+" tr").each(function(i,main_list){messages+=main_list.id.replace(/_[a-zA-Z0-9]+/,"")+',';});});if(messages.indexOf(',')==0)
+messages=messages.substring(1,(messages.length));return messages.substring(0,(messages.length-1));}
+function get_selected_messages_search(){var aba=document.getElementById('content_id_'+currentTab);var selected_messages="";jQuery("#"+aba.id+" tr").each(function(i,main_list){var check_box=main_list.firstChild.firstChild;if(check_box&&check_box.checked){selected_messages+=main_list.id.replace(/_[a-zA-Z0-9]+/,"")+',';};});if(selected_messages!=""){if(selected_messages.indexOf(',')==0)
+selected_messages=selected_messages.substring(1,(selected_messages.length));selected_messages=selected_messages.substring(0,(selected_messages.length-1));return selected_messages;}else{return false;}}
+function get_selected_messages_search_role(){var aba=document.getElementById('content_id_'+currentTab);var selected_messages="";jQuery("#"+aba.id+" tr").each(function(i,main_list){var check_box=main_list.firstChild.firstChild;if(check_box&&check_box.checked&&check_box.id!='chk_box_select_all_messages_search'){selected_messages+=main_list.role+',';};});if(selected_messages!=""){if(selected_messages.indexOf(',')==0)
+selected_messages=selected_messages.substring(1,(selected_messages.length));selected_messages=selected_messages.substring(0,(selected_messages.length-1));return selected_messages;}else{return false;}}
+function get_selected_messages_shortcut(){var main;try{main=document.getElementById("divScrollMain_"+numBox).firstChild.firstChild;}catch(e){};if(!main)
+main=Element("tbody_box_"+numBox);if(!main)
+main=Element("tbody_box");var main_list=main.childNodes;var selected_messages_by_shortcuts='';var j=0;for(j;j<(main_list.length);j++)
+{if(exist_className(Element(main_list[j].id),'selected_shortcut_msg'))
+{selected_messages_by_shortcuts+=main_list[j].id+',';}}
+selected_messages_by_shortcuts=selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1));return selected_messages_by_shortcuts;}
+function get_selected_messages(){var selectedMsg=new Array();$.each(selectedPagingMsgs,function(index,value){if(value)
+selectedMsg.push(index);});return""+selectedMsg;}
+function clear_selected_messages(){selectedPagingMsgs={};}
+function replaceAll(string,token,newtoken){while(string.indexOf(token)!=-1){string=string.replace(token,newtoken);}
+return string;}
+function new_message_to(email){var new_border_ID=new_message('new','null');document.getElementById("to_"+new_border_ID).value=email;}
+function new_message(type,border_ID,flagged){if(RichTextEditor.editorReady===false)return false;RichTextEditor.editorReady=false;if(Element('show_img_link_'+border_ID))
+{show_msg_img(border_ID.match(/^\d*/)[0],Element('input_folder_'+border_ID).value);}
+var new_border_ID=draw_new_message(parseInt(border_ID.replace('_r','')));if(typeof(openTab.type[new_border_ID])!="undefined"){if(tabTypes[type]==openTab.type[new_border_ID]){if(type!='edit')
+{delete_border(currentTab);new_border_ID=draw_new_message(parseInt(border_ID));}}else{var a_types={6:get_lang("Forward"),7:get_lang("Reply"),8:get_lang("Reply to all with history"),9:get_lang("Reply without history"),10:get_lang("Reply to all without history")};if(new_border_ID!=0)
+if(!confirm(get_lang("Your message to %1 has not been saved or sent. "+"To %2 will be necessary open it again. Discard your message?",a_types[openTab.type[new_border_ID]].toUpperCase(),a_types[tabTypes[type]].toUpperCase()))){return new_border_ID;}else{delete_border(currentTab);new_border_ID=draw_new_message(parseInt(border_ID));}}}
+if(new_border_ID=='maximo'){RichTextEditor.editorReady=true;return false;}
+if(new_border_ID==false)
+{RichTextEditor.editorReady=true;setTimeout('new_message(\''+type+'\',\''+border_ID+'\',\''+flagged+'\');',500);return false;}
+openTab.type[new_border_ID]=tabTypes[type];var folder_message=Element("input_folder_"+border_ID);if(folder_message){var input_current_folder=document.createElement('input');input_current_folder.id="new_input_folder_"+border_ID;input_current_folder.name="input_folder";input_current_folder.type="hidden";input_current_folder.value=folder_message.value;Element("content_id_"+new_border_ID).appendChild(input_current_folder);}
+var title='';data=[];if(Element("from_"+border_ID)){if(document.getElementById("reply_to_"+border_ID)){data.to=document.getElementById("reply_to_values_"+border_ID).value;data.to=data.to.replace(/&lt;/gi,"<");data.to=data.to.replace(/&gt;/gi,">");}
+else{if(document.getElementById("sender_values_"+border_ID))
+{data.to=document.getElementById("sender_values_"+border_ID).value;data.to=data.to.replace(/&lt;/gi,"<");data.to=data.to.replace(/&gt;/gi,">");}
+else if(document.getElementById("from_values_"+border_ID)){data.to=document.getElementById("from_values_"+border_ID).value;data.to=data.to.replace(/&lt;/gi,"<");data.to=data.to.replace(/&gt;/gi,">");}}
+if(document.getElementById("to_values_"+border_ID)){data.to_all=document.getElementById("to_values_"+border_ID).value;data.to_all_alternative=document.getElementById("user_email_alternative").value;data.to_all=data.to_all.replace(/\n/gi," ");data.to_all=data.to_all.replace(/&lt;/gi,"<");data.to_all=data.to_all.replace(/&gt;/gi,">");var _array_to_all=data.to_all.split(",");var _array_to_alternative=data.to_all_alternative.split(",");}}
+if(document.getElementById("cc_"+border_ID)){data.cc=document.getElementById("cc_values_"+border_ID).value;data.cc=data.cc.replace(/&lt;/gi,"<");data.cc=data.cc.replace(/&gt;/gi,">");var _array_cc=data.cc.split(",");}
+if(document.getElementById("cco_"+border_ID)){data.cco=document.getElementById("cco_values_"+border_ID).value;data.cco=data.cco.replace(/&lt;/gi,"<");data.cco=data.cco.replace(/&gt;/gi,">");}
+if($("#subject_"+border_ID))
+data.subject=$("#subject_"+border_ID).text();if(data.subject==get_lang("(no subject)   "))
+data.subject='';if(document.getElementById("body_"+border_ID))
+data.body=document.getElementById("body_"+border_ID).innerHTML;if(document.getElementById("from_values_"+border_ID))
+data.from=document.getElementById("from_values_"+border_ID).value;if(Element('date_'+border_ID)){data.date=Element('date_'+border_ID).innerHTML;}
+if(Element('date_day_'+border_ID)){data.date_day=Element('date_day_'+border_ID).value;}
+if(Element('date_hour_'+border_ID)){data.date_hour=Element('date_hour_'+border_ID).value;}
+var signature=RichTextEditor.getSignatureDefault();if(type!="new"&&type!="edit"&&document.getElementById("is_local_"+border_ID)!=null)
+data.is_local_message=(document.getElementById("is_local_"+border_ID).value=="1")?true:false;if(typeof($.fn.elastic)=="undefined"){$.lazy({src:'../prototype/plugins/jquery-elastic/jquery.elastic.source.js',name:'elastic'});}
+var content=$("#content_id_"+new_border_ID);var btnSaveVerify=function(){$("#content_id_"+currentTab+" .save").button("disable");dataBtn=new Array(".to",".cc",".cco","input[name=input_subject]",".reply-to");for(var i in dataBtn){$("#content_id_"+currentTab+" "+dataBtn[i]).keydown(function(){$("#content_id_"+currentTab+" .save").button("enable");});}
+RichTextEditor.keydown(new_border_ID);}
+switch(type){case"reply_without_history":btnSaveVerify();RichTextEditor.replyController=true;content.find('[name="input_to"]').val(data.to);draw_reply_boxes_by_field("to",data.to,content);title="Re: "+html_entities(data.subject);content.find(".subject").val("Re: "+data.subject);useOriginalAttachments(new_border_ID,border_ID);content.find('[name="msg_reply_from"]').val($("#msg_number_"+border_ID).val());if(preferences.use_signature=="1"){RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature,true);}
+break;case"reply_with_history":btnSaveVerify();RichTextEditor.replyController=true;title="Re: "+html_entities(data.subject);content.find(".subject").val("Re: "+data.subject);content.find('[name="input_to"]').val(data.to);draw_reply_boxes_by_field("to",data.to,content);content.find('[name="msg_reply_from"]').val($("#msg_number_"+border_ID).val());block_quoted_body=make_body_reply(data.body,data.from,data.date_day,data.date_hour);useOriginalAttachments(new_border_ID,border_ID);if(preferences.use_signature=="1"){RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature+'<div><br type="_moz"></div>'+block_quoted_body,true);}else{RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+block_quoted_body,true);}
+break;case"reply_to_all_without_history":btnSaveVerify();RichTextEditor.replyController=true;data.to_all=new Array();data.to_all=removeUserEmail(_array_to_all);data.to_all=removeAlternative(data.to_all,_array_to_alternative);content.find('[name="msg_reply_from"]').val($("#msg_number_"+border_ID).val());data.to_all=data.to_all.join(",");title="Re: "+html_entities(data.subject);content.find(".subject").val("Re: "+data.subject);if(data.to.indexOf(Element("user_email").value)>0){draw_reply_boxes_by_field("to",data.to_all,content);content.find('[name="input_to"]').val(data.to_all);}else{draw_reply_boxes_by_field("to",data.to+','+data.to_all,content);content.find('[name="input_to"]').val(data.to+','+data.to_all);}
+if(data.cc){data.cc=new Array();data.cc=removeUserEmail(_array_cc);data.cc=removeAlternative(data.cc,_array_to_alternative);if(data.cc!=get_lang("undisclosed-recipient"))
+data.cc=data.cc.join(",");else
+data.cc="";if(data.cc!=""){content.find('[name="input_cc"]').val(data.cc);input_binds(content.find('[name="input_cc"]').parent(),new_border_ID);content.find(".cc-tr").show();content.find(".cc-button").toggleClass("expressomail-button-icon-ative");content.find(".cc-button").find("span").html("Remover CC");draw_reply_boxes_by_field("cc",data.cc,content);}}
+useOriginalAttachments(new_border_ID,border_ID);if(preferences.use_signature=="1"){RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature,true);}
+break;case"reply_to_all_with_history":btnSaveVerify();RichTextEditor.replyController=true;data.to_all=new Array();data.to_all=removeUserEmail(_array_to_all);data.to_all=removeAlternative(data.to_all,_array_to_alternative);content.find('[name="msg_reply_from"]').val($("#msg_number_"+border_ID).val());if(data.to_all!=get_lang("undisclosed-recipient"))
+data.to_all=data.to_all.join(",");else
+data.to_all="";title="Re: "+html_entities(data.subject);if(data.to.indexOf(Element("user_email").value)>0){draw_reply_boxes_by_field("to",data.to_all,content);content.find('[name="input_to"]').val(data.to_all);}else{draw_reply_boxes_by_field("to",data.to+','+data.to_all,content);content.find('[name="input_to"]').val(data.to+','+data.to_all);}
+if(data.cc){data.cc=new Array();data.cc=removeUserEmail(_array_cc);data.cc=removeAlternative(data.cc,_array_to_alternative);if(data.cc!=get_lang("undisclosed-recipient"))
+data.cc=data.cc.join(",");else
+data.cc="";if(data.cc!=""){content.find('[name="input_cc"]').val(data.cc);input_binds(content.find('[name="input_aux_cc"]').parent(),new_border_ID);content.find(".cc-tr").show();content.find(".cc-button").toggleClass("expressomail-button-icon-ative");content.find(".cc-button").find("span").html("Remover CC");draw_reply_boxes_by_field("cc",data.cc,content);}}
+content.find(".subject").val("Re: "+data.subject);block_quoted_body=make_body_reply(data.body,data.from,data.date_day,data.date_hour);useOriginalAttachments(new_border_ID,border_ID);if(preferences.use_signature=="1"){RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div><div><br type="_moz"></div>'+signature+'<div><br type="_moz"></div>'+block_quoted_body,true);}else{RichTextEditor.setInitData(new_border_ID,block_quoted_body,true);}
+break;case"forward":btnSaveVerify();title="Fw: "+html_entities(data.subject);content.find(".subject").val("Fw: "+data.subject);var divFiles=Element("divFiles_"+new_border_ID);var campo_arquivo;content.find('[name="msg_forward_from"]').val($("#msg_number_"+border_ID).val());if(Element("attachments_"+border_ID))
+addOriginalAttachments(new_border_ID,border_ID);if(preferences.use_signature=="1"){$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>'+signature+'<div><br type="_moz"></div>'+make_forward_body(data.body,data.to,data.date,data.subject,data.to_all,data.cc));RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature+'<div><br type="_moz"></div>'+make_forward_body(data.body,data.to,data.date,data.subject,data.to_all,data.cc));content.find(".to").focus();}
+else{RichTextEditor.setInitData(new_border_ID,make_forward_body(data.body,data.to,data.date,data.subject,data.to_all,data.cc));$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>'+make_forward_body(data.body,data.to,data.date,data.subject,data.to_all,data.cc));content.find(".to").focus();}
+break;case"new":btnSaveVerify();title=get_lang("New Message");if(Element('msg_number').value){var _to=Element('msg_number').value;var reEmail=/^[A-Za-z\d_-]+(\.[A-Za-z\d_-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;if(!reEmail.test(_to)){var array_contacts=contacts.split(',');for(i=0;i<array_contacts.length;i++){if(array_contacts[i].lastIndexOf(_to)!="-1"){var _group=array_contacts[i].split(";");_to='"'+_group[0]+'" <'+_group[1]+'>';break;}}}
+content.find('[name="input_to"]').val(_to+',');draw_email_box(_to,content.find(".to").filter("input"));Element('msg_number').value='';}
+if(preferences.use_signature=="1"){$("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>'+signature);RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+signature);content.find(".to").focus();}
+else
+content.find('[name="input_to"]').focus();break;case"edit":btnSaveVerify();if(flagged=='F')
+$(".important").addClass("expressomail-button-icon-ative");openTab.imapBox[new_border_ID]=folder_message.value;document.getElementById('font_border_id_'+new_border_ID).innerHTML=data.subject;title="Edição: "+html_entities(data.subject);data.to=Element("to_values_"+border_ID).value;if(data.to!=get_lang("without destination")){data.to=data.to.replace(/&lt;/gi,"<");data.to=data.to.replace(/&gt;/gi,">");}else{data.to="";}
+draw_reply_boxes_by_field("to",data.to,content);content.find('[name="input_to"]').val(data.to);if(data.cc){data.cc=data.cc.replace(/&lt;/gi,"<");data.cc=data.cc.replace(/&gt;/gi,">");content.find('[name="input_cc"]').val(data.cc);input_binds(content.find('[name="input_cc"]').parent(),new_border_ID);content.find(".cc-tr").show();content.find(".cc-button").toggleClass("expressomail-button-icon-ative");content.find(".cc-button").find("span").html(get_lang('Remove CC'));draw_reply_boxes_by_field("cc",data.cc,content);}
+if(data.cco){if(content.find('[name="input_cco"]').length){content.find('[name="input_cco"]').val(data.cco);content.find(".cco-tr").show();content.find(".cco-button").toggleClass("expressomail-button-icon-ative");content.find(".cco-button").find("span").html(get_lang('Remove CCo'));input_binds(content.find('[name="input_cco"]').parent(),new_border_ID);draw_reply_boxes_by_field("cco",data.cco,content);}}
+content.find(".subject").val(data.subject);if($("#disposition_notification_"+border_ID).length){content.find('[name="input_return_receipt"]').attr("checked",true);content.find(".return-recept").toggleClass("expressomail-button-icon-ative");}
+var element_important_message=Element("important_message_"+new_border_ID);if(element_important_message){if($("#disposition_important_"+border_ID).length){content.find('[name="input_important_message"]').attr("checked",true);content.find(".important").toggleClass("expressomail-button-icon-ative");}}
+if(Element("attachments_"+border_ID))
+addOriginalAttachments(new_border_ID,border_ID);RichTextEditor.setInitData(new_border_ID,data.body,'edit');uidsSave[new_border_ID].push(new_border_ID);close_delete(border_ID);break;default:}
+content.find('[name="input_to"]').trigger("update");var txtarea=$('#body_'+new_border_ID);var height=document.body.scrollHeight-330;txtarea.css("overflowY","auto");txtarea.css("height",height);$("#border_id_"+new_border_ID).attr("title",title);set_border_caption("border_id_"+new_border_ID,title);resizeWindow();return new_border_ID;}
+function draw_reply_boxes_by_field(field,value,context){array=break_comma(value);$.each(array,function(index,value){draw_email_box(value,context.find("."+field).filter("textarea:first"));});}
+function removeUserEmail(emailList){var userEmail=Element("user_email").value;var array_emails=Array();var j=0;for(var i=0;i<emailList.length;i++){if(emailList[i].indexOf(userEmail)<0){array_emails[j++]=emailList[i];}}
+return array_emails;}
+function removeAlternative(value_to_all,_array_to_alternative){for(i=0;i<_array_to_alternative.length;i++){for(k=0;k<value_to_all.length;k++){if(value_to_all[k].match(/<([^<]*)>[\s]*$/)){if(value_to_all[k].match(/<([^<]*)>[\s]*$/)[1].toLowerCase()==_array_to_alternative[i].toLowerCase()){value_to_all.splice(k,1);k--;}}else if(value_to_all[k].replace(/^\s+|\s+$/g,"").toLowerCase()==_array_to_alternative[i].toLowerCase()){value_to_all.splice(k,1);k--;}}}
+return value_to_all;}
+function useOriginalAttachments(new_border_ID,old_id_border)
+{if(Element("attachments_"+old_id_border))
+{var fileUploadMSG=$('#fileupload_msg'+new_border_ID);var attachments=$("#attachments_"+old_id_border).find("a");if(openTab.imapBox[new_border_ID].split("local").length>1&&attachments.length>0){alert("Não é possivel utilizar os anexos das mensagens locais, favor desarquivar para ter acesso aos anexos");return false;}
+var imagens=block_quoted_body.match(/<img[^>]*>/g);var arrayAttachments=[];var arrayAttachmentsA=[];for(var i=0;i<attachments.length;i++){if((attachments[i].tagName=="SPAN")||(attachments[i].tagName=="IMG")||((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1)))
+continue;if(attachments[i].href.split("local")>1){var arrayAtt=attachments[i].href.replace("javascript:download_local_attachment(","").replace(")","").split(',');}else{var arrayAtt=attachments[i].href.replace("javascript:download_attachments(","").replace(")","").split(',');}
+var att=new Object();var regex=new RegExp("'","g");att.folder=utf8_decoder(Base64.decode(arrayAtt[0].replace(regex,"")));att.uid=arrayAtt[1].replace(regex,"");att.part=arrayAtt[3].replace(regex,"");att.type='imapPart';var idATT=JSON.stringify(att);if(block_quoted_body.indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&amp;msgNumber='+att.uid+'&amp;indexPart='+att.part+'"')!==-1)
+{addAttachment(new_border_ID,idATT);var attach={};attach.fileName=attachments[i].text.substring(0,attachments[i].text.lastIndexOf('('));attach.fullFileName=attach.fileName;if(attach.fileName.length>20)
+attach.fileName=attach.fileName.substr(0,17)+" ... "+attach.fileName.substr(attach.fileName.length-9,attach.fileName.length);attach.fileSize=attachments[i].text.substring((attachments[i].text.lastIndexOf('(')+1),attachments[i].text.lastIndexOf(')'));attach.error=false;fileUploadMSG.find(' .attachments-list').show();var upload=$(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs",{file:attach}));upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>');upload.find(".att-box-loading").remove();upload.find('.att-box-delete').click(function(){var idAttach=$(this).parent().find('input[name="fileId[]"]').val();var content_body=RichTextEditor.getData('body_'+new_border_ID);var imagens=content_body.match(/<img[^>]*>/g);var att=JSON.parse(idAttach);if(imagens!=null)
+{for(var x=0;x<imagens.length;x++)
+if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&amp;msgNumber='+att.uid+'&amp;indexPart='+att.part)!==-1)
+content_body=content_body.replace(imagens[x],'');RichTextEditor.setData('body_'+new_border_ID,content_body);}
+fileUploadMSG.find('.attachments-list').find('input[value="'+idAttach+'"]');delAttachment(new_border_ID,idAttach);$(this).parent().qtip("destroy");$(this).parent().remove();if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){fileUploadMSG.find(' .attachments-list').hide();}});fileUploadMSG.find('.attachments-list').append(upload);fileUploadMSG.find('.attachments-list .att-box:last').qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true,screen:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:3,textAlign:'left',tip:true,name:'blue'}});}
+else
+{arrayAttachments.push(idATT);arrayAttachmentsA.push(attachments[i]);}}
+if(arrayAttachments.length>0)
+{var orignialAtt=fileUploadMSG.find('.button-files-upload').append(' <button tabindex="-1" class="message-add-original-att button small">Anexar arquivos originais</button>').find(".message-add-original-att").button();orignialAtt.click(function(event){for(var i=0;i<arrayAttachments.length;i++){var att=JSON.parse(arrayAttachments[i]);addAttachment(new_border_ID,arrayAttachments[i]);var attach={};attach.fileName=arrayAttachmentsA[i].text.substring(0,arrayAttachmentsA[i].text.lastIndexOf('('));attach.fullFileName=attach.fileName;if(attach.fileName.length>20)
+attach.fileName=attach.fileName.substr(0,17)+" ... "+attach.fileName.substr(attach.fileName.length-9,attach.fileName.length);attach.fileSize=arrayAttachmentsA[i].text.substring((arrayAttachmentsA[i].text.lastIndexOf('(')+1),arrayAttachmentsA[i].text.lastIndexOf(')'));attach.error=false;fileUploadMSG.find(' .attachments-list').show();var upload=$(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs",{file:attach}));upload.find('.att-box-loading').remove();upload.append('<input type="hidden" name="fileId[]" value=\''+arrayAttachments[i]+'\'/>');upload.find('.att-box-delete').click(function(){var idAttach=$(this).parent().find('input[name="fileId[]"]').val();var content_body=RichTextEditor.getData('body_'+new_border_ID);var imagens=content_body.match(/<img[^>]*>/g);var att=JSON.parse(idAttach);if(imagens!=null)
+{for(var x=0;x<imagens.length;x++)
+if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&amp;msgNumber='+att.uid+'&amp;indexPart='+att.part)!==-1)
+content_body=content_body.replace(imagens[x],'');RichTextEditor.setData('body_'+new_border_ID,content_body);}
+fileUploadMSG.find('.attachments-list').find('input[value="'+idAttach+'"]');delAttachment(new_border_ID,idAttach);$(this).parent().qtip("destroy");$(this).parent().remove();if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){fileUploadMSG.find(' .attachments-list').hide();}});fileUploadMSG.find('.attachments-list').append(upload);fileUploadMSG.find('.attachments-list .att-box:last').qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true,screen:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:3,textAlign:'left',tip:true,name:'blue'}});}
+$(this).remove();});}}}
+function addOriginalAttachments(new_border_ID,old_id_border)
+{var fileUploadMSG=$('#fileupload_msg'+new_border_ID);var attachments=$("#attachments_"+old_id_border).find("a");if(openTab.imapBox[new_border_ID].split("local").length>1&&attachments.length>0){alert("Não é possivel utilizar os anexos das mensagens locais, favor desarquivar para ter acesso aos anexos");return false;}
+for(var i=0;i<attachments.length;i++){if((attachments[i].tagName=="SPAN")||(attachments[i].tagName=="IMG")||((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1)))
+continue;fileUploadMSG.find(' .attachments-list').show();if(attachments[i].href.split("local").length>1){var arrayAtt=attachments[i].href.replace("javascript:download_local_attachment(","").replace(")","").split(',');}else{var arrayAtt=attachments[i].href.replace("javascript:download_attachments(","").replace(")","").split(',');}
+var att=new Object();var regex=new RegExp("'","g");att.folder=utf8_decoder(Base64.decode(arrayAtt[0].replace(regex,"")));att.uid=arrayAtt[1].replace(regex,"");att.part=arrayAtt[3].replace(regex,"");att.type='imapPart';var idATT=JSON.stringify(att);addAttachment(new_border_ID,idATT);var attach={};var attachText=(is_ie?attachments[i].innerText:attachments[i].text);attach.fileName=attachText.substring(0,attachText.lastIndexOf('('));attach.fullFileName=attach.fileName;if(attach.fileName.length>20)
+attach.fileName=attach.fileName.substr(0,17)+" ... "+attach.fileName.substr(attach.fileName.length-9,attach.fileName.length);attach.fileSize=attachText.substring((attachText.lastIndexOf('(')+1),attachText.lastIndexOf(')'));attach.error=false;var upload=$(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs",{file:attach}));upload.find('.att-box-loading').remove();upload.find('.att-box-delete').click(function(){var idAttach=$(this).parent().find('input[name="fileId[]"]').val();var content_body=RichTextEditor.getData('body_'+new_border_ID);var imagens=content_body.match(/<img[^>]*>/g);var att=JSON.parse(idAttach);if(imagens!=null)
+{for(var x=0;x<imagens.length;x++)
+if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&amp;msgNumber='+att.uid+'&amp;indexPart='+att.part)!==-1)
+content_body=content_body.replace(imagens[x],'');RichTextEditor.setData('body_'+new_border_ID,content_body);}
+fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]');delAttachment(new_border_ID,idAttach);$(this).parent().qtip("destroy");$(this).parent().remove();if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){fileUploadMSG.find(' .attachments-list').hide();}});upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>');fileUploadMSG.find('.attachments-list').append(upload);fileUploadMSG.find('.attachments-list .att-box:last').qtip({content:DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs",{attach:attach}),position:{corner:{tooltip:'bottomMiddle',target:'topMiddle'},adjust:{resize:true,scroll:true,screen:true}},show:{when:'mouseover',ready:false},hide:'mouseout',style:{border:{width:1,radius:5},width:{min:75,max:1000},padding:3,textAlign:'left',tip:true,name:'blue'}});}}
+function send_message_return(data,ID){if(typeof(data)=='object'&&data.load){cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);}
+watch_changes_in_msg(ID);var content=$("#content_id_"+ID);var sign=false;var crypt=false;var reComplexEmail=/<([^<]*)>[\s]*$/;if((preferences.use_assinar_criptografar!='0')&&(preferences.use_signature_digital_cripto!='0')){var checkSign=document.getElementById('return_digital_'+ID)
+if(checkSign.checked){sign=true;}
+var checkCript=document.getElementById('return_cripto_'+ID);if(checkCript.checked){crypt=true;}}
+if(typeof(data)=='object'&&!data.success)
+{connector=new cConnector();if(sign||crypt){var operation='';if(sign){operation='sign';}
+else{operation='nop';}}
+if(data.body){Element('cert_applet').doButtonClickAction(operation,ID,data.body);}
+else{alert(data.error);}
+return;}
+if(data&&data.success==true){var msg_number_replied=content.find('[name="msg_reply_from"]');var msg_number_forwarded=content.find('[name="msg_forward_from"]');if(msg_number_replied.val()){proxy_mensagens.proxy_set_message_flag(msg_number_replied.val(),'answered');}
+else if(msg_number_forwarded.val()){proxy_mensagens.proxy_set_message_flag(msg_number_forwarded.val(),'forwarded');}
+if(expresso_offline){write_msg(get_lang('Your message was sent to queue'));delete_border(ID,'true');return;}else{if(wfolders.alert){write_msg(get_lang('Your message was sent and save.'));wfolders.alert=false;}
+else{write_msg(get_lang('Your message was sent.'));}}
+delete_border(ID,'true');var arrayTo=content.find(".to-tr").find(".box").clone();save_dynamic_contacts(arrayTo);var arrayCC=content.find(".cc-tr").find(".box").clone();save_dynamic_contacts(arrayCC);var arrayCCo=content.find(".cco-tr").find(".box").clone();save_dynamic_contacts(arrayCCo);if(parseInt(preferences.use_dynamic_contacts))
+updateDynamicContact();cache=new Array();}
+else{if(data=='Post-Content-Length')
+write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',Element('upload_max_filesize').value));else if(data){var error_mail=$.trim(data.split(":")[data.split(":").length-1]);var array=content.find(".to-tr").find(".box");$.each(array,function(index,value){if(error_mail==$(value).find("input").val().match(reComplexEmail)[1])
+$(value).addClass("invalid-email-box");});if(content.find('[name="input_cco"]').length){if(content.find(".cco-tr").css("display")!="none"){var array=content.find(".cco-tr").find(".box");$.each(array,function(index,value){if(error_mail==$(value).find("input").val().match(reComplexEmail)[1])
+$(value).addClass("invalid-email-box");});}}
+if(content.find(".cc-tr").css("display")!="none")
+{var array=content.find(".cc-tr").find(".box");$.each(array,function(index,value){if(error_mail==$(value).find("input").val().match(reComplexEmail)[1])
+$(value).addClass("invalid-email-box");});}
+write_msg(data);}else
+write_msg(get_lang("Connection failed with %1 Server. Try later.","Web"));var save_link=$("#content_id_"+ID).find(".save")[0];save_link.onclick=function onclick(event){openTab.toPreserve[ID]=true;save_msg(ID);};$("#save_message_options_"+ID).button({disabled:false});}
+if(!expresso_offline)
+connector.hideProgressBar();}
+function save_dynamic_contacts(array){if(parseInt(preferences.use_dynamic_contacts)){$.each(array,function(i,value){var stop=false;$.each(dynamicPersonalContacts,function(x,valuex){if(valuex.email==$(value).find("input").val().match(reComplexEmail)[1]){stop=true;return false;}});$.each(dynamicPersonalGroups,function(x,valuex){if(valuex.email==$(value).find("input").val().match(reComplexEmail)[1]){stop=true;return false;}});if(!stop){var exist=0;$.each(dynamicData,function(x,valuex){if(valuex.mail==$(value).find("input").val().match(reComplexEmail)[1]){exist=valuex.id;return false;}});if(exist){REST.put("/dynamiccontact/"+exist,{name:$(value).find("input").val().split('"')[1],mail:$(value).find("input").val().match(reComplexEmail)[1]});}else{REST.post("/dynamiccontacts",{name:$(value).find("input").val().split('"')[1],mail:$(value).find("input").val().match(reComplexEmail)[1]});}}});}}
+function appletReturn(smime,ID,operation,folder){if(!smime){connector=new cConnector();connector.hideProgressBar();return;}
+if(operation=='decript')
+{var handler=function(data){if(data.msg_day=='')
+{header=expresso_local_messages.get_msg_date(data.original_ID,proxy_mensagens.is_local_folder(get_current_folder()));data.fulldate=header.fulldate;data.smalldate=header.smalldate;data.msg_day=header.msg_day;data.msg_hour=header.msg_hour;}
+this.show_msg(data);}
+para="&source="+smime+"&ID="+ID+"&folder="+folder;cExecute("$this.imap_functions.show_decript&",handler,para);}else
+{ID_tmp=ID;var handler_send_smime=function(data){send_message_return(data,this.ID_tmp);};var textArea=document.createElement("TEXTAREA");textArea.style.display='none';textArea.id='smime';textArea.name="smime";textArea.value+=smime;if(is_ie){var i=0;while(document.forms(i).name!="form_message_"+ID){i++}
+form=document.forms(i);}
+else
+form=document.forms["form_message_"+ID];form.appendChild(textArea);cExecuteForm("$this.imap_functions.send_mail",form,handler_send_smime,ID);}}
+function verifyBodyWords(body,words){for(i=0;i<words.length;i++){if(body.search(words[i])!=-1){return words[i];}}
+return false;}
+function send_message(ID,folder,folder_name){var content_body=RichTextEditor.getData('body_'+ID);if(language=="pt-br")
+var words=['anexo','anexos','anexada','anexado','anexei','anexando','anexaste','anexastes','anexamos','anexaram'];else if(language=="es-es")
+var words=['anexo','adjunto','adjuntos','adjuntado','adjuntamos'];else
+var words=['attach','attachment','attached','annex','appending'];if($('#fileupload_msg'+ID).find('.att-box').length==0&&preferences.alert_message_attachment=='1'){var bodyWord=verifyBodyWords(content_body,words);if(bodyWord){$.Zebra_Dialog(get_lang('You wrote "%1" in your message, but there are no files attached. Send it anyway?',bodyWord),{'type':'question','overlay_opacity':'0.5','buttons':['OK','Cancelar'],'width':500,'onClose':function(clicked){if(clicked=='OK'){send_valided_message(ID,folder,folder_name);return;}else{return;}}});}
+else
+send_valided_message(ID,folder,folder_name);}
+else if(!zebraDiscardEventDialog&&$('#fileupload_msg'+ID).find('.att-box-loading').length)
+{zebraDiscardEventDialog=true;window.setTimeout(function(){$.Zebra_Dialog('Existem anexos sendo enviados para o servidor. Caso envie sua mensagem agora estes arquivos serão perdidos.',{'type':'question','overlay_opacity':'0.5','buttons':['Descartar anexos e enviar','Continuar editando e esperar anexos'],'width':500,'onClose':function(clicked){if(clicked=='Descartar anexos e enviar'){$.each($('#fileupload_msg'+ID).find('.att-box'),function(index,value){if($(value).find(".att-box-loading").length)
+$(value).find('.att-box-delete').trigger("click");});send_valided_message(ID,folder,folder_name);}
+window.setTimeout(function(){zebraDiscardEventDialog=false;},500);}})},300);}else{send_valided_message(ID,folder,folder_name);}}
+function send_valided_message(ID,folder,folder_name)
+{if(preferences.auto_save_draft==1)
+autoSaveControl.status[ID]=true;var content=$("#content_id_"+ID);var save_link=$("#content_id_"+ID).find(".save");var onClick=save_link.onclick;save_link.onclick='';save_link.button({disabled:true});var _subject=trim(content.find(".subject").val());if((_subject.length==0)&&!confirm(get_lang("Send this message without a subject?"))){save_link.click(onClick);content.find(".subject").focus();return;}
+var stringReply="";draw_email_box(content.find(".reply-to-tr").find("textarea:first").val(),content.find(".reply-to-tr").find("textarea:first"));content.find(".reply-to-tr").find("textarea:first").val("");var array=content.find(".reply-to-tr").find(".box");$.each(array,function(index,value){stringReply+=$(value).find("input").val()+",";});var stringToEmail="";draw_email_box(content.find(".to-tr").find("textarea:first").val()||content.find(".to-tr").find("input:visible").val(),content.find(".to-tr").find("textarea:first"));content.find(".to-tr").find("textarea:first").val("");content.find(".to-tr").find("input:visible").val("");var array=content.find(".to-tr").find(".box");$.each(array,function(index,value){stringToEmail+=$(value).find("input").val()+",";});var stringEmail="";stringEmail=stringToEmail;var stringCCoEmail="";if(content.find('[name="input_cco"]').length){if(content.find(".cco-tr").css("display")!="none"){draw_email_box(content.find(".cco-tr").find("textarea:first").val()||content.find(".cco-tr").find("input:visible").val(),content.find(".cco-tr").find("textarea:first"));content.find(".cco-tr").find("textarea:first").val("");content.find(".cco-tr").find("input:visible").val("");var array=content.find(".cco-tr").find(".box");$.each(array,function(index,value){stringCCoEmail+=$(value).find("input").val()+",";});}}
+stringEmail+=stringCCoEmail;var stringCCEmail="";if(content.find(".cc-tr").css("display")!="none")
+{draw_email_box(content.find(".cc-tr").find("textarea:first").val()||content.find(".cc-tr").find("input:visible").val(),content.find(".cc-tr").find("textarea:first"));content.find(".cc-tr").find("textarea:first").val("");content.find(".cc-tr").find("input:visible").val("");var array=content.find(".cc-tr").find(".box");$.each(array,function(index,value){stringCCEmail+=$(value).find("input").val()+",";});}
+stringEmail+=stringCCEmail;var mailData=new Object();mailData.body=Base64.encode(RichTextEditor.getData('body_'+ID));mailData.folder=folder;mailData.type=RichTextEditor.plain[ID]?'plain':'html';mailData.uids_save=uidsSave[ID].toString();mailData.save_folder=(openTab.imapBox[ID]&&openTab.type[ID]<6)?openTab.imapBox[ID]:"INBOX"+cyrus_delimiter+draftsfolder;mailData.attachments=listAttachment(ID);mailData.messageNum=currentTab;mailData.input_subject=trim(content.find(".subject").val());mailData.input_reply_to=stringReply;mailData.input_to=stringToEmail;mailData.input_cco=stringCCoEmail;mailData.input_cc=stringCCEmail;mailData.input_cc=stringCCEmail;mailData.abaID=$(content).find('[name="abaID"]').val();mailData.input_important_message=$(content).find('input:checkbox:checked[name="input_important_message"]').val();mailData.input_return_receipt=$(content).find('input:checkbox:checked[name="input_return_receipt"]').val();mailData.msg_forward_from=$(content).find('[name="msg_forward_from"]').val();mailData.msg_reply_from=$(content).find('[name="msg_reply_from"]').val();if($(content).find('select[name="input_from"]').val())
+mailData.input_from=$(content).find('select[name="input_from"]').val();if(stringEmail!=""){$.ajax({url:"controller.php?action=$this.imap_functions.send_mail",data:mailData,type:'POST',success:function(data){send_message_return(connector.unserialize(data),ID);},error:function(){write_msg("Erro ao tentar enviar a mensagem. Nova tentativa em alguns segundos...");var interval=setInterval(function(){send_valided_message(ID,folder,folder_name);clearInterval(interval);},15000);return;}});}else{write_msg(get_lang("message without receiver"));return;}}
+function is_valid_email(campo){var invalidEmail=searchEmail(campo);var semicolon=campo.split(";");if((campo.replace(/^\s+|\s+$/g,""))!=""){if(invalidEmail[0]==true){write_msg("Erro de SMTP: Os endereços de destinatário a seguir falharam: "+invalidEmail[1]);return false;}else{if(semicolon.length>1){var stringError="Erro de SMTP: Os endereços devem ser separados apenas por vígula: ";for(var i=0;i<semicolon.length;i++){stringError=stringError+semicolon[i];if(i+1<semicolon.length)
+stringError=stringError+" ; ";}
+write_msg(stringError);return false;}else{return true;}}}
+else{write_msg(get_lang("Message without receiver"));return false;}}
+function change_tr_properties(tr_element,newUid,newSubject){message_id=tr_element.id;var td_from=document.getElementById('td_from_'+message_id);if(typeof(newSubject)!='undefined')
+td_from.nextSibling.innerHTML=newSubject;tr_element.id=newUid;var openNewMessage=function(){$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.get_info_msg',msg_number:newUid,msg_folder:current_folder,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)
+show_msg(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});};for(var i=2;i<10;i++){if(typeof(tr_element.childNodes[i].id)!="undefined")
+tr_element.childNodes[i].id=tr_element.childNodes[i].id.replace(message_id,newUid);tr_element.childNodes[i].onclick=openNewMessage;}}
+function autoSave(ID)
+{var content=$("#content_id_"+border_id);content.find(".save").button('option','disabled',true);saveButtonDisabled=$("#content_id_"+ID).find(".save").button('option','disabled');if(autoSaveControl.status[ID]===false&&!saveButtonDisabled)
+save_msg(ID);refresh();}
+function save_msg(border_id){if(preferences.auto_save_draft==1)
+autoSaveControl.status[border_id]=true;var content=$("#content_id_"+border_id);content.find(".save").button('option','disabled',true);var array=content.find(".reply-to-tr").find(".box");var stringReplyToEmail="";$.each(array,function(index,value){stringReplyToEmail+=$(value).find("input").val()+",";});content.find('[name="input_reply_to"]').val(stringReplyToEmail);var stringEmail="";var array=content.find(".to-tr").find(".box");$.each(array,function(index,value){stringEmail+=$(value).find("input").val()+",";});content.find('[name="input_to"]').val(stringEmail);stringEmail="";if(content.find('[name="input_cco"]').length){if(content.find(".cco-tr").css("display")!="none"){var array=content.find(".cco-tr").find(".box");$.each(array,function(index,value){stringEmail+=$(value).find("input").val()+",";});content.find('[name="input_cco"]').val(stringEmail);}}
+stringEmail="";if(content.find(".cc-tr").css("display")!="none")
+{var array=content.find(".cc-tr").find(".box");$.each(array,function(index,value){stringEmail+=$(value).find("input").val()+",";});content.find('[name="input_cc"]').val(stringEmail);}
+var idJavascript=saveBorderError[border_id];if(saveBorderError[border_id]!==false)
+DataLayer.put('message',DataLayer.merge(DataLayer.form("#form_message_"+border_id),{id:idJavascript}));else
+idJavascript=DataLayer.put('message',DataLayer.form("#form_message_"+border_id));uidsSave[border_id]=[];DataLayer.commit(false,false,function(data){if(data!=null&&data['message://'+idJavascript]!==undefined&&data['message://'+idJavascript].id!==undefined)
+{uidsSave[border_id].push(data['message://'+idJavascript].id);saveBorderError[border_id]=false;write_msg('Mensagem salva com sucesso!');}
+else
+{saveBorderError[border_id]=idJavascript;write_msg('Erro ao salvar sua mensagem! Nova tentativa em alguns segundos.');}});}
+function set_messages_flag_search_local(flag){}
+function set_messages_flag_search(flag){var id_border=currentTab.replace(/[a-zA-Z_]+/,"");var msgs_flag=this.get_selected_messages_search();if(!msgs_flag){write_msg(get_lang('No selected message.'));return;}
+var selected_param="";msgs_to_flag=msgs_flag.split(",");search=true;for(i=0;i<msgs_to_flag.length;i++){var tr=Element(msgs_to_flag[i]+'_s'+id_border);var msg_to_flag=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));selected_param+=','+msg_to_flag+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");}
+var handler_set_messages_flag=function(data){var errors=false;var notErrors=false;for(var i=0;i<data.length;i++){var notArray=true;if(data[i].msgs_to_set!=''){var msgs=[];if(data[i].msgs_to_set.indexOf(',')>0){msgs=data[i].msgs_to_set.split(',')
+notArray=false;}else
+msgs[0]=data[i].msgs_to_set;for(var j=0;j<msgs.length;j++){switch(data[i].flag){case"unseen":set_msg_as_unread(msgs[j]+'_s'+id_border,true);Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked=false;break;case"seen":set_msg_as_read(msgs[j]+'_s'+id_border,true);Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked=false;break;case"flagged":set_msg_as_flagged(msgs[j]+'_s'+id_border,true);document.getElementById("search_"+id_border+"_check_box_message_"+msgs[j]).checked=false;break;case"unflagged":set_msg_as_unflagged(msgs[j]+'_s'+id_border,true);Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked=false;break;}
+notErrors=true;}}else{errors=true;}}
+draw_tree_folders();Element('chk_box_select_all_messages_search').checked=false;refresh();if(errors&&notErrors)
+write_msg(get_lang('Some messages were not marked with success!'));else if(notErrors)
+write_msg(get_lang('The messages were marked with success!'));else
+write_msg(get_lang('Error marking messages.'));}
+cExecute("$this.imap_functions.set_messages_flag_from_search&msg_to_flag="+selected_param+"&flag="+flag,handler_set_messages_flag);}
+function set_messages_flag(flag,msgs_to_set){if(currentTab!=0&&currentTab.indexOf("search_local")>=0){return set_messages_flag_search_local(flag);}
+if(currentTab!=0&&currentTab.indexOf("search_")>=0){return set_messages_flag_search(flag);}
+var handler_set_messages_flag=function(data){if(!verify_session(data))
+return;var msgs_to_set=data.msgs_to_set.split(",");if(data.disposition_notification_to){$.Zebra_Dialog(data.disposition_notification_to.length==1?get_lang('One of his messages can not be marked as read, because it contains a read confirmation.'):data.disposition_notification_to.length+get_lang(' of its messages could not be marked as read, because it contains a read confirmation.'),{'type':'warning','overlay_opacity':'0.5','buttons':['Fechar']});}
+if(!data.status){write_msg(data.msg);Element('chk_box_select_all_messages').checked=false;for(var i=0;i<msgs_to_set.length;i++){Element("check_box_message_"+msgs_to_set[i]).checked=false;remove_className(Element(msgs_to_set[i]),'selected_msg');}
+if(!data.msgs_unflageds)
+return;else
+if(data.msgs_not_to_set!="")
+write_msg(get_lang("Error processing some messages."));msgs_to_set=data.msgs_unflageds.split(",");}
+for(var i=0;i<msgs_to_set.length;i++){if(preferences.use_cache=='True')
+{if(current_folder=='')
+current_folder='INBOX';var setFlag=function(msgObj){switch(data.flag){case"unseen":msgObj.Unseen="U";break;case"seen":msgObj.Unseen="";break;case"flagged":msgObj.Flagged="F";break;case"unflagged":msgObj.Flagged="";break;}}}
+if(Element("check_box_message_"+msgs_to_set[i])){switch(data.flag){case"unseen":set_msg_as_unread(msgs_to_set[i]);if(results_search_messages!="")
+set_msg_as_unread(results_search_messages,true);Element("check_box_message_"+msgs_to_set[i]).checked=false;break;case"seen":set_msg_as_read(msgs_to_set[i],false);if(results_search_messages!="")
+set_msg_as_read(results_search_messages,false,true);Element("check_box_message_"+msgs_to_set[i]).checked=false;$.each(fromRules,function(index,value){if(value==folder){cExecute("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_to_set,function(){});return false;}});break;case"flagged":set_msg_as_flagged(msgs_to_set[i]);if(results_search_messages!="")
+set_msg_as_flagged(results_search_messages,true);document.getElementById("check_box_message_"+msgs_to_set[i]).checked=false;break;case"unflagged":set_msg_as_unflagged(msgs_to_set[i]);if(results_search_messages!="")
+set_msg_as_unflagged(results_search_messages,true);Element("check_box_message_"+msgs_to_set[i]).checked=false;break;}}}
+Element('chk_box_select_all_messages').checked=false;}
+var folder=get_current_folder();if(msgs_to_set=='get_selected_messages')
+var msgs_to_set=this.get_selected_messages();else
+folder=Element("input_folder_"+msgs_to_set+"_r").value;if(msgs_to_set)
+$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.set_messages_flag',folder:folder,msgs_to_set:msgs_to_set,flag:flag,decoded:true}),success:function(data){data=connector.unserialize(data);selectAllFolderMsgs();$('.select-link').unbind('click');if(data)
+handler_set_messages_flag(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});else
+write_msg(get_lang('No selected message.'));}
+function set_message_flag(msg_number,flag,func_after_flag_change){var msg_number_folder=Element("new_input_folder_"+msg_number+"_r");if(!msg_number_folder)
+var msg_number_folder=Element("input_folder_"+msg_number+"_r");var handler_set_messages_flag=function(data){if(!verify_session(data))
+return;if(!data.status){write_msg(get_lang("this message cant be marked as normal"));return;}
+else if(func_after_flag_change){func_after_flag_change(true);}
+if(data.status&&Element("td_message_answered_"+msg_number)){switch(flag){case"unseen":set_msg_as_unread(msg_number);break;case"seen":set_msg_as_read(msg_number);break;case"flagged":set_msg_as_flagged(msg_number);break;case"unflagged":set_msg_as_unflagged(msg_number);break;case"answered":Element("td_message_answered_"+msg_number).innerHTML='<img src=templates/'+template+'/images/answered.png title=Respondida>';break;case"forwarded":Element("td_message_answered_"+msg_number).innerHTML='<img src=templates/'+template+'/images/forwarded.png title=Encaminhada>';break;}}else{refresh();}}
+$.ajax({url:'controller.php?'+$.param({action:'$this.imap_functions.set_messages_flag',folder:(msg_number_folder?msg_number_folder.value:get_current_folder()),msgs_to_set:msg_number,flag:flag,decoded:true}),success:function(data){data=connector.unserialize(data);if(data)
+handler_set_messages_flag(data);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+function print_search_msg(){var folder="<h2>&nbsp;Resultado da Pesquisa&nbsp;<font color=\"#505050\" face=\"Verdana\" size=\"1\"></h2>";msgs_number=get_selected_messages_search();var tbody=Element('divScrollMain_'+numBox).firstChild.firstChild.innerHTML;var id_border=currentTab.replace(/[a-zA-Z_]+/,"");if(msgs_number){msgs_number=msgs_number.split(",");var tbody="";for(var i=0;i<msgs_number.length;i++){tbody+="<tr id=\""+msgs_number[i]+"_s"+id_border+"\" class=\"tr_msg_unread tr_msg_read2\">"+Element(msgs_number[i]+'_s'+id_border).innerHTML+"</tr>";}}else{msgs_number=get_all_messages_search();msgs_number=msgs_number.split(",");var tbody="";for(var i=0;i<msgs_number.length;i++){tbody+="<tr id=\""+msgs_number[i]+"_s"+id_border+"\" class=\"tr_msg_unread tr_msg_read2\">"+Element(msgs_number[i]+'_s'+id_border).innerHTML+"</tr>";}}
+var print_width=screen.width-200;var x=((screen.width-print_width)/2);var y=((screen.height-400)/2)-35;var window_print=window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);seekDot=(is_ie?/width=24/gi:/width="24"/gi);var thead="<tr class=\"message_header\">    <td width=\"3%\"></td><td width=\"2%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"2%\"></td><td id=\"message_header_FOLDER_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">Pasta</td><td id=\"message_header_SORTFROM_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">De</td><td id=\"message_header_SORTSUBJECT_0\" class=\"th_resizable\" align=\"left\" width=\"*\">Assunto</td><td id=\"message_header_SORTARRIVAL_0\" class=\"th_resizable\" align=\"center\" width=\"11%\"><b>Data</b><img src=\"templates/default/images/arrow_descendant.gif\"></td><td id=\"message_header_SORTSIZE_0\" class=\"th_resizable\" align=\"left\" width=\"11%\">Tamanho</td></tr>";tbody=tbody.replace(seekDot,"style='display:none'");seekDot=(is_ie?/width=16/gi:/width="16"/gi);tbody=tbody.replace(seekDot,"style='display:none'");seekDot=(is_ie?/width=12/gi:/width="12"/gi);tbody=tbody.replace(seekDot,"style='display:none'");while(1){try{window_print.document.open();var html='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>'
++'<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>'
++cabecalho+'</h4><hr>'
++'<h2>'+folder+'</h2><hr/><blockquote><font size="2">'
++'<table width="100%" cellpadding="0" cellspacing="0">'
++'<thead>'+thead+'</thead><tbody>'+tbody+'</tbody>'
++'</table></font></blockquote></body></html>';window_print.document.write(html);window_print.document.close();break;}
+catch(e){}}
+window_print.document.close();window_print.print();}
+function print_messages_bodies(){var messages={};messages[get_current_folder()]=get_selected_messages().split(',');var print_bodies=function(data){var print_width=screen.width-200;var x=((screen.width-print_width)/2);var y=((screen.height-400)/2)-35;var window_print=window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);if(window_print==null){alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname));return;}
+var header='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>'
++'<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>';window_print.document.write(header);var printData='<body style="overflow:auto">'+cabecalho+'</h4><hr>';window_print.document.write(printData);var newRow=function(label,data){return"<tr><td width=7%><font size='2'><b>"+label+" </b></font></td><td><font size='2'>"+data+"</font></td></tr>";}
+$.each(data,function(index,message){var html="<table><tbody>";if(message.sender)
+for(var i=0;i<message.sender.length;i++){html+=newRow(get_lang('Sent by')+":",message.sender[i]);}
+if(message.from)
+for(var i=0;i<message.from.length;i++){html+=newRow(get_lang('From')+":",message.from[i]);}
+if(message.toaddress2){html+=newRow(get_lang('To')+":",message.toaddress2);}
+if(message.cc){html+=newRow(get_lang('Cc')+":",message.cc);}
+if(message.bcc){html+=newRow(get_lang('Cco')+":",message.bcc);}
+if(message.smalldate)
+html+=newRow(get_lang('Date')+":",message.smalldate);else if(message.udate){var norm=function(arg){return(arg<10?'0'+arg:arg);};var weekDays=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];var today=new Date();today.setHours(23);today.setMinutes(59);today.setSeconds(59);today.setMilliseconds(999);udate_local=message.udate*1000+today.getTimezoneOffset()*60*1000;date_msg=new Date(udate_local);if(preferences.show_date_numerical==0||typeof(preferences.show_date_numerical)=='undefined'){if(today.getTime()-date_msg.getTime()<86400000)
+html+=newRow(get_lang('Date')+":",norm(date_msg.getHours())+':'+norm(date_msg.getMinutes()));else
+if(today.getTime()-date_msg.getTime()<172800000)
+newRow(get_lang('Date')+":",get_lang('Yesterday'));else if(today.getTime()-date_msg.getTime()<259200000)
+html+=newRow(get_lang('Date')+":",get_lang(weekDays[date_msg.getDay()]));else
+html+=newRow(get_lang('Date')+":",norm(date_msg.getDate())+'/'+norm(date_msg.getMonth()+1)+'/'+date_msg.getFullYear());}else
+html+=newRow(get_lang('Date')+":",norm(date_msg.getDate())+'/'+norm(date_msg.getMonth()+1)+'/'+date_msg.getFullYear());}
+html+=newRow(get_lang('Subject')+":",message.subject);if(message.attachments&&message.attachments.length){var img='<img style="margin-bottom : -5px; cursor : pointer;" src="templates/'+template+'/images/new.png">';var atts="";$.each(message.attachments,function(index,attach){atts+=" | "+attach.name+"("+formatBytes(attach.fsize)+") "+img+" | ";});html+=newRow(get_lang('Attachments: '),atts);}
+else if(message.attachment&&message.attachment.number_attachments>0){var img='<img style="margin-bottom : -5px; cursor : pointer;" src="templates/'+template+'/images/new.png">';var atts="";$.each(message.attachment.names.split(','),function(index,attach){atts+=" | "+attach+img+" |";});html+=newRow(get_lang('Attachments: '),atts);}
+html+='</tbody></table>';if(message.body){html+="<hr>"+message.body;}
+else if(message._return){html+="<hr>"+message._return;}
+html+="<hr>";window_print.document.write(html);});window_print.document.close();window_print.print();}
+if(proxy_mensagens.is_local_folder(get_current_folder())){var msgs=Array();var _msg={};$.each(get_selected_messages().split(','),function(index,value){_msg.header=expresso_mail_archive.getMessageHeaders(value);_msg.body=expresso_mail_archive.getMessageBodies([value]);msgs.push($.extend({},_msg.header,_msg.body[0]));});print_bodies(msgs);}
+else{$.ajax({url:"controller.php?"+$.param({action:"$this.imap_functions.getMessages",details:"all",messages:messages,}),success:function(data){data=connector.unserialize(data);if(data){print_bodies(data[get_current_folder()]);}},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}}
+function newTbody(messages){var tbody=$("<tbody>");$.each(messages,function(index,msg){var newTr=make_tr_message(msg,get_current_folder());if(msg.attachments&&msg.attachments.length){$(newTr).find('td').eq(1).html("<img src ='templates/"+template+"/images/clip.gif'>");}
+tbody.append(newTr);});return tbody.html();}
+function print_messages_list(){var print_list=function(tbody,folder){var print_width=screen.width-200;var x=((screen.width-print_width)/2);var y=((screen.height-400)/2)-35;var window_print=window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);seekDot=(is_ie?/width=24/gi:/width="24"/gi);var thead="<tr class=\"message_header\"> <td width=\"3%\"></td><td width=\"2%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"2%\"></td><td width=\"2%\"></td><td width=\"2%\"></td><td id=\"message_header_SORTFROM_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">De</td><td id=\"message_header_SORTSUBJECT_0\" class=\"th_resizable\" align=\"left\" width=\"*\">Assunto</td><td id=\"message_header_SORTARRIVAL_0\" class=\"th_resizable\" align=\"center\" width=\"11%\"><b>Data</b><img src=\"templates/default/images/arrow_descendant.gif\"></td><td id=\"message_header_SORTSIZE_0\" class=\"th_resizable\" align=\"left\" width=\"11%\">Tamanho</td></tr>";tbody=tbody.replace(seekDot,"style='display:none'");seekDot=(is_ie?/width=16/gi:/width="16"/gi);tbody=tbody.replace(seekDot,"style='display:none'");seekDot=(is_ie?/width=12/gi:/width="12"/gi);tbody=tbody.replace(seekDot,"style='display:none'");while(1){try{window_print.document.open();var html='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>'
++'<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>'
++cabecalho+'</h4><hr>'
++'<h2>'+$('#border_id_0').html()+'</h2><hr/><blockquote><font size="2">'
++'<table width="100%" cellpadding="0" cellspacing="0">'
++'<thead>'+thead+'</thead><tbody>'+tbody+'</tbody>'
++'</table></font></blockquote></body></html>';window_print.document.write(html);window_print.document.close();break;}
+catch(e){}}
+window_print.document.close();window_print.print();}
+msgs_number=get_selected_messages();if(msgs_number==false){var tbody=Element('divScrollMain_0').firstChild.firstChild.innerHTML;print_list(tbody);}else{var messages={};messages[get_current_folder()]=msgs_number.split(',');if(proxy_mensagens.is_local_folder(get_current_folder())){var msgs=Array();$.each(msgs_number.split(','),function(index,value){msgs.push(expresso_mail_archive.getMessageHeaders(value));});print_list(newTbody(msgs));}
+else{$.ajax({url:"controller.php?"+$.param({action:"$this.imap_functions.getMessages",details:"all",messages:messages,}),success:function(data){data=connector.unserialize(data);if(data){data=data[get_current_folder()];print_list(newTbody(data));}},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}}}
+function print_all(){if(typeof(currentTab)=="string"&&currentTab.indexOf("local")!=-1){alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais.");return true;}
+if(openTab.type[currentTab]==2)
+return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab);if(currentTab!=0&&currentTab.indexOf("search_")>=0){return print_search_msg();}
+if(get_selected_messages()==false){return print_messages_list();}
+var msg='Algumas mensagens foram selecionadas para impressão. Deseja imprimir o conteúdo de cada uma delas? Caso contrário, apenas uma lista das mensagens selecionadas será impressa.';$.Zebra_Dialog(msg,{'type':'question','buttons':['Sim','Não'],'overlay_opacity':'0.5','onClose':function(caption){if(caption=='Sim'){return print_messages_bodies();}
+else{return print_messages_list();}}});}
+function print_msg(msg_folder,msg_number,border_ID){var div_toaddress_full=Element("div_toaddress_full_"+border_ID);var div_ccaddress_full=Element("div_ccaddress_full_"+border_ID);var div_ccoaddress_full=Element("div_ccoaddress_full_"+border_ID);var printListTO=(div_toaddress_full&&div_toaddress_full.style.display!='none')||toaddress_array[border_ID].length==1?true:false;var printListCC=(div_ccaddress_full&&div_ccaddress_full.style.display!='none')||!div_ccaddress_full?true:false;var printListCCO=(div_ccoaddress_full&&div_ccoaddress_full.style.display!='none')||!div_ccoaddress_full?true:false;var sender=Element('sender_values_'+border_ID)?Element('sender_values_'+border_ID).value:null;var from=Element('from_values_'+border_ID)?Element('from_values_'+border_ID).value:null;var to=Element('to_values_'+border_ID)?Element('to_values_'+border_ID).value:null;var cco=Element('cco_values_'+border_ID)?Element('cco_values_'+border_ID).value:null;var cc=Element('cc_values_'+border_ID)?Element('cc_values_'+border_ID).value:null;var date=Element('date_'+border_ID);var subject=Element('subject_'+border_ID);var attachments=Element('attachments_'+border_ID);var body=Element('body_'+border_ID);var att='';var countAtt=0;if(attachments!==null)
+{countAtt=attachments.getElementsByTagName('a').length;if(countAtt===1)
+att=attachments.getElementsByTagName('a')[0].innerHTML;else if(countAtt>1)
+for(var i=1;i<attachments.getElementsByTagName('a').length;i++)
+att+=" | "+attachments.getElementsByTagName('a')[i].innerHTML;}
+var body=Element('body_'+border_ID);var print_width=screen.width-200;var x=((screen.width-print_width)/2);var y=((screen.height-400)/2)-35;var window_print=window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y);if(window_print==null){alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname));return;}
+if(attachments!=null)
+{var a=attachments.childNodes;var attachs="";var show_attachs="";var ii=a.length>2?2:1;for(i=ii;i<a.length;i++)
+{if(a[i].tagName&&a[i].tagName=="A")
+{attachs+=a[i].innerHTML;}}
+show_attachs="<tr><td width=7%><font size='2'>"+get_lang('Attachments: ')+" </font></td><td><font size='2'>"+attachs+"</font></td></tr>";}else{show_attachs="";}
+var current_path=window.location.href.substr(0,window.location.href.lastIndexOf("/"));var head='<head><title></title><link href="'+current_path+'/templates/default/main.css" type="text/css" rel="stylesheet"></head>';window_print.document.write(head);while(1){try{var html='<body style="overflow:auto">';html+=cabecalho+'</h4><hr>';html+='<table><tbody>';if(sender)
+html+="<tr><td width=7% noWrap><font size='2'>"+get_lang('Sent by')+": </font></td><td><font size='2'>"+sender+"</font></td></tr>";if(from)
+html+="<tr><td width=7%><font size='2'>"+get_lang('From')+": </font></td><td><font size='2'>"+from+"</font></td></tr>";if(to){if(!printListTO)
+to='Os destinatários não estão sendo exibidos para esta impressão';html+="<tr><td width=7%><font size='2'>"+get_lang('To')+": </font></td><td><font size='2'>"+to+"</font></td></tr>";}
+if(cc){if(!printListCC)
+cc='Os destinatários não estão sendo exibidos para esta impressão';html+="<tr><td width=7%><font size='2'>"+get_lang('Cc')+": </font></td><td><font size='2'>"+cc+"</font></td></tr>";}
+if(cco){if(!printListCCO)
+cco='Os destinatários não estão sendo exibidos para esta impressão';html+="<tr><td width=7%><font size='2'>"+get_lang('Cco')+": </font></td><td><font size='2'>"+cco+"</font></td></tr>";}
+if(date)
+html+="<tr><td width=7%><font size='2'>"+get_lang('Date')+": </font></td><td><font size='2'>"+date.innerHTML+"</font></td></tr>";html+="<tr><td width=7%><font size='2'>"+get_lang('Subject')+": </font></td><td><font size='2'>"+subject.innerHTML+"</font></td></tr>";if(countAtt>0){html+="<tr><td width=7%><font size='2'>"+get_lang('Attachments: ')+"</font></td><td><font size='2'>"+att+"</font></td></tr>";}
+html+="</tbody></table><hr>";window_print.document.write(html+body.innerHTML);var tab_tags=window_print.document.getElementsByTagName("IMG");var link=location.href.replace(/\/expressoMail1_2\/(.*)/,"");for(var i=0;i<tab_tags.length;i++){var _img=tab_tags[i].cloneNode(true);if(tab_tags[i].src.toUpperCase().indexOf('INC/GET_ARCHIVE.PHP?MSGFOLDER=')>-1)
+_img.src=link+'/expressoMail1_2/'+tab_tags[i].src.substr(tab_tags[i].src.toUpperCase().indexOf('INC/GET_ARCHIVE.PHP?MSGFOLDER='));tab_tags[i].parentNode.replaceChild(_img,tab_tags[i]);}
+break;}
+catch(e){}}
+window_print.document.close();window_print.print();}
+function empty_trash_imap(shared,button,type){if(shared){var folder_part=$(button).parents("li:first").attr("id").split(cyrus_delimiter);var folder=folder_part[0]+cyrus_delimiter+folder_part[1];}
+var handler_empty_trash=function(data){Element('chk_box_select_all_messages').checked=false;if(!verify_session(data))
+return;update_quota(get_current_folder());draw_new_tree_folder();draw_tree_labels();if(data){if(typeof(data)=="object"){if(data[1]=="Permission denied"){cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);return write_msg(get_lang("Permission denied"));}}
+write_msg(get_lang('Your Trash folder was empty.'));if(get_current_folder()==mount_url_folder(["INBOX",special_folders["Trash"]])){draw_paging(0);remove_rows(document.getElementById("table_box"));Element('tot_m').innerHTML=0;Element('new_m').innerHTML=0;}}
+else
+write_msg(get_lang('ERROR emptying your Trash folder.'));}
+$.Zebra_Dialog(get_lang('Do you really want to empty your trash folder?'),{'type':'question','title':get_lang('Empty Trash'),'buttons':[get_lang("Yes"),get_lang("No")],'overlay_opacity':0.5,'onClose':function(caption){if(caption==get_lang("Yes")){if(type.id=="local_messages_trash"){expresso_mail_archive.deleteAllMessages(type.id);cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);}else{cExecute("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultTrashFolder"+(shared?"&shared="+folder:""),handler_empty_trash);}}}});}
+function empty_spam_imap(shared,button,type){if(shared){var folder_part=$(button).parents("li:first").attr("id").split(cyrus_delimiter);var folder=folder_part[0]+cyrus_delimiter+folder_part[1];}
+var handler_empty_spam=function(data){Element('chk_box_select_all_messages').checked=false;if(!verify_session(data))
+return;if(get_current_folder()==mount_url_folder(["INBOX",special_folders["Spam"]])){draw_paging(0);remove_rows(document.getElementById("table_box"));}
+draw_new_tree_folder();draw_tree_labels();update_quota(get_current_folder());if(data){if(typeof(data)=="object"){if(data[1]=="Permission denied"){cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);return write_msg(get_lang("Permission denied"));}else{write_msg(get_lang('Your Spam folder was empty.'));}}else{write_msg(get_lang('Your Spam folder was empty.'));}}
+else
+write_msg(get_lang('ERROR emptying your Spam folder.'));}
+$.Zebra_Dialog(get_lang('Do you really want to empty your spam folder?'),{'type':'question','title':get_lang('Empty Spam'),'buttons':[get_lang("Yes"),get_lang("No")],'overlay_opacity':0.5,'onClose':function(caption){if(caption==get_lang("Yes")){if(type.id=="local_messages_spam"){expresso_mail_archive.deleteAllMessages(type.id);cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);}else{cExecute("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultSpamFolder"+(shared?"&shared="+folder:""),handler_empty_spam);}}}});}
+function buildExportArchiver(msgsArchive,name_box){var hand_export=function(data){if(!data){write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.'))}else if(data["empty_folder"]||data=="empty_folder"){write_msg(get_lang("The selected folder is empty."));}else
+download_attachments(null,null,data,null,null,get_current_folder().split("_")[2]+'.zip');}
+var array=new Array();for(var i=0;i<msgsArchive.length;i++){eachMsg={'ContentType':msgsArchive[i].ContentType,'from':{'email':msgsArchive[i].from.email,'full':msgsArchive[i].from.full,'name':msgsArchive[i].from.name},'msg_sample':msgsArchive[i].msg_sample,'subject':msgsArchive[i].subject,'to':{'email':msgsArchive[i].to.email,'full':msgsArchive[i].to.full,'name':msgsArchive[i].to.name},'toaddress2':msgsArchive[i].toaddress2,'msg_number':msgsArchive[i].msg_number,'date':new Date(msgsArchive[i].timestamp).toString()};array.push(eachMsg);}
+$.ajax({type:"POST",url:"controller.php?action=$this.exporteml.export_all_byLocalFolder",data:{folder:name_box,type:"msg_local",messages:array}}).done(function(msg){hand_export(msg.split('"')[1]);});}
+function export_all_selected_msgs(){if(get_current_folder().split("_")[0]=="local"){if(get_selected_messages().indexOf(",")!=-1){expresso_mail_archive.getSomeMsgs(get_selected_messages().split(","));}else{expresso_mail_archive.getSomeMsgs([get_selected_messages()]);}
+buildExportArchiver(expresso_mail_archive.getSomeMsg,get_current_folder().split("_")[2]);}else{if(openTab.type[currentTab]>1){source_msg(currentTab,openTab.imapBox[currentTab]);return;}
+var search=false;if(currentTab!=0&&currentTab.indexOf("search_")>=0){var id_border=currentTab.replace(/[a-zA-Z_]+/,"");var msgs_to_export=this.get_selected_messages_search();if(!msgs_to_export){write_msg(get_lang('No selected message.'));return;}
+var selected_param="";msgs_to_export=msgs_to_export.split(",");search=true;for(i=0;i<msgs_to_export.length;i++){var tr=Element(msgs_to_export[i]+'_s'+id_border);msg_to_move=(tr.getAttribute('name')==null?get_current_folder():tr.getAttribute('name'));selected_param+=','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");}}else{var msgs_to_export=this.get_selected_messages();}
+var handler_export_all_selected_msgs=function(data){if(!data){write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.'));}
+else{var filename='mensagens.zip';if(data[0].match(/\.eml$/gi)){filename=data[1]+'.eml';}
+download_attachments(null,null,data[0],null,null,filename);}}
+if(search){cExecute("$this.exporteml.makeAll",handler_export_all_selected_msgs,"folder=false&msgs_to_export="+selected_param);}else if(msgs_to_export){cExecute("$this.exporteml.makeAll",handler_export_all_selected_msgs,"folder="+get_current_folder()+"&msgs_to_export="+msgs_to_export);write_msg(get_lang('You must wait while the messages will be exported...'));}
+else
+write_msg(get_lang('No selected message.'));}}
+function select_all_search_messages(select,aba){if(select){jQuery("#"+aba+" tr").each(function(i,o){o.firstChild.firstChild.checked=true;add_className(o,'selected_msg');});}else{jQuery("#"+aba+" tr").each(function(i,o){o.firstChild.firstChild.checked=false;remove_className(o,'selected_msg');});}}
+function verify_session(data){if(data&&data.imap_error){if(data.imap_error=="nosession")
+write_msg(get_lang("your session could not be verified."));else
+write_msg(data.imap_error);return false;}
+else
+return true;}
+function save_image(e,thumb,file_type){file_type=file_type.replace("/",".");thumb.oncontextmenu=function(e){return false;}
+var _button=is_ie?window.event.button:e.which;var _target=is_ie?event.srcElement:e.target;if(_button==2||_button==3){var _params=_target.id.split(";;");download_attachments(Base64.encode(_params[0]),_params[1],_params[2],_params[3],_params[4],file_type);if($(_target).parent().attr("href").split("http").length>1){var part_find=thumb.toString().split("#");var part2_find=part_find[1].split("/temp");var part_id_dwl=part2_find[0]+'/temp/download'+part2_find[1];download_local_attachment(part_id_dwl);return;}else{var _params=_target.id.split(";;");download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type);}}}
+function save_image2(info){var obj=jQuery.parseJSON(unescape(info));download_attachments(obj.folder,obj.message,obj.thumbIndex,obj.pid,obj.encoding,obj.type.replace("/","."));}
+function nospam(msgs_number,border_ID,folder){if(folder=='null')
+folder=get_current_folder();var new_folder='';if(folder.substr(0,4)=='user'){arrayFolder=folder.split(cyrus_delimiter);new_folder='user'+cyrus_delimiter+arrayFolder[1];}
+else{new_folder='INBOX';}
+var new_folder_name=get_lang('INBOX');var handler_move_msgs=function(data){if(msgs_number=='selected')
+set_messages_flag("unseen","get_selected_messages");else
+proxy_mensagens.proxy_set_message_flag(msgs_number,"unseen");proxy_mensagens.proxy_move_messages(folder,msgs_number,border_ID,new_folder,new_folder_name);if(openTab.type[currentTab]>1)
+delete_border(currentTab,'false');}
+if(currentTab.toString().indexOf("_r")!=-1)
+msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));else if(msgs_number=='selected')
+msgs_number=get_selected_messages();if(currentTab==0)
+msgs_number=get_selected_messages();if(typeof currentTab=="string"&&currentTab.indexOf("search_")!="-1"){msgs_number="";var checked=$("#divScrollMain_"+currentTab.substr(currentTab.indexOf('_')+1,255)).find("tr input:checked");$.each(checked,function(index,value){if(value){if(index==0)
+msgs_number=$(value).parents("tr").attr("id");else
+msgs_number+=","+$(value).parents("tr").attr("id");}});}
+if(parseInt(msgs_number)>0||msgs_number.length>0)
+cExecute("$this.imap_functions.spam&folder="+folder+"&spam=false"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+0+"&cyrus_delimiter="+cyrus_delimiter,handler_move_msgs);else
+write_msg(get_lang('No selected message.'));}
+function spam(folder,msgs_number,border_ID){if(folder=='null')
+folder=get_current_folder();var new_folder='';if(folder.substr(0,4)=='user')
+{arrayFolder=folder.split(cyrus_delimiter);new_folder='user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Spam'];}
+else
+{new_folder=mount_url_folder(["INBOX",special_folders["Spam"]]);}
+var new_folder_name='Spam';var not_opem_previus=true;var handler_move_msgs=function(data){proxy_mensagens.proxy_move_messages(folder,msgs_number,border_ID,new_folder,new_folder_name,not_opem_previus);if(openTab.type[currentTab]>1){if(preferences.delete_and_show_previous_message==1)
+delete_border(currentTab,'false');}}
+if(currentTab.toString().indexOf("_r")!=-1)
+msgs_number=currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));else if(currentTab!=0&&currentTab.indexOf("search_")>=0){var content_search=document.getElementById('content_id_'+currentTab);mount_url_folder(["INBOX",special_folders['Trash']]),'Trash',move_search_msgs('content_id_'+currentTab,mount_url_folder(["INBOX",special_folders["Spam"]]),special_folders['Spam']);refresh();return;}else if(msgs_number=='selected')
+msgs_number=get_selected_messages();if(currentTab==0)
+msgs_number=get_selected_messages();if(parseInt(msgs_number)>0||msgs_number.length>0)
+cExecute("$this.imap_functions.spam&folder="+folder+"&spam=true"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+0+"&cyrus_delimiter="+cyrus_delimiter,handler_move_msgs);else
+write_msg(get_lang('No selected message.'));}
+function import_window()
+{if(typeof(currentTab)=="string"&&currentTab.indexOf("local")!=-1){alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais.");return true;}
+var folder={};var importEmails=$("#importEmails");importEmails.html(DataLayer.render(BASE_PATH+"modules/mail/templates/importEmails.ejs",{}));importEmails.dialog({height:280,width:500,resizable:false,title:get_lang('zip mails to import'),modal:true,buttons:[{text:get_lang("Close"),click:function()
+{importEmails.dialog("close").dialog("destroy");}},{text:get_lang("Import"),click:function()
+{var input_file=importEmails.find("input[type=file]");var input_hidden=importEmails.find("input[name=folder]");if(input_file.attr("value")=="")
+{$.Zebra_Dialog(get_lang("You must choose a file")+" !",{'type':'warning','overlay_opacity':'0.5','onClose':function(){$("#importMessageAccordion").accordion('activate',0);}});}
+else
+{if(input_hidden.attr("value")=="")
+$.Zebra_Dialog(get_lang("You must choose a folder")+" !",{'type':'warning','overlay_opacity':'0.5','onClose':function(){$("#importMessageAccordion").accordion('activate',1);}});else
+{var handler_return=function(data)
+{write_msg(get_lang('The import was executed successfully.'));return_import_msgs(data,folder);}
+var formSend=document.getElementById("importFileMessages");importEmails.dialog("destroy");write_msg(get_lang('You must wait while the messages will be imported...'));cExecuteForm('$this.imap_functions.import_msgs',formSend,handler_return);}}}}],open:function(event,ui)
+{if(typeof(shortcut)!='undefined')shortcut.disabled=true;},close:function(event,ui)
+{if(typeof(shortcut)!='undefined')shortcut.disabled=false;}});importEmails.css("overflow","hidden");importEmails.find("input[type=file]").change(function()
+{var deniedExtension=true;var fileExtension=["eml","zip"];var fileName=importEmails.find("input[type=file]").attr('value');fileName=fileName.split(".");if(fileName[1])
+{for(var i in fileExtension)
+{if(fileExtension[i].toUpperCase()===fileName[1].toUpperCase())
+{deniedExtension=false;break;}}}
+if(deniedExtension)
+{$.Zebra_Dialog(get_lang('File extension forbidden or invalid file'),{'type':'warning','overlay_opacity':'0.5'});}
+$("#lblFileName").html((!deniedExtension)?importEmails.find("input[type=file]").attr('value'):"");});$("#importMessageAccordion").accordion();var foldersTree=jQuery("#foldertree-container-importMessage").removeClass('empty-container').html(DataLayer.render(BASE_PATH+'api/templates/foldertree.ejs',{folders:[cp_tree1,cp_tree2,[]]})).find("#foldertree").treeview().click(function(event)
+{var target=$(event.target);if(target.is('.collapsable-hitarea, .expandable-hitarea, .lastCollapsable, .lastExpandable, .treeview'))
+return;if(!target.attr('id'))
+target=target.parent();if(target.attr('id')=="foldertree")return;folder.id=target.attr('id');folder.child=target.find('.folder');folder.caption=target.find('span').attr('title');$('#foldertree-container-importMessage .filetree span.folder.selected').removeClass('selected');if(!target.is('#foldertree > .expandable, #foldertree > .collapsable'))
+$(target).children('.folder').addClass('selected');selectedFolder={id:folder.id,name:folder.child.attr('title'),'class':folder.child.attr('class')};importEmails.find("input[name=folder]").attr("value",folder.id);});$("#lblFileName").prev().css("margin-left","10px");$("#lblFileName").prev().css("font-weight","bold");}
+function return_import_msgs(data,folder)
+{if(data&&data.error){write_msg(data.error);}
+else
+{if(data=='Post-Content-Length')
+write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',preferences.max_attachment_size?preferences.max_attachment_size:Element('upload_max_filesize').value));else
+{var er=/^local_/;if(er.test(folder.id))
+{alert("Mensagens não podem ser importadas em pastas locais");}
+else
+{if(openTab.imapBox[0]==folder.id)
+{openTab.imapBox[0]='';change_folder(folder.id,folder.caption);}
+refresh();}}}}
+function decodeCreateSchedulable(type,ID){var startEvent=new Date();if(startEvent.toString('mm')<30)
+startEvent.add({minutes:(30-parseInt(startEvent.toString('mm')))});else
+startEvent.add({hours:1,minutes:'-'+startEvent.toString('mm')});var endEvent=function(date){if(!!User.preferences.defaultCalendar){return new Date(parseInt(date.getTime())+
+(!!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration?(Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration*60000):(User.preferences.defaultDuration*60000)));}else
+return new Date(parseInt(date.getTime())+(User.preferences.defaultDuration*60000));};var emails=$("#to_values_"+ID).val().split(',');var schedulable={};schedulable={acl:{inviteGuests:true,organization:true,participationRequired:false,read:true,write:true},alarms:[],allDay:false,attachments:[],isAttendee:true,attendee:'',category:'','class':'1',delegatedFrom:{},endDate:startEvent.toString(User.preferences.dateFormat),startDate:endEvent(startEvent).toString(User.preferences.dateFormat),startHour:startEvent.toString(User.preferences.hourFormat),endHour:endEvent(startEvent).toString(User.preferences.hourFormat),timezone:User.preferences.defaultCalendar?Calendar.signatureOf[User.preferences.defaultCalendar].calendar.timezone:User.preferences.timezone,summary:$("#subject_"+ID).text(),description:$("#body_"+ID).text(),startTime:startEvent.getTime(),endTime:endEvent(startEvent),timezones:Timezone.timezones,me:{name:User.me.name,mail:User.me.mail,acl:'rowi',status:'1',delegatedFrom:'0',id:User.me.id},organizer:{name:User.me.name,mail:User.me.mail,acl:'rowi',status:'1',delegatedFrom:'0',id:User.me.id},statusParticipants:{accepted:0,cancelled:0,tentative:0,unanswered:emails.length},location:'',attendee:$.map(emails,function(mail){var contact=false;var decoded=Encoder.htmlDecode(mail);var newAttendeeName="";var name=decoded.match(/"([^"]*)"/)?decoded.match(/"([^"]*)"/)[1]:'';var mail=decoded.match(/<([^<]*)>[\s]*$/)?decoded.match(/<([^<]*)>[\s]*$/)[1].toLowerCase():decoded;var user=DataLayer.get('user',["=","mail",mail],true);if($.type(user)=="array")
+user=user[0];if(user!=''){if(User.me.mail==user.mail)
+return(null);user.isExternal=(!!user&&!(!!user.isExternal))?0:1;return DataLayer.merge({name:user.name,mail:user.mail,acl:'r',delegatedFrom:'0',status:'4',isExternal:user.isExternal},!!user.id?{id:DataLayer.put('participant',{user:user.id,isExternal:user.isExternal})}:{id:DataLayer.put('participant',{user:user})});}else if(mail.match(/[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])/)){var userId=DataLayer.put('user',{name:name,mail:mail,isExternal:'1'});var newAttendeeId=DataLayer.put('participant',{user:userId,isExternal:'1'});return{id:newAttendeeId,name:name,mail:mail,acl:'r',delegatedFrom:'0',status:'4',isExternal:'1'};}else
+return(null);})};schedulable=DataLayer.merge(schedulable,type=='event'?{calendar:User.preferences.defaultCalendar?User.preferences.defaultCalendar:Calendar.calendars[0],calendars:Calendar.calendars}:{group:Calendar.groups[0].id,groups:Calendar.groups,percentage:0,isOrganizer:true});return schedulable;}
+function import_implements_calendar(){if(typeof(Encoder)=="undefined"){$.ajax({url:"../prototype/modules/calendar/js/load.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/modules/calendar/js/map.disponibility.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/modules/calendar/js/helpers.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/modules/calendar/js/task.helpers.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/plugins/encoder/encoder.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/plugins/jquery.spinner/jquery.spinner.min.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});$.ajax({url:"../prototype/plugins/fullcalendar/fullcalendar.js",async:false,beforeSend:function(xhr){xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});DataLayer.dispatchPath="../prototype/";}}
+function select_import_folder(){var imgExtensions=new Array("eml","zip");var inputFile=document.form_import.file_1;if(!inputFile.value){alert(get_lang('File extension forbidden or invalid file')+'.');return false;}
+var fileExtension=inputFile.value.split(".");fileExtension=fileExtension[(fileExtension.length-1)];var deniedExtension=true;for(var i=0;i<imgExtensions.length;i++){if(imgExtensions[i].toUpperCase()==fileExtension.toUpperCase()){deniedExtension=false;break;}}
+if(deniedExtension){alert(get_lang('File extension forbidden or invalid file')+'.');return false;}
+arrayJSWin['import_window'].close();connector.loadScript('wfolders');if(typeof(wfolders)=="undefined")
+setTimeout('select_import_folder()',500);else
+wfolders.makeWindow('null','import');}
+function decodeOwner(){owner=User.me.id;var imapBox=openTab.imapBox[currentTab].split(cyrus_delimiter);if(imapBox.length>1){var user=DataLayer.get('user',{filter:['=','uid',imapBox[1]]});owner=$.isArray(user)?user[0].id:user.id;}
+return owner;}
+function import_calendar(data){var import_url='$this.db_functions.import_vcard&msg_folder='+data;var logUser;var up;var owner;function handler_import_calendar(data){if(data===true){write_msg(get_lang("The event was imported successfully."));}
+else if(data['url'])
+{var form=document.createElement("form");form.setAttribute("action",DEFAULT_URL+data['url']+'&isPost=true');form.setAttribute("method","POST");document.body.appendChild(form);form.submit();}
+else
+write_msg(get_lang(data));}
+if(defaultCalendar=="expressoCalendar"&&$("#expressoCalendarid")[0]){import_implements_calendar();$("#import-dialog").dialog({autoOpen:false,height:220,modal:true,resizable:false,open:function(event,ui){if(typeof(shortcut)!='undefined')shortcut.disabled=true;},close:function(event,ui){event.stopPropagation();if(typeof(shortcut)!='undefined')shortcut.disabled=false;},closeOnEscape:true});$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(),async:false,success:function(data){data=connector.unserialize(data);var createDialog=function(typeImport,propaget){if(typeof(typeImport)=="object"){var calendarIds=!!typeImport.calendar?typeImport.calendar:Calendar[typeImport.type];typeImport=typeImport.action;}
+switch(parseInt(typeImport)){case 1:case 7:case 10:$("#select-agenda").html('');var options='';if(calendarIds){for(var i=0;i<calendarIds.length;i++)
+options+='<option value="'+calendarIds[i]+'">'+Calendar.signatureOf[calendarIds[i]].calendar.name+'</option>'}
+$("#select-agenda").append(options);$("#select-agenda").css("display","block");$("#import-dialog").dialog({buttons:{Cancel:function(){$(this).dialog("close");},"Importar":function(){$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner()+'&cirus_delimiter='+cyrus_delimiter,success:function(msg){var alt=((msg=connector.unserialize(msg))=="ok")?"Importado com sucesso para ":"Ocorreu um erro ao importar o evento/tarefa para a agenda ";alert(alt+$("#select-agenda option:selected").text());}});$(this).dialog("close");}}});if(typeImport==7){$("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change');$("#import-dialog").find('#select-status').attr('disabled','disabled');}
+break;case 3:$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&selected=true',success:function(msg){alert(((connector.unserialize(msg))=="ok")?"Seu evento/tarefa foi removido ":"Ocorreu um erro ao remover o evento/tarefa");}});return;break;case 5:$.ajax({url:'controller.php?action='+import_url+'&from_ajax=true&selected=true&cirus_delimiter='+cyrus_delimiter,success:function(msg){alert(((connector.unserialize(msg))=="ok")?"Seu evento/tarefa foi Atualizado com sucesso":"Ocorreu um erro ao atualizar evento/tarefa");}});return;break;case 6:var acceptedSuggestion=confirm("Deseja atualizar o evento/tarefa de acordo com a sugestão ?");$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value+'&uidAccount='+decodeOwner(),success:function(msg){if(acceptedSuggestion)
+alert(((connector.unserialize(msg))=="ok")?"Evento/tarefa atualizado com sucesso ":"Ocorreu um erro ao atualizar o evento");}});return;break;case 9:alert('Seu evento/tarefa não possui alterações!');return;break;case 11:alert('Este evento/tarefa já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!');return;break;default:up=true;$("#select-agenda").css("display","none");$("#import-dialog").children("p:first-child").css("display","none");$("#import-dialog").dialog({height:160,title:'Atualizar Evento/Tarefa',buttons:{Cancel:function(){$(this).dialog("close");},"Atualizar":function(){$.ajax({url:"controller.php?action="+import_url+'&from_ajax=true&cirus_delimiter='+cyrus_delimiter+'&selected='+(parseInt(typeImport)==2||parseInt(typeImport)==4?'true':$("#select-agenda option:selected").val())+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(),success:function(msg){alert(((msg=connector.unserialize(msg))=="ok")?"Atualizado com sucesso":"Ocorreu um erro ao atualizar o evento");}});$(this).dialog("close");}},close:function(event,ui)
+{if(typeof(shortcut)!='undefined')shortcut.disabled=false;},open:function(event,ui)
+{if(typeof(shortcut)!='undefined')shortcut.disabled=true;}});$(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar");}
+$("#import-dialog").dialog("open");};createDialog(data,true);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+else
+{if(confirm(get_lang("Do you confirm this import to your Calendar?"))){cExecute(import_url+"&from_ajax=true",handler_import_calendar);}}}
+function open_msg_part(data){var handler_open_msg_part=function(data)
+{if(data.append==1)
+{proxy_mensagens.get_msg(data.msg_number,data.msg_folder,false,show_msg);partMsgs.push(data.msg_number);}
+else
+write_msg(data.append);}
+cExecute('$this.imap_functions.ope_msg_part&msg_folder='+data+'&save_folder=INBOX'+cyrus_delimiter+special_folders['Trash'],handler_open_msg_part);}
+function hack_sent_queue(data,rowid_message){if(data.success!=true){queue_send_errors=true;expresso_local_messages.set_problem_on_sent(rowid_message,data);}
+else{expresso_local_messages.set_as_sent(rowid_message);if(document.getElementById('_action')){el=document.getElementById('_action');father=el.parentNode;father.removeChild(el);}
+send_mail_from_queue(false);}}
+function send_mail_from_queue(first_pass){if(first_pass)
+modal('send_queue');var num_msgs=expresso_local_messages.get_num_msgs_to_send();if(num_msgs<=0){close_lightbox();return;}
+document.getElementById('text_send_queue').innerHTML=get_lang('Number of messages to send:')+' '+num_msgs;var handler_send_queue_message=function(data,rowid_message){hack_sent_queue(data,this.ID_tmp);}
+var msg_to_send=expresso_local_messages.get_form_msg_to_send();if(!is_ie)
+ID_tmp=msg_to_send.rowid.value;else{for(var i=0;i<msg_to_send.length;i++){if(msg_to_send.elements[i].name=='rowid'){ID_tmp=msg_to_send.elements[i].value;break;}}}
+expresso_local_messages.set_as_sent(ID_tmp);cExecuteForm("$this.imap_functions.send_mail",msg_to_send,handler_send_queue_message,"queue_"+ID_tmp);send_mail_from_queue(false);}
+function check_mail_in_queue(){var num_msgs=expresso_local_messages.get_num_msgs_to_send();if(num_msgs>0){control=confirm(get_lang('You have messages to send. Want you to send them now?'));if(control){send_mail_from_queue(true);}
+return true;}
+else{return false;}}
+function force_check_queue(){if(!check_mail_in_queue()){write_msg(get_lang("No messages to send"));}}
+function create_new_local_folder(parentFolderId,name){parentFolderId=parentFolderId.split("_");var parentName=parentFolderId[2];expresso_mail_archive.createFolder(parentName,name);}
+function create_new_folder(name_folder,base_path){if(preferences.imap_max_folders){if(cp_tree1.length==parseInt(preferences.imap_max_folders)){$(".folders-loading").removeClass("folders-loading");cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);return write_msg(get_lang("Limit reached folders"));}}
+$.ajax({url:"controller.php?action=$this.imap_functions.create_mailbox",type:"POST",async:false,data:"newp="+name_folder+"&base_path="+base_path,success:function(data){data=connector.unserialize(data);if(data=="Mailbox already exists"){write_msg(get_lang("Mailbox already exists"));}else if(data.substring(data.indexOf("Permission"),data.length)=="Permission denied"){$(".folders-loading").removeClass("folders-loading");cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);return write_msg(get_lang("Permission denied"));}
+cExecute("$this.imap_functions.get_folders_list&onload=true",update_menu);},beforeSend:function(jqXHR,settings){connector.showProgressBar();},complete:function(jqXHR,settings){connector.hideProgressBar();}});}
+function searchEmail(emailString){var arrayInvalidEmails=new Array();arrayInvalidEmails[1]='';var email;var arrayEmailsFull=new Array();arrayEmailsFull=emailString.split(',');var er_Email=new RegExp("<(.*?)>");var er_ValidaEmail=new RegExp("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$");for(i=0;i<arrayEmailsFull.length;i++){email=er_Email.exec(arrayEmailsFull[i]);tempEmail=email==null?arrayEmailsFull[i]:email[1];tempEmail=tempEmail.replace(/^\s+|\s+$/g,"");if(tempEmail!=''){singleEmail=er_ValidaEmail.exec(tempEmail);if(singleEmail==null){arrayInvalidEmails[0]=true;arrayInvalidEmails[1]+=(email==null?arrayEmailsFull[i]:email[1])+"";}}}
+return arrayInvalidEmails;}
+function reports_window(currentTab){ID_msg=currentTab.substr(0,currentTab.indexOf("_"));report_wind.make_report_window(ID_msg);}
+DataLayer.codec("message","detail",{decoder:function(form){var border_id=form.abaID;var user_selected=$('#content_id_'+border_id).find('.from-select option:selected').text();var str_begin_name=user_selected.indexOf('<')+1;var str_end_name=user_selected.indexOf('@');var user_selected_name=user_selected.substring(str_begin_name,str_end_name);if(user_selected.length>0)
+var user_selected_email=user_selected.match(/<([^<]*)>[\s]*$/)[1];else
+var user_selected_email=User.me.mail;if(user_selected_email==User.me.mail){var prefix='INBOX';}else{var prefix='user'+cyrus_delimiter+user_selected_name;DataLayer.remove('folder',false);DataLayer.get('folder');var has_folder=DataLayer.get('folder',prefix+cyrus_delimiter+draftsfolder);if(!has_folder){create_new_folder(draftsfolder,prefix);}}
+var folder_id=(openTab.imapBox[border_id]&&openTab.type[border_id]<6)?openTab.imapBox[border_id]:prefix+cyrus_delimiter+draftsfolder;form.folder=folder_id;form.body=RichTextEditor.getData("body_"+border_id);form.type=RichTextEditor.plain[border_id]?'plain':'html';form.attachments=listAttachment(border_id);form.uidsSave=uidsSave[border_id].toString();return(form);},encoder:function(pref){return(pref);}});DataLayer.codec("mailAttachment","detail",{decoder:function(evtObj){if(notArray=$.type(evtObj)!=="array")
+evtObj=[evtObj];var res=$.map(evtObj,function(form){return[$.map(form.files,function(files){return{source:files,disposition:form['attDisposition'+form.abaID]};})];});return notArray?res[0]:res;},encoder:function(){}});function formatBytes(bytes){if(bytes>=1000000000){return(bytes/1000000000).toFixed(2)+' GB';}
+if(bytes>=1000000){return(bytes/1000000).toFixed(2)+' MB';}
+if(bytes>=1000){return(bytes/1000).toFixed(2)+' KB';}
+return bytes+' B';};function truncate(text,size){var result=text;if(text.length>size){result=text.substring(0,size)+'...';}
+return result;}
+function break_comma(originalText){var quotesMarks=false;var completeString="";var brokenEmails=new Array();originalText+=",";for(i=0;i<originalText.length;i++){var character=originalText.substr(i,1);if(character=="\""){quotesMarks=!quotesMarks;}
+if(!quotesMarks){if(character==","){brokenEmails.push(completeString);completeString="";}
+else
+completeString+=character;}
+else
+completeString+=character;}
+return brokenEmails;}
+DataLayer.links('message');DataLayer.poll('message',30);function services_retry(){try{connector.purgeCache();if((expresso_mail_archive.enabled==null)&&(expresso_mail_archive.timer==null)&&(expresso_mail_archive.counter>0)){connector.hideProgressBar();write_msg(get_lang('Sorry, but you need to reload this web page. Click at reload page at web browsing top navigation.'));return;}
+if(arguments.length==0){write_msg(get_lang('Trying to communicate with Mail Archiver...'));}
+connector.showProgressBar();var head=document.getElementById('send_queue');var script_xdr=document.createElement('script');var script_xdr_tag_id='mail_archiver_retry_xdr';var script_request=document.createElement('script');var script_request_tag_id='mail_archiver_retry_request';var script_cors=document.createElement('script');var script_cors_tag_id='mail_archiver_retry_cors';var script_utils=document.createElement('script');var script_utils_tag_id='mail_archiver_retry_utils';if(document.getElementById(script_xdr_tag_id)){document.getElementById(script_xdr_tag_id).parentNode.removeChild(document.getElementById(script_xdr_tag_id));}
+if(document.getElementById(script_request_tag_id)){document.getElementById(script_request_tag_id).parentNode.removeChild(document.getElementById(script_request_tag_id));}
+if(document.getElementById(script_cors_tag_id)){document.getElementById(script_cors_tag_id).parentNode.removeChild(document.getElementById(script_cors_tag_id));}
+if(document.getElementById(script_utils_tag_id)){document.getElementById(script_utils_tag_id).parentNode.removeChild(document.getElementById(script_utils_tag_id));}
+script_xdr.type='text/javascript';script_xdr.src=mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/arcservutil/cxf-addon-xdr-adapter.js';script_xdr.id=script_xdr_tag_id;head.appendChild(script_xdr);script_request.type='text/javascript';script_request.src=mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/arcservutil/cxf-addon-cors-request-object.js';script_request.id=script_request_tag_id;head.appendChild(script_request);script_cors.type='text/javascript';script_cors.src=mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/arcservutil/cxf-addon-cors-utils.js';script_cors.id=script_cors_tag_id;head.appendChild(script_cors);script_utils.type='text/javascript';script_utils.src=mail_archive_protocol+'://'+mail_archive_host+':'+mail_archive_port+'/arcserv/ArchiveServices?js&nojsutils';script_utils.id=script_utils_tag_id;head.appendChild(script_utils);ttintval=window.setTimeout('check_services_restart()',1000);}
+catch(e){write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));connector.hideProgressBar();check_services_tryouts=1;}}
+function check_services_restart(){try{write_msg(get_lang('Wait: attempt %1 from %2...',check_services_tryouts,check_services_tryouts_limit));if(check_services_tryouts<=5){try{ArchiveServices=new web_service_mailarchiver_serpro__ArchiveServices();ArchiveServices.url=mail_archive_protocol+"://"+mail_archive_host+":"+mail_archive_port+"/arcserv/ArchiveServices";window.clearInterval(ttintval);expresso_mail_archive.Restart(expresso_mail_archive);}
+catch(e){check_services_tryouts++;window.clearInterval(ttintval);ttintval=window.setTimeout('services_retry(true)',1);}}
+else{write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));connector.hideProgressBar();check_services_tryouts=1;}}
+catch(e){write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!'));connector.hideProgressBar();check_services_tryouts=1;}}
