// Tempo do auto refresh (em milisegundos) var time_refresh = 300000; // tempo do auto save (em milisegundos) // 20000 = 20 segundos var autosave_time = 20000; function init(){ if (!is_ie) Element('tableDivAppbox').width = '100%'; var save_contacts = function(data){ contacts = data; } var save_preferences = function(data){ preferences = data; 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.outoffice == "1") write_msg(get_lang("Attention, you are in out of office mode."), true); ConstructMenuTools(); cExecute ("$this.imap_functions.get_folders_list", update_menu); } var handler_automatic_trash_cleanness = function(data){ if (data != false){ write_msg(data.length +' '+ Element('txt_clear_trash').value); } } // Versão Element('divAppboxHeader').innerHTML = title_app; // Get cyrus delimiter cyrus_delimiter = Element('cyrus_delimiter').value; cExecute ("$this.db_functions.get_dropdown_contacts", save_contacts); cExecute ("$this.functions.get_preferences", save_preferences); setTimeout('auto_refresh()', time_refresh); } function disable_field(field,condition) { var comando = "if ("+condition+") { document.getElementById('"+field.id+"').disabled=true;} else { document.getElementById('"+field.id+"').disabled=false; }"; eval(comando); } /* função que remove todos os anexos... */ function remove_all_attachments(folder,msg_num) { var call_back = function(data) { if(!data.status) { //Em caso de erros, o status vem como false e o texto do erro vem em msg. alert(data.msg); } else { mail_msg = Element("tbody_box"); msg_to_delete = Element(data.msg_num); if (msg_to_delete) { if ( (msg_to_delete.style.backgroundColor != '') && (preferences.use_shortcuts == '1') ) select_msg('null', 'down'); mail_msg.removeChild(msg_to_delete); }//Remove o email com anexos da lista de emails. write_msg(get_lang("Attachments removed"));//indica que os anexos foram removidos refresh(); //dá um refresh na lista de emails, para que apareça o novo email sem anexos delete_border(data.msg_num+'_r','false');//fecha a tela do email já removido. } }; if (confirm(get_lang("delete all attachments confirmation"))) cExecute ("$this.imap_functions.remove_attachments&folder="+folder+"&msg_num="+msg_num, call_back); //chamada em ajax para a função de remover anexos. } function watch_changes_in_msg(border_id) { if (document.getElementById('border_id_'+border_id)) { function keypress_handler () { away=false; var save_link = Element("save_message_options_"+border_id); save_link.onclick = function onclick(event) { openTab.toPreserve[border_id] = true; save_msg(border_id); } ; save_link.className = 'message_options'; }; var obj = document.getElementById('body_'+border_id).contentWindow.document; if ( obj.addEventListener ) obj.addEventListener('keypress', keypress_handler, false); else if ( obj.attachEvent ) obj.attachEvent('onkeypress', keypress_handler); var subject_obj = document.getElementById('subject_'+border_id); 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 = document.getElementById('to_'+border_id); if ( to_obj.addEventListener ) to_obj.addEventListener('keypress', keypress_handler, false); else if ( to_obj.attachEvent ) to_obj.attachEvent('onkeypress', keypress_handler); } } function show_msg_img(msg_info){ delete_border(msg_info.msg_number+"_r"); msg_info.showImg = true; show_msg(msg_info); } 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.status == 'false'){ eval(msg_info.command_to_exec); } else{ if (preferences.use_shortcuts == '1') select_msg(msg_info.msg_number, 'null'); // Call function to draw message var id_msg_read = msg_info.msg_number +"_r"; // If needed, delete old border if (openTab.type[currentTab] == 2 || openTab.type[currentTab] == 3) delete_border(currentTab,'false'); if(Element("border_id_" + id_msg_read)) alternate_border(id_msg_read); else { var border_id = create_border(msg_info.subject, id_msg_read); if(border_id) { openTab.type[border_id] = 2; 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); } } else return; } var domains = ""; if ((msg_info.DispositionNotificationTo) && (!msg_is_read(msg_info.msg_number) || (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 (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?",msg_info.DispositionNotificationTo), ""); if (confNotification) cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), handler_sendNotification); } //Change msg class to read. if (!msg_is_read(msg_info.msg_number)) { set_msg_as_read(msg_info['msg_number'], true); if (msg_info.cacheHit) set_message_flag(msg_info.msg_number, "seen"); // avoid caducous (lazy) data } } } function auto_refresh(){ refresh(preferences.alert_new_msg); setTimeout('auto_refresh()', time_refresh); } function refresh(alert_new_msg){ var handler_refresh = function(data){ if(!verify_session(data)) return; var box = Element("tbody_box"); if (box.childNodes.length == 0) { td_info = document.createElement("H3"); td_info.setAttribute("height", "25%"); td_info.setAttribute("background", "#FFF"); td_info.setAttribute("id", "msg_info"); td_info.align = "center"; td_info.innerHTML = get_lang("This mail box is empty"); box.appendChild(td_info); } if (data.length > 0){ var msg_info = document.getElementById('msg_info') if (msg_info != null) main.removeChild(msg_info); table_element = Element("table_box"); var box = Element("tbody_box"); table_element.appendChild(box); for (var i=0; i 0) alert(get_lang("You have %1 new", data['new_msgs'])+" "+(data['new_msgs'] > 1 ? get_lang("messages") : get_lang("message")) +"!"); if(data.new_msgs > 0){ Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + parseInt(data.new_msgs); //refresh tab title update_quota(current_folder); } //if(data.new_msgs > 0 || data.msgs_to_delete.length > 0) // purgeCache(); } purgeCache(); update_menu(); } msg_range_end = (current_page*preferences.max_email_per_page); msg_range_begin = (msg_range_end-(preferences.max_email_per_page)+1); //Get element tBody. main = Element("tbody_box"); if(!main) return; // Get all TR (messages) in tBody. 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)); cExecute ("$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, handler_refresh); } function delete_msgs(folder, msgs_number, border_ID, show_success_msg) { if (arguments.length < 4){ show_success_msg = true; } if (folder == 'null') folder = current_folder; if(openTab.type[currentTab] == 1) return move_search_msgs('content_id_'+currentTab); if(currentTab.toString().indexOf("_r") != -1){ msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); } if ((parseInt(preferences.save_deleted_msg)) && (folder!='INBOX'+cyrus_delimiter+trashfolder)){ move_msgs2(folder, msgs_number, border_ID, 'INBOX'+cyrus_delimiter+trashfolder,trashfolder,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') { var all_messages = mail_msg.childNodes; //Last msg is selected 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); } } } var msg_to_delete; for (var i=0; i 1){ if (parseInt(preferences.delete_and_show_previous_message)) { delete_border(currentTab,'false'); show_msg(data.previous_msg); } else delete_border(currentTab,'false'); } Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length; refresh(); } if (msgs_number == 'selected') msgs_number = get_selected_messages(); 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+"&reuse_border="+border_ID+"&get_previous_msg="+preferences.delete_and_show_previous_message, handler_delete_msgs); else write_msg(get_lang('No selected message.')); } function move_search_msgs(border_id, new_folder, new_folder_name){ var selected_messages = ''; var temp_msg; var main_list = Element("tbody_box_"+currentTab.substr(7)).childNodes; for (j = 0; j < main_list.length; j++) { var check_box = main_list[j].firstChild.firstChild; if(check_box && check_box.checked) { if (proxy_mensagens.is_local_folder(main_list[j].name)) { alert(get_lang("You cant manipulate local messages on search")); return; } selected_messages += main_list[j].id + ','; } } selected_messages = selected_messages.substring(0,(selected_messages.length-1)); var handler_move_search_msgs = function(data){ if(!data || !data.msgs_number) return; else if(data.deleted) { 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.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)); } selected_messages = selected_messages.split(","); for (i = 0; i < selected_messages.length; i++){ var tr = Element(selected_messages[i]); tr.parentNode.removeChild(tr); } purgeCache(); } 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]); selected_param += ','+tr.name+';'+tr.id; } } else { var tr=Element(selected_messages); selected_param=tr.name+';'+tr.id; } var params = ""; if (!new_folder && parseInt(preferences.save_deleted_msg)){ new_folder = 'INBOX'+cyrus_delimiter+trashfolder; new_folder_name = trashfolder; params = "&delete=true"; } params += "&selected_messages="+url_encode(selected_param); if(new_folder) { 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){ if (! folder || folder == 'null') folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : current_folder; 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" : trashfolder; alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.', move_to_folder)); connector.loadScript('TreeShow'); ttree.FOLDER = 'root'; ttreeBox.new_past(move_to_folder); return false; }else{ alert(get_lang('Error moving message.')+":\n"+data); return false; } //Este bloco verifica as permissoes ACL sobre pastas compartilhadas if(data.status == false){ alert(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 (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; cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg); } else delete_border(currentTab,'false'); } else delete_border(currentTab,'false'); if(msg_to_delete) mail_msg.removeChild(msg_to_delete); 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; //Last msg is selected 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 0 || msgs_number.length > 0) cExecute ("$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="+preferences.delete_and_show_previous_message, handler_move_msgs); else write_msg(get_lang('No selected message.')); } function move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name) { move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,true); } function archive_msgs(folder,folder_dest,id_msgs) { if(proxy_mensagens.is_local_folder(folder)) { write_msg(get_lang("You cant archive local mails")); return; } var has_local_messages_before = expresso_local_messages.has_local_mails(); //vejo se já tinha mensagens locais var handler_arquivar_mensagens = function(data) { var sucess = true; var temp; var msgs_to_remove = new Array(); var update_tree; for (var i = 0; i < data.length; i++) { msg_info = connector.unserialize(data[i]); if ( folder == 'INBOX/Lixeira/tmpMoveToLocal' ) msg_info.msg_folder += (Date.parse(new Date)); temp = expresso_local_messages.insert_mail(msg_info, msg_info['header'],msg_info['array_attach'],folder_dest ); if ( Element("check_box_message_" + msg_info.msg_number) ) Element("check_box_message_" + msg_info.msg_number).checked = false; if(!temp) sucess = false; else msgs_to_remove.push(msg_info.msg_number);//As mensagens arquivadas devem ser removidas, caso o usu�rio tenha isso configurado. if ( Element(msg_info.msg_number) ) remove_className(Element(msg_info.msg_number), 'selected_msg'); if ( tree_folders._selected.id.indexOf( 'local_' ) == 0 || folder.indexOf( 'INBOX/Lixeira/tmpMoveToLocal' ) == 0 ) { openTab.imapBox[0] = ''; tree_folders.getNodeById( 'local_Inbox' )._select( ); change_folder('local_Inbox','Inbox') } } if (preferences.keep_archived_messages == 0) { //Remove as mensagens delete_msgs(folder,msgs_to_remove,'null',false); } update_tree=(!has_local_messages_before) && expresso_local_messages.has_local_mails(); Element('chk_box_select_all_messages').checked = false; if(update_tree) ttreeBox.update_folder(); else update_menu(); if(sucess) write_msg(get_lang("selected messages have been archived")); else write_msg(get_lang("at least, one of selected mails is already archived, expresso tried to archive the others, check them later")); } if(!id_msgs) id_msgs = get_selected_messages(); if (parseInt(id_msgs) > 0 || id_msgs.length > 0) cExecute("$this.imap_functions.get_info_msgs&folder=" + folder + "&msgs_number=" + id_msgs , handler_arquivar_mensagens); else write_msg(get_lang('No selected message.')); } function get_selected_messages(){ main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; if (! main) main = Element("tbody_box"); // Get all TR (messages) in tBody. main_list = main.childNodes; var selected_messages = ''; var selected_messages_by_shortcuts = ''; var j = 0; for (j; j<(main_list.length); j++) { check_box = Element("check_box_message_"+main_list[j].id); if ( (check_box) && (check_box.checked) ) selected_messages += main_list[j].id + ','; if (preferences.use_shortcuts == '1') { if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') ) { selected_messages_by_shortcuts += main_list[j].id + ','; } } } selected_messages = selected_messages.substring(0,(selected_messages.length-1)); if (preferences.use_shortcuts == '1') { selected_messages_by_shortcuts = selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1)); var array_selected_messages_by_shortcuts = selected_messages_by_shortcuts.split(","); var array_selected_messages = selected_messages.split(","); if ((array_selected_messages.length <= 1) && (array_selected_messages_by_shortcuts.length > 1)) { return selected_messages_by_shortcuts; } } if (selected_messages == '') return false; else return selected_messages; } 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){ var new_border_ID = draw_new_message(parseInt(border_ID)); if (new_border_ID == false) return false; openTab.type[new_border_ID] = tabTypes[type]; // Salva a pasta da mensagem respondida ou encaminhada: 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); }//Fim. 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(/</gi,"<"); data.to = data.to.replace(/>/gi,">"); } else { if (document.getElementById("from_values_" + border_ID)) { data.to = document.getElementById("from_values_" + border_ID).value; data.to = data.to.replace(/</gi,"<"); data.to = data.to.replace(/>/gi,">"); } } if (document.getElementById("to_values_" + border_ID)){ data.to_all = document.getElementById("to_values_" + border_ID).value; data.to_all = data.to_all.replace(/\n/gi," "); data.to_all = data.to_all.replace(/</gi,"<"); data.to_all = data.to_all.replace(/>/gi,">"); var _array_to_all = data.to_all.split(","); } } if (document.getElementById("cc_" + border_ID)){ data.cc = document.getElementById("cc_values_" + border_ID).value; data.cc = data.cc.replace(/</gi,"<"); data.cc = data.cc.replace(/>/gi,">"); } if (document.getElementById("subject_" + border_ID)) data.subject = document.getElementById("subject_" + border_ID).innerHTML; if (document.getElementById("body_" + border_ID)) data.body = document.getElementById("body_" + border_ID).innerHTML; 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 = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "
"); switch(type){ case "reply_without_history": Element("to_" + new_border_ID).value = data.to; title = "Re: " + data.subject; Element("subject_" + new_border_ID).value = "Re: " + data.subject; useOriginalAttachments(new_border_ID,border_ID); var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1"){ body.contentWindow.document.write("" + "
" + signature + ""); } else{ body.contentWindow.document.write(""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); if (is_ie) body.contentWindow.document.onkeypress = function(){if(body.contentWindow.event.keyCode == 13){changeEnterKey(body.contentWindow)}}; msg_reply_from = document.createElement('input'); msg_reply_from.id = "msg_reply_from_" + new_border_ID; msg_reply_from.type = "hidden"; msg_reply_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_reply_from); break; case "reply_with_history": title = "Re: " + data.subject; Element("subject_" + new_border_ID).value = "Re: " + data.subject; Element("to_" + new_border_ID).value = data.to; useOriginalAttachments(new_border_ID,border_ID); block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + "" + block_quoted_body + ""); } else { body.contentWindow.document.write(""+block_quoted_body+""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); if (is_ie) body.contentWindow.document.onkeypress = function(){if(body.contentWindow.event.keyCode == 13){changeEnterKey(body.contentWindow)}}; msg_reply_from = document.createElement('input'); msg_reply_from.id = "msg_reply_from_" + new_border_ID; msg_reply_from.type = "hidden"; msg_reply_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_reply_from); config_events( body.contentWindow.document, "onkeyup", function( e ) { // Break the indentation to answer an email when the Enter key is pressed if ( e.keyCode == 13 && !e.shiftKey ) { // Hiding error that occurs in Internet Explorer try { var selection = null, range = null; var iframeWindow = body.contentWindow; var iframeDocument = iframeWindow.document; if( typeof iframeWindow.getSelection != 'undefined' ) { selection = iframeWindow.getSelection( ); //if ( typeof selection.getRangeAt != 'undefined' ) // range = selection.getRangeAt( 0 ); //else if ( typeof selection.baseNode != 'undefined' ) //{ // range = iframeDocument.createRange( ); // range.setStart( selection.baseNode, selection.baseOffset ); // range.setEnd( selection.extentNode, selection.extentOffset ); // if ( range.collapsed ) // { // range.setStart( selection.extentNode, selection.extentOffset ); // range.setEnd( selection.baseNode, selection.baseOffset ); // } //} range = selection.getRangeAt( 0 ); if ( range.commonAncestorContainer != 'body' ) { var indent = false; var node = range.commonAncestorContainer.parentNode; while ( node ) { if ( node.nodeName.toLowerCase( ) == 'blockquote' ) indent = true; node = node.parentNode; } if ( indent ) { var rangecopy = range.cloneRange( ); rangecopy.collapse( true ); range.deleteContents( ); var newline = iframeDocument.createElement( 'br' ); rangecopy.insertNode( newline ); iframeWindow.focus( ); body.contentWindow.document.execCommand( 'outdent', false, '' ); } } } else if ( typeof iframeDocument.selection != 'undefined' ) { // @TODO: IE code } else { return false; } } catch(e){alert(e);} } } ); break; case "reply_to_all_without_history": // delete user email from to_all array. data.to_all = new Array(); var j = 0; for(i = 0; i < _array_to_all.length; i++) { if(_array_to_all[i].lastIndexOf(Element("user_email").value) == "-1"){ data.to_all[j++] = _array_to_all[i]; } } data.to_all = data.to_all.join(","); title = "Re: " + data.subject; Element("subject_" + new_border_ID).value = "Re: " + data.subject; Element("to_" + new_border_ID).value = data.to; Element("to_" + new_border_ID).value += ', ' + data.to_all; if (data.cc){ Element("cc_" + new_border_ID).value = data.cc; Element("a_cc_link_" + new_border_ID).style.display='none'; Element("tr_cc_" + new_border_ID).style.display=''; Element('space_link_' + new_border_ID).style.display='none'; } useOriginalAttachments(new_border_ID,border_ID); var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + ""); } else { body.contentWindow.document.write(""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); if (is_ie) body.contentWindow.document.onkeypress = function(){if(body.contentWindow.event.keyCode == 13){changeEnterKey(body.contentWindow)}}; msg_reply_from = document.createElement('input'); msg_reply_from.id = "msg_reply_from_" + new_border_ID; msg_reply_from.type = "hidden"; msg_reply_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_reply_from); break; case "reply_to_all_with_history": // delete user email from to_all array. data.to_all = new Array(); var j = 0; for(i = 0; i < _array_to_all.length; i++) { if(_array_to_all[i].lastIndexOf(Element("user_email").value) == "-1"){ data.to_all[j++] = _array_to_all[i]; } } data.to_all = data.to_all.join(","); title = "Re: " + data.subject; Element("to_" + new_border_ID).value = data.to; Element("to_" + new_border_ID).value += ', ' + data.to_all; if (data.cc){ document.getElementById("cc_" + new_border_ID).value = data.cc; document.getElementById("a_cc_link_" + new_border_ID).style.display='none'; document.getElementById("tr_cc_" + new_border_ID).style.display=''; document.getElementById('space_link_' + new_border_ID).style.display='none'; } document.getElementById("subject_" + new_border_ID).value = "Re: " + data.subject; useOriginalAttachments(new_border_ID,border_ID); block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); var body = document.getElementById("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + "" + block_quoted_body + ""); } else { body.contentWindow.document.write(""+block_quoted_body+""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); if (is_ie) body.contentWindow.document.onkeypress = function(){if(body.contentWindow.event.keyCode == 13){changeEnterKey(body.contentWindow)}}; msg_reply_from = document.createElement('input'); msg_reply_from.id = "msg_reply_from_" + new_border_ID; msg_reply_from.type = "hidden"; msg_reply_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_reply_from); config_events( body.contentWindow.document, "onkeyup", function( e ) { // Break the indentation to answer an email when the Enter key is pressed if ( e.keyCode == 13 && !e.shiftKey ) { // Hiding error that occurs in Internet Explorer try { var selection = null, range = null; var iframeWindow = body.contentWindow; var iframeDocument = iframeWindow.document; if( typeof iframeWindow.getSelection != 'undefined' ) { selection = iframeWindow.getSelection( ); //if ( typeof selection.getRangeAt != 'undefined' ) // range = selection.getRangeAt( 0 ); //else if ( typeof selection.baseNode != 'undefined' ) //{ // range = iframeDocument.createRange( ); // range.setStart( selection.baseNode, selection.baseOffset ); // range.setEnd( selection.extentNode, selection.extentOffset ); // if ( range.collapsed ) // { // range.setStart( selection.extentNode, selection.extentOffset ); // range.setEnd( selection.baseNode, selection.baseOffset ); // } //} range = selection.getRangeAt( 0 ); if ( range.commonAncestorContainer != 'body' ) { var indent = false; var node = range.commonAncestorContainer.parentNode; while ( node ) { if ( node.nodeName.toLowerCase( ) == 'blockquote' ) indent = true; node = node.parentNode; } if ( indent ) { var rangecopy = range.cloneRange( ); rangecopy.collapse( true ); range.deleteContents( ); var newline = iframeDocument.createElement( 'br' ); rangecopy.insertNode( newline ); iframeWindow.focus( ); body.contentWindow.document.execCommand( 'outdent', false, '' ); } } } else if ( typeof iframeDocument.selection != 'undefined' ) { // @TODO: IE code } else { return false; } } catch(e){alert(e);} } } ); break; case "forward": data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false; msg_forward_from = document.createElement('input'); msg_forward_from.id = "msg_forward_from_" + new_border_ID; msg_forward_from.type = "hidden"; msg_forward_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_forward_from); title = "Fw: " + data.subject; document.getElementById("subject_" + new_border_ID).value = "Fw: " + data.subject; var divFiles = Element("divFiles_"+new_border_ID); var campo_arquivo if (Element("attachments_" + border_ID)){ var attachments = document.getElementById("attachments_" + border_ID).childNodes; for (var i = (attachments.length > 1 ? 1 : 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; var link_attachment = document.createElement("A"); link_attachment.setAttribute("href", attachments[i].href); link_attachment.innerHTML = attachments[i].innerHTML; if (data.is_local_message) {//Local messages document.getElementById("is_local_forward"+new_border_ID).value = "1"; var tmp = link_attachment.href.substring(link_attachment.href.indexOf("(") + 2);//Pula o parenteses e a aspas tmp = tmp.substring(0, tmp.length - 2);//corta a aspas e o parenteses tmp = replaceAll(tmp,"%20"," "); var tempNomeArquivo = tmp.split("/"); var nomeArquivo = tempNomeArquivo[tempNomeArquivo.length-1]; nomeArquivo = nomeArquivo.substring(0,nomeArquivo.length - 4); //Anexos no gears são todos com extensão .php. tenho que tirar a extensão para ficar o nome real do arquivo. campo_arquivo = addForwardedFile(new_border_ID,nomeArquivo,link_attachment.href); expresso_local_messages.getInputFileFromAnexo(campo_arquivo, tmp); } else { var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); var a_tmp = tmp.split(','); tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; s_tmp = escape(connector.serialize(a_tmp)); divFiles.innerHTML += ""; divFiles.innerHTML += ""; divFiles.appendChild(link_attachment); } } } var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + "" + make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc) + ""); } else { body.contentWindow.document.write(""+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)+""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; if (is_ie) body.contentWindow.document.onkeypress = function(){if(body.contentWindow.event.keyCode == 13){changeEnterKey(body.contentWindow)}}; Element("to_" + new_border_ID).focus(); break; case "new": 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; } } } Element("to_" + new_border_ID).value = _to +','; Element('msg_number').value = ''; } var body = document.getElementById("body_" + new_border_ID); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { config_events( body, 'onload', function( ) { body.contentWindow.document.body.innerHTML += "
" + signature; }); } if (is_ie) body.contentWindow.document.onkeypress = function(){if(body.contentWindow.event.keyCode == 13){changeEnterKey(body.contentWindow)}}; Element("to_" + new_border_ID).focus(); break; case "edit": openTab.imapBox[new_border_ID] = folder_message.value; openTab.toPreserve[new_border_ID] = true; openTab.imapUid[new_border_ID] = parseInt(border_ID.substr(0,border_ID.indexOf("_"))); document.getElementById('font_border_id_'+new_border_ID).innerHTML = data.subject; data.to = Element("to_values_" + border_ID).value; data.to = data.to.replace(/</gi,"<"); data.to = data.to.replace(/>/gi,">"); title = "Edição: "+data.subject; Element("to_" + new_border_ID).value = data.to; if (data.cc){ Element("cc_" + new_border_ID).value = data.cc; Element("space_link_" + new_border_ID).style.display = 'none'; Element("a_cc_link_" + new_border_ID).style.display = 'none'; Element("tr_cc_"+ new_border_ID).style.display = ''; } Element("subject_" + new_border_ID).value = data.subject; var divFiles = Element("divFiles_"+new_border_ID); if (Element("attachments_" + border_ID)){ var attachments = document.getElementById("attachments_" + border_ID).childNodes; for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){ var link_attachment = document.createElement("A"); link_attachment.setAttribute("href", attachments[i].href); link_attachment.innerHTML = attachments[i].innerHTML; var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); var a_tmp = tmp.split(','); tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; s_tmp = escape(connector.serialize(a_tmp)); divFiles.innerHTML += ""; divFiles.appendChild(link_attachment); } } var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); body.contentWindow.document.write(""+data.body+""); body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); if (is_ie) body.contentWindow.document.onkeypress = function(){if(body.contentWindow.event.keyCode == 13){changeEnterKey(body.contentWindow)}}; break; default: } // IM Module Enabled if( window.parent.loadscript ) { config_events( body.contentWindow.document, "onkeypress", loadscript.autoStatusIM ); } if (preferences.auto_save_draft == 1) { openTab.autosave_timer[new_border_ID] = false; config_events(body,'onload', function( ) { config_events( body.contentWindow.document, 'keypress', function( ) { if (openTab.autosave_timer[new_border_ID]) clearTimeout(openTab.autosave_timer[new_border_ID]); openTab.autosave_timer[new_border_ID] = setTimeout("save_msg("+new_border_ID+")", autosave_time); }); }); } //BEGIN Tab event if (preferences.use_shortcuts == '1') { if (is_ie) { body.contentWindow.document.attachEvent('onkeydown', function(event) { if(event.keyCode==27){delete_border(new_border_ID,'false');} if(event.keyCode==9) { Element('to_'+new_border_ID).focus(); Element('send_button_'+new_border_ID).focus(); return false;} }, false); } else { body.contentWindow.document.addEventListener('keypress', function(event) { if(event.keyCode==27){delete_border(new_border_ID,'false');} if(event.keyCode==9) { Element('send_button_'+new_border_ID).focus(); event.preventDefault(); } }, false); } } // END Tab event var offWidth = Element('border_blank').offsetWidth ? Element('border_blank').offsetWidth : Element('border_blank').clientWidth; var resize = false; if (offWidth < 200) { resize = Element("border_id_" + new_border_ID).style.width; } if (title.length > 21){ title = title.substring(0,21) + "..."; } if(resize) title = title.substring(0, parseInt(resize)*0.08); Element("border_id_" + new_border_ID).innerHTML = "
" +title + "
"; return new_border_ID; //Preciso retornar o ID da nova mensagem. } function useOriginalAttachments(new_id_border,old_id_border) { var divFiles = Element("divFiles_"+new_id_border); if (Element("attachments_" + old_id_border)) { var areaOldAttachments = document.createElement("DIV"); areaOldAttachments.id = "area_div_attachments_"+new_id_border; divFiles.appendChild(areaOldAttachments); var optAttachments = document.createElement("A"); optAttachments.setAttribute("href","javascript:void(0)"); optAttachments.tabIndex = -1; optAttachments.innerHTML = get_lang("Original attachments: add")+"
"; areaOldAttachments.appendChild(optAttachments); var divOriginalAttachments = document.createElement("DIV"); divOriginalAttachments.id = "div_attachments_"+new_id_border; optAttachments.onclick = function(){ if(document.getElementById('div_attachments_'+new_id_border)) { areaOldAttachments.removeChild(document.getElementById('div_attachments_'+new_id_border)); optAttachments.innerHTML = get_lang("Original attachments: add")+"
"; } else { areaOldAttachments.appendChild(divOriginalAttachments); optAttachments.innerHTML = get_lang("Original attachments: remove")+"
"; } return false;}; var attachments = document.getElementById("attachments_" + old_id_border).childNodes; for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){ var link_attachment = document.createElement("A"); link_attachment.setAttribute("href", attachments[i].href); link_attachment.innerHTML = attachments[i].innerHTML; var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); var a_tmp = tmp.split(','); tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; s_tmp = escape(connector.serialize(a_tmp)); divOriginalAttachments.innerHTML += ""; divOriginalAttachments.appendChild(link_attachment); } } } // Change the tag

for the tag
on IE function changeEnterKey(win) { var oSel = win.document.selection.createRange(); oSel.pasteHTML("
"); win.event.cancelBubble = true; win.event.returnValue=false; oSel.select(); oSel.moveEnd("character",1); oSel.moveStart("character",1); oSel.collapse(false); return false; } function send_message_return(data, ID){ if(data && data.success == true ){ // if send ok, set a flag as answered or forwarded var msg_number_replied = Element('msg_reply_from_'+ID); var msg_number_forwarded = Element('msg_forward_from_'+ID); if (msg_number_replied){ set_message_flag(msg_number_replied.value, 'answered'); } else if (msg_number_forwarded){ set_message_flag(msg_number_forwarded.value, 'forwarded'); } 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.')); } // If new dynamic contacts were added, update the autocomplete .... if(data.new_contacts){ var ar_contacts = data.new_contacts.split(',;'); for(var j in ar_contacts){ // If the dynamic contact don't exist, update the autocomplete.... if((contacts+",").indexOf(";"+ar_contacts[j]+",") == -1) contacts += ",;" + ar_contacts[j]; } } if ((! openTab.toPreserve[ID]) && (openTab.imapUid[ID] != 0)) cExecute ("$this.imap_functions.delete_msgs&folder="+openTab.imapBox[ID]+"&msgs_number="+openTab.imapUid[ID],function(data){ return }); delete_border(ID,'true'); // Becarefull: email saved automatically should be deleted. delete_border erase information about openTab } 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) write_msg(data); else write_msg(get_lang("Connection failed with %1 Server. Try later.", "Web")); } } function send_message(ID, folder, folder_name){ if ( document.getElementById('viewsource_rt_checkbox').checked == true ) document.getElementById('viewsource_rt_checkbox').click(); var save_link = Element("save_message_options_"+ID); save_link.onclick = ''; save_link.className = 'message_options_inactive'; ID_tmp = ID; var handler_send_message = function(data){ send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug }; var textArea = document.createElement("TEXTAREA"); textArea.style.display='none'; textArea.name = "body"; body = document.getElementById("body_"+ID); textArea.value += '\r\n'; textArea.value += body.contentWindow.document.body.innerHTML; textArea.value += '\r\n'; var input_folder = document.createElement("INPUT"); input_folder.style.display='none'; input_folder.name = "folder"; input_folder.value = folder; var msg_id = document.createElement("INPUT"); msg_id.style.display='none'; msg_id.name = "msg_id"; msg_id.value = openTab.imapUid[ID]; 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); form.appendChild(input_folder); form.appendChild(msg_id); var _subject = trim(Element("subject_"+ID).value); if((_subject.length == 0) && !confirm(get_lang("Send this message without a subject?"))) { Element("subject_"+ID).focus(); return; } cExecuteForm ("$this.imap_functions.send_mail", form, handler_send_message, ID); } function return_save(data,border_id,folder_name,folder_id,message_id) { var handler_delete_msg = function(data){ refresh(preferences.alert_new_msg); }; if (data.append != true || !data) { RichTextEditor.saveFlag = -1; if (! data.append) write_msg('ERROR saving your message.'); else { if (data.append.match(/^(.*)TRYCREATE(.*)$/)) { connector.loadScript('TreeS'); alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.',draftsfolder)); connector.loadScript('TreeShow'); ttree.FOLDER = 'root'; ttreeBox.new_past(draftsfolder); setTimeout('save_msg('+border_id+')',3000); } else write_msg(data.append); } } else { RichTextEditor.saveFlag = 1; openTab.imapUid[border_id] = data.msg_no; openTab.imapBox[border_id] = data.folder_id; var newTitle = document.getElementById('subject_'+border_id).value; if (newTitle.length > 18) newTitle = newTitle.substr(18) + '...'; else if (newTitle == '') newTitle = get_lang("No subject"); document.getElementById('font_border_id_'+border_id).innerHTML = newTitle; // Replace the embedded images for new uids var mainField = document.getElementById('body_'+border_id).contentWindow; var content_body = mainField.document.getElementsByTagName('body').item(0).innerHTML; var body_images = content_body.match(/msg_num=\d*/g); var images_part = content_body.match(/msg_part=\d*/g); if (body_images) { for (var i=0; i'; else if(flag == 'forwarded') Element("td_message_answered_"+msg_number).innerHTML = ''; } } cExecute ("$this.imap_functions.set_messages_flag&folder="+( msg_number_folder ? msg_number_folder.value : current_folder )+"&msgs_to_set="+msg_number+"&flag="+flag, handler_set_messages_flag); } function print_all(){ if (openTab.type[currentTab] == 2) return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab); var folder= Element('border_id_0').innerHTML; var body = Element('divScrollMain_'+numBox).innerHTML; 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); var seekDot = /\"; window_print.document.body.innerHTML = html + '

' + '
 '+get_lang("Who")+''+get_lang("Subject")+''+get_lang("Date")+''+get_lang("Size")+'
' + body + '
'; break; } catch(e){ //alert(e.message); } } window_print.document.close(); window_print.print(); } 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 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 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 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 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; } while (1){ try{ var html = '

'; //html += ""; html += "

ExpressoLivre - ExpressoMail


"; html += ''; if(sender) html += ""; if(from) html += ""; if(to) { if(!printListTO) to = 'Os destinatários não estão sendo exibidos para esta impressão'; html += ""; } if (cc) { if(!printListCC) cc = 'Os destinatários não estão sendo exibidos para esta impressão'; html += ""; } if(date) html += ""; html += ""; html += "
" + get_lang('Sent by') + ": "+sender+"
" + get_lang('From') + ": "+from+"
" + get_lang('To') + ": "+to+"
" + get_lang('Cc') + ": "+cc+"
" + get_lang('Date') + ": "+date.innerHTML+"
" + get_lang('Subject')+ ": "+subject.innerHTML+"

"; window_print.document.body.innerHTML = html + '
' + body.innerHTML + '
'; if(!is_ie){ var tab_tags = window_print.document.getElementsByTagName("IMG"); for(var i = 0; i < tab_tags.length;i++){ var _img = document.createElement("IMG"); _img.src = tab_tags[i].src; tab_tags[i].parentNode.replaceChild(_img,tab_tags[i]); } } break; } catch(e){ //alert(e.message); } } window_print.document.close(); window_print.print(); } function empty_trash_imap(){ var handler_empty_trash = function(data){ Element('chk_box_select_all_messages').checked = false; if(!verify_session(data)) return; if (current_folder == 'INBOX'+cyrus_delimiter+trashfolder){ draw_paging(0); kill_current_box(); } tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder).alter({caption: get_lang("Trash")}); tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder)._refresh(); update_quota(current_folder); if (data) write_msg(get_lang('Your Trash folder was empty.')); else write_msg(get_lang('ERROR emptying your Trash folder.')); } var realyEmptyTrash=confirm(get_lang('Do you really want to empty your trash folder?')); if (realyEmptyTrash) cExecute ("$this.imap_functions.empty_trash", handler_empty_trash); } function export_all_selected_msgs(){ if (openTab.type[currentTab] > 1){ source_msg(currentTab,current_folder); return; } 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 download_attachments(null, null, data, null,null,'mensagens.zip'); } if (msgs_to_export) { cExecute ("$this.exporteml.makeAll", handler_export_all_selected_msgs, "folder="+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, id){ var search_box = Element("table_resultsearch_" + id.substr(18)).firstChild; var felement = search_box.firstChild; while(felement) { if (select) felement.firstChild.firstChild.checked = true; else felement.firstChild.firstChild.checked = false; felement = felement.nextSibling; } } 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); // Hold sesion for edit message. //if(!hold_session) // location.href="../login.php?cd=10&phpgw_forward=%2FexpressoMail1_2%2Findex.php"; return false; } else return true; } // Save image file. function save_image(e,thumb){ 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(_params[0],_params[1],_params[2],_params[3],_params[4]); } } function nospam(msgs_number, border_ID, folder){ if (folder == 'null') folder = current_folder; var 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 set_message_flag(msgs_number, "unseen"); proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name); } if (msgs_number == 'selected') msgs_number = get_selected_messages(); 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="+preferences.delete_and_show_previous_message+"&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 = current_folder; var new_folder = 'INBOX'+cyrus_delimiter+'Spam'; var new_folder_name = 'Spam'; var handler_move_msgs = function(data){ // debug // alert(data); proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name); } if(msgs_number == 'selected') 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="+preferences.delete_and_show_previous_message+"&cyrus_delimiter="+cyrus_delimiter, handler_move_msgs); else write_msg(get_lang('No selected message.')); } function import_window(){ var win = arrayJSWin["import_window"]; var form_upload = Element("form_upload"); if(!win) { var form = document.createElement("DIV"); form.id = "import_window"; form.style.visibility = "hidden"; form.style.position = "absolute"; form.style.background = "#eeeeee"; form.style.left = "0px"; form.style.top = "0px"; form.style.width = "0px"; form.style.height = "0px"; document.body.appendChild(form); form_upload = document.createElement("DIV"); form_upload.id = "form_upload"; form_upload.style.position = "absolute"; form_upload.style.top = "5px"; form_upload.style.left = "5px"; form_upload.name = get_lang('zip mails to import'); form_upload.style.width = "450px"; form_upload.style.height = "75px"; form.appendChild(form_upload); form.style.width = form.firstChild.style.width; form.style.height = form.firstChild.style.height; form.style.zIndex = "10000"; var title = form.firstChild.name; var wHeight = form.offsetHeight + "px"; var wWidth = form.offsetWidth + "px"; form.style.width = form.offsetWidth - 5; win = new dJSWin({ id: 'win_'+form.id, content_id: form.id, width: wWidth, height: wHeight, title_color: '#3978d6', bg_color: '#eee', title: title, title_text_color: 'white', button_x_img: '../phpgwapi/images/winclose.gif', border: true }); win.draw(); } form_upload.innerHTML = '
'+get_lang('zip mails to import')+':
'+ '
' + ' ' + '
'; win.open(); } function import_msgs(wfolders_tree){ function handler(data){ // Its necessary to encapsulate the data returned (IE bugfix) return_import_msgs(data,wfolders_tree); } var countFiles = document.form_import.countFiles; if(!countFiles){ countFiles = document.createElement("INPUT"); countFiles.type = "hidden"; countFiles.name = "countFiles"; countFiles.value = "1"; document.form_import.appendChild(countFiles); } var folder = document.createElement("INPUT"); folder.type = "hidden"; folder.name = "folder"; folder.value = wfolders_tree._selected.id; document.form_import.appendChild(folder); write_msg(get_lang('You must wait while the messages will be imported...')); cExecuteForm('$this.imap_functions.import_msgs', document.form_import, handler); } function return_import_msgs(data, wfolders_tree){ 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).',Element('upload_max_filesize').value)); else { if ( wfolders_tree._selected.id == 'local_Inbox' ) { archive_msgs('INBOX/Lixeira/tmpMoveToLocal','local_Inbox',data); cExecute('$this.imap_functions.delete_mailbox',function(){},'del_past=INBOX/Lixeira/tmpMoveToLocal'); } else { write_msg(data); arrayJSWin["import_window"].close(); if(openTab.imapBox[0] == wfolders_tree._selected.id){ openTab.imapBox[0] = ''; change_folder(wfolders_tree._selected.id, wfolders_tree._selected.caption); } else{ refresh(); } } } } } function select_import_folder(){ //Begin: Verify if the file extension is allowed. 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