if (!expresso_offline) { var _showBar = showBar; var _hideBar = hideBar; } function __showBar(){ _showBar(); resizeWindow(); } function __hideBar(){ _hideBar(); resizeWindow(); } showBar = __showBar; hideBar = __hideBar; XEvents.add( window, 'onresize', resizeWindow ); // BEGIN: FUNCTION RESIZE WINDOW function resizeWindow(){ var divScrollMain = Element("divScrollMain_"+numBox); var table_message = Element("table_message"); var content_folders = Element("content_folders"); var clientHeight = ((window.innerHeight ? window.innerHeight : document.body.offsetHeight) - 8); var clientWidth = ((window.innerWidth ? window.innerWidth : document.body.offsetWidth) - 17); if(divScrollMain){ divScrollMain.style.height = (clientHeight - (findPosY(divScrollMain) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight))) + "px"; } if(typeof(BordersArray) != 'undefined') { for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) { var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence); var div = Element("content_id_"+BordersArray[i].sequence); if(div){ div.style.height = (clientHeight - (findPosY(div) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+2)) + "px"; div.style.width = (clientWidth - (findPosX(div)+10)) + "px"; } if(div_scroll){ div_scroll.style.height = (clientHeight - (findPosY(div_scroll) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight))) + "px"; div_scroll.style.width = (clientWidth - (findPosX(div_scroll)+10)) + "px"; } } } if(content_folders){ var search_div = Element("search_div"); var contentFoldersY = findPosY(content_folders); content_folders.style.height = (clientHeight - (contentFoldersY + (contentFoldersY > findPosY(search_div) ? 0 : (search_div.clientHeight ? search_div.clientHeight : search_div.offsetHeight) + 5))) + "px"; } } // END: FUNCTION RESIZE WINDOW var _beforeunload_ = window.onbeforeunload; window.onbeforeunload = function() { return unloadMess(); }; function unloadMess(){ if (typeof(expresso_mail_sync) != "undefined" && expresso_mail_sync.working) { var mess = get_lang("You're about archiving your e-mails from server. Do you really want to stop this action?"); return mess; } else { var mess = get_lang("Your message has not been sent and will be discarted."); for (var i = 0; i < BordersArray.length; i++) { var body = Element('body_' + BordersArray[i].sequence); if (body && body.contentWindow && body.contentWindow.document.designMode.toLowerCase() == 'on') { return mess; } } } } // Change the class of message. // In refresh, the flags UnRead and UnSeen don't exist anymore. function set_msg_as_read(msg_number, selected){ tr_message = Element(msg_number); if (exist_className(tr_message, 'tr_msg_unread')) decrement_folder_unseen(1); remove_className(tr_message, 'tr_msg_unread'); remove_className(tr_message, 'selected_msg'); Element("td_message_unseen_"+msg_number).innerHTML = ""; return true; } function msg_is_read(msg_number, selected){ tr_message = Element(msg_number); return !(tr_message && LTrim(tr_message.className).match('tr_msg_unread')); } function set_msg_as_unread(msg_number){ tr_message = Element(msg_number); if ((exist_className(tr_message, 'tr_msg_read') || exist_className(tr_message, 'tr_msg_read2')) && (!exist_className(tr_message, 'tr_msg_unread'))) increment_folder_unseen(1); remove_className(tr_message, 'selected_msg'); add_className(tr_message, 'tr_msg_unread'); Element("td_message_unseen_"+msg_number).innerHTML = ""; } function set_msg_as_flagged(msg_number){ var msg = Element(msg_number); remove_className(msg, 'selected_msg'); add_className(msg, 'flagged_msg'); Element("td_message_important_"+msg_number).innerHTML = ""; } function set_msg_as_unflagged(msg_number){ var msg = Element(msg_number); remove_className(msg, 'selected_msg'); remove_className(msg, 'flagged_msg'); Element("td_message_important_"+msg_number).innerHTML = "   "; } function get_current_folder(){ return current_folder; } // Kill current box (folder or page). function kill_current_box(){ var box = document.getElementById("table_box"); if (box != null) box.parentNode.removeChild(box); else return false; } // Kill current paging. function kill_current_paging(){ var paging = Element("span_paging"); if (paging != null) paging.parentNode.removeChild(paging); } function show_hide_span_paging(ID){ if ((ID != "0") && Element("span_paging")) Element("span_paging").style.display = 'none'; else if (Element("span_paging")) Element("span_paging").style.display = ''; } function download_local_attachment(url) { if (div_attachment == null){ var div_attachment = document.createElement("DIV"); div_attachment.id="id_div_attachment"; document.body.appendChild(div_attachment); } div_attachment.innerHTML=""; } function download_attachments(msg_folder, msg_number, idx_file, msg_part, encoding, new_file_name, show_iframe){ div_attachment = document.getElementById("id_div_attachment"); var params = ''; if (div_attachment == null){ var div_attachment = document.createElement("DIV"); div_attachment.id="id_div_attachment"; document.body.appendChild(div_attachment); } if(new_file_name) params = "&newfilename="+escape(new_file_name); if(encoding) params += "&encoding="+encoding; div_attachment.innerHTML=""; } function download_all_attachments(msg_folder, msg_number){ var handler_source = function(data){ download_attachments(null, null, data, null,null,'anexos.zip'); }; cExecute("expressoMail1_2.exporteml.download_all_attachments",handler_source,"folder="+msg_folder+"&num_msg="+msg_number); } //ADD forwarded files function addForwardedFile(id_border,file_name,link){ divFiles = document.getElementById("divFiles_"+id_border); if (! divFiles) return false; if (divFiles.lastChild) var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; if (! countDivFiles) var countDivFiles = 1; divFile = document.createElement('DIV'); if (!expresso_offline) { if (!is_ie) { var inputFile = document.createElement("INPUT"); var tmp_id_border = document.createAttribute('id_border'); tmp_id_border.value = id_border; inputFile.setAttributeNode(tmp_id_border); inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; inputFile.type = 'file'; inputFile.size = 50; inputFile.maxLength = 255; inputFile.name = 'file_' + countDivFiles; inputFile.style.display = "none"; } else { var inputFile = document.createElement("link"); var tmp_id_border = document.createAttribute('id_border'); tmp_id_border.value = id_border; inputFile.setAttributeNode(tmp_id_border); inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; inputFile.name = 'file_' + countDivFiles; } } else { var inputFile = document.createElement("input"); inputFile.type = 'hidden'; inputFile.name = 'offline_forward_' + countDivFiles; } divFile.appendChild(inputFile); var a_tmp = new Array(); a_tmp[0] = "local_"; a_tmp[1] = 'file_' + countDivFiles; a_tmp[2] = file_name; s_tmp = escape(expresso.connector.serialize(a_tmp)); var checkbox = document.createElement("INPUT"); checkbox.type = "checkbox"; checkbox.id = "checkbox_"+id_border+"_"+countDivFiles; checkbox.name = "local_attachments[]"; checkbox.value = s_tmp; divFile.appendChild(checkbox); var link_attachment = document.createElement("A"); link_attachment.setAttribute("href", link); link_attachment.innerHTML = file_name; divFile.appendChild(link_attachment); countDivFiles++; divFile.id = "divFile_"+id_border+"_"+countDivFiles; divFiles.appendChild(divFile); checkbox.checked = true; //Incrível, mas no Internet Explorer o checked só funciona efetivamente se o elemente já estiver renderizado... por isso só aqui eu seleciono ele... return inputFile; } // Add Input File Dynamically. function addFile(id_border){ divFiles = document.getElementById("divFiles_"+id_border); if (! divFiles) return false; if (divFiles.lastChild) var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; if (! countDivFiles) var countDivFiles = 1; divFile = document.createElement('DIV'); divFile.innerHTML = ""; var linkFile = document.createElement("A"); linkFile.id = "linkFile_"+id_border+"_"+countDivFiles; linkFile.href='javascript:void(0)'; linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;}; linkFile.innerHTML=get_lang("Remove"); //divFile.innerHTML += "  "; divFile.appendChild(linkFile); divFile.id = "divFile_"+id_border+"_"+countDivFiles; divFiles.appendChild(divFile); return document.getElementById("inputFile_"+id_border+"_"+countDivFiles); } var setTimeout_write_msg = 0; var old_msg = false; // Funcao usada para escrever mensagem // notimeout = True : mensagem nao apaga function write_msg(msg, notimeout){ if (setTimeout_write_msg) clearTimeout(setTimeout_write_msg); var msg_div = Element('em_div_write_msg'); var old_divStatusBar = Element("divStatusBar"); if(!msg_div) { msg_div = document.createElement('DIV'); msg_div.id = 'em_div_write_msg'; msg_div.className = 'em_div_write_msg'; old_divStatusBar.parentNode.insertBefore(msg_div,old_divStatusBar); } if( document.getElementById('JabberMessenger')) loadscript.adIcon(); msg_div.innerHTML = '
'+msg+'
'; old_divStatusBar.style.display = 'none'; msg_div.style.display = ''; // Nao ponha var na frente!! jakjr handle_write_msg = function(){ try{ if(!old_msg) clean_msg(); else write_msg(old_msg, true); } catch(e){} }; if(notimeout) old_msg = msg; else setTimeout_write_msg = setTimeout("handle_write_msg();", 5000); } // Funcao usada para apagar mensagem sem timeout function clean_msg(){ old_msg = false; var msg_div = Element('em_div_write_msg'); var old_divStatusBar = Element("divStatusBar"); if(msg_div) msg_div.style.display = 'none'; old_divStatusBar.style.display = ''; } function make_body_reply(body, to, date_day, date_hour){ to = to.replace("<","<"); to = to.replace(">",">"); block_quoted_body ="

"; block_quoted_body += get_lang('At %1, %2 hours, %3 wrote:', date_day, date_hour, to); block_quoted_body += "
"; block_quoted_body += body; block_quoted_body += "
"; return block_quoted_body; } function make_forward_body(body, from, date, subject, to, cc){ from = from.replace(//g,">"); to = to.replace(//g,">"); var forward_body = '

---------- ' + get_lang('Forwarded message') + ' ----------
'; forward_body += get_lang('From') + ': ' + from + '
'; forward_body += get_lang('Date') + ': ' + date + '
'; forward_body += get_lang('Subject') + ': ' + subject + '
'; forward_body += get_lang('To') + ': ' + to+ '
'; if(cc != undefined){ cc = cc.replace(//g,">"); forward_body += get_lang('CC') + ': ' + cc+ '

'; } forward_body += body; return forward_body; } function norm(arg) {return (arg < 10 ? '0'+arg : arg);} function strDateShow(timestamp){ var retStr = ''; var weekDays = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; var date_msg = new Date(timestamp*1000); var today = new Date(); today.setHours(0); today.setMinutes(0); if (today.getTime() - date_msg.getTime() < 86400000) retStr = norm(date_msg.getHours()) + ':' + norm(date_msg.getMinutes()); else if (today.getTime() - date_msg.getTime() < 172800000) retStr = get_lang('Yesterday'); else if (today.getTime() - date_msg.getTime() < 259200000) retStr = get_lang(weekDays[date_msg.getDay()]); else retStr = norm(date_msg.getDate()) + '/' + norm(date_msg.getMonth()+1) + '/' +date_msg.getFullYear(); return retStr; } function emMessageSearch(e,value){ var e = is_ie ? window.event : e; if(e.keyCode == 13) { search_emails(value); } } function emQuickSearch(emailList, field, ID){ var quickSearchKeyBegin; var quickSearchKeyEnd; if(expresso_offline) { alert(get_lang('Not allowed in offline mode')); return; } var handler_emQuickSearch = function(data) { window_DropDownContacts = Element('tipDiv'); if (window_DropDownContacts.style.visibility != 'hidden'){ window_DropDownContacts.style.visibility = 'hidden'; } if ((!data.status) && (data.error == "many results")){ alert(get_lang('More than %1 results. Please, try to refine your search.',200)); return false; } if (data.length > 0){ if ((field != 'null') && (ID != 'null')) { expresso.connector.loadScript("jscode/QuickCatalogSearch"); if (typeof(QuickCatalogSearch) == 'undefined'){ setTimeout('emQuickSearch("'+emailList+'", "'+field+'", "'+ID+'")',500); return false; } QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd); } else { expresso.connector.loadScript("jscode/QuickSearchUser"); if (typeof(QuickSearchUser) == 'undefined'){ setTimeout('emQuickSearch("'+emailList+'", "'+field+'", "'+ID+'")',500); return false; } QuickSearchUser.showList(data); } } else alert(get_lang('None result was found.')); return true; }; if ((field != 'null') && (ID != 'null')) { Element(field +'_'+ ID).focus(); //It requires for IE. var i = getPosition(Element(field +'_'+ ID)); //inputBox.selectionStart; var j = --i; // Acha o inicio while ((j >= 0) && (emailList.charAt(j) != ',')){j--}; quickSearchKeyBegin = ++j; // Acha o final while ((i <= emailList.length) && (emailList.charAt(i) != ',')){i++}; quickSearchKeyEnd = i; // A Chave da Pesquisa var search_for = trim(emailList.substring(quickSearchKeyBegin, quickSearchKeyEnd)); } else var search_for = emailList; if (search_for.length < preferences.search_characters_number){ alert(get_lang('Your search argument must be longer than %1 characters.', preferences.search_characters_number)); return false; } cExecute ("expressoMail1_2.ldap_functions.quicksearch&search_for="+search_for+"&field="+field+"&ID="+ID, handler_emQuickSearch); } function folderbox(){ expresso.connector.loadScript("jscode/TreeS"); if (typeof(ttree) == 'undefined'){ setTimeout('folderbox()',500); return false; } ttree.make_Window(); } function filterbox(){ expresso.connector.loadScript("jscode/filter"); expresso.connector.loadScript("jscode/filters"); if (typeof(filters) == 'undefined') { setTimeout('filterbox()',500); return false; } filters.Forms(); } function sharebox(){ var handler_imap_getacl = function(data) { var options = ''; for (var x in data) { options += ""; } expresso.connector.loadScript("jscode/sharemailbox"); if (typeof(sharemailbox) == 'undefined') { setTimeout('sharebox()',500); return false; } sharemailbox.makeWindow(options); }; cExecute ("expressoMail1_2.imap_functions.getacl", handler_imap_getacl); } function preferences_mail(){ location.href="../preferences/preferences.php?appname=expressoMail1_2"; } function search_emails(value){ expresso.connector.loadScript("jscode/TreeS"); expresso.connector.loadScript("jscode/search"); if (typeof(EsearchE) == 'undefined' || typeof(ttree) == 'undefined'){ setTimeout('search_emails("'+value+'")',500); return false; } EsearchE.showForms(value); } function source_msg(id_msg,folder){ var num_msg = id_msg.substr(0,(id_msg.length - 2)); var handler_source = function(data){ download_attachments(null, null, data, null,null,'fonte_da_mensagem.eml'); }; cExecute("expressoMail1_2.exporteml.export_msg",handler_source,"folder="+url_decode(folder)+"&msgs_to_export="+num_msg); } function Element (el) { return document.getElementById(el); } function getPosition(obj) { if(typeof obj.selectionStart != "undefined") { return obj.selectionStart; } else if(document.selection && document.selection.createRange) { var M = document.selection.createRange(); try { var Lp = M.duplicate(); Lp.moveToElementText(obj); } catch(e) { var Lp=obj.createTextRange(); } Lp.setEndPoint("EndToStart",M); var rb=Lp.text.length; if(rb > obj.value.length) { return -1; } return rb; } }; function increment_folder_unseen(num){ if (num < 0) return decrement_folder_unseen(num*-1); else if(num == 0) return; var folder_id = get_current_folder(); var folder_unseen = Element('dftree_'+folder_id+'_unseen'); var abas_unseen = Element('new_m').innerHTML; abas_unseen = abas_unseen.match(/[0-9]+/); if (folder_unseen) { folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) + num); } else { tree_folders.getNodeById(folder_id).alter({caption: tree_folders.getNodeById(current_folder).caption + ' ('+num+')'}); tree_folders.getNodeById(folder_id)._refresh(); } if (abas_unseen) { abas_unseen = parseInt(abas_unseen) + num; Element('new_m').innerHTML = '' + abas_unseen + ''; } else{ abas_unseen = Element('new_m').innerHTML; abas_unseen = abas_unseen.match( /[0-9]+/); abas_unseen = parseInt(abas_unseen) + num; Element('new_m').innerHTML = '' + abas_unseen + ''; } if ( current_folder.indexOf( 'INBOX' ) !== 0 && current_folder.indexOf( 'local_' ) !== 0 ) { var _disp_unseenshfolder = Element('dftree_user_unseen'); if ( _disp_unseenshfolder ) tree_folders.getNodeById( 'user' ).alter({caption:'[' + ( parseInt( _disp_unseenshfolder.innerHTML) + num ) + ']' + get_lang("Shared folders")}); else tree_folders.getNodeById( 'user' ).alter({caption:'[1]' + get_lang("Shared folders")}); tree_folders.getNodeById( 'user' )._refresh(); } var _disp_unseen_mb = Element('dftree_root_unseen'); if(!expresso_offline) var node_to_refresh = 'root'; else var node_to_refresh = 'local_root'; tree_folders.getNodeById( node_to_refresh )._refresh(); } function decrement_folder_unseen(num){ var folder_id = get_current_folder(); var folder_unseen = Element('dftree_'+folder_id+'_unseen'); var abas_unseen = Element('new_m').innerHTML; abas_unseen = abas_unseen.match( /[0-9]+/); if(!folder_unseen || !abas_unseen) return; if ((folder_unseen) && (parseInt(folder_unseen.innerHTML) > num)) { folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) - num); } else if (parseInt(folder_unseen.innerHTML) <= num) { var tmp_folder_name = tree_folders.getNodeById(folder_id).caption.split('<'); var folder_name = tmp_folder_name[0]; tree_folders.getNodeById(folder_id).alter({caption: folder_name}); tree_folders.getNodeById(folder_id)._refresh(); } if ((abas_unseen) && (parseInt(abas_unseen) > num)) { abas_unseen = (parseInt(abas_unseen) - num); Element('new_m').innerHTML = '' + abas_unseen + ''; } else if (parseInt(abas_unseen) <= 1) { Element('new_m').innerHTML = '0'; } if ( current_folder.indexOf( 'INBOX' ) !== 0 ) { var _disp_unseenshfolder = Element('dftree_user_unseen'); if ( _disp_unseenshfolder ) { var _useen_shfolder = parseInt( _disp_unseenshfolder.innerHTML ); _useen_shfolder--; if ( _useen_shfolder > 0 ) tree_folders.getNodeById( 'user' ).alter({caption:'[' + _useen_shfolder + ']' + get_lang("My Folders")}); else tree_folders.getNodeById( 'user' ).alter({caption:get_lang("Shared folders")}); tree_folders.getNodeById( 'user' )._refresh(); } } var _disp_unseen_mb = Element('dftree_root_unseen'); if ( _disp_unseen_mb ) { var unseen_in_mailbox = parseInt( _disp_unseen_mb.innerHTML ); unseen_in_mailbox--; //if ( unseen_in_mailbox > 0 ) // tree_folders.getNodeById( 'root' ).alter({caption:'[' + unseen_in_mailbox + ']' + get_lang("My Folders")}); //else if(!expresso_offline) var node_to_refresh = 'root'; else var node_to_refresh = 'local_root'; tree_folders.getNodeById( node_to_refresh ).alter({caption:get_lang("My Folders")}); tree_folders.getNodeById( node_to_refresh )._refresh(); } } //changes MENU background color. function set_menu_bg(menu) { menu.style.backgroundColor = 'white'; menu.style.border = '1px solid black'; menu.style.padding = '0px 0px'; } //changes MENU background color. function unset_menu_bg(menu) { menu.style.backgroundColor = ''; menu.style.border = '0px'; menu.style.padding = '1px 0px'; } function array_search(needle, haystack) { var n = haystack.length; for (var i=0; i