// 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;
if (preferences.use_local_messages == 1 && window.google && google.gears)
if (expresso_local_messages.is_offline_installed())
expresso_local_messages.capt_url('controller.php?action=$this.db_functions.get_dropdown_contacts_to_cache');
}
var save_preferences = function(data){
preferences = data;
current_folder="INBOX";
if( (window.google && google.gears) && !google.gears.factory.getPermission())
preferences.use_local_messages=0;
if ((preferences.use_local_messages==1) && (!window.google || !google.gears)) {
temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?"));
if (temp) {
location.href = "http://gears.google.com/?action=install&message="+
"Para utilizar o recurso de mensagens locais, instale o google gears&return=" + document.location.href;
}
else {
preferences.use_local_messages=0;
}
}
if (preferences.use_local_messages==1) { //O I.E 7 estava se atrapalhando caso esses loads fossem feitos após as chamadas ajax. Antes não apresentou problemas...
connector.loadScript('mail_sync');
if (is_ie)
connector.loadScript('TreeShow');
setTimeout('auto_archiving()', 30000);
}
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);
cExecute ("$this.imap_functions.get_folders_list&onload=true", update_menu);
cExecute ("$this.db_functions.get_dropdown_contacts", save_contacts); //Save contacts needs preferences.
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();
if ( (preferences.use_local_messages==1) && (expresso_local_messages.is_offline_installed()) ) //Precisa ser feito após a renderização da caixa de emails
check_mail_in_queue();
// Insere a applet de criptografia
if (preferences.use_signature_digital_cripto == '1'){
loadApplet();
}
// Fim da inserção da applet
}
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.functions.get_preferences", save_preferences);
cExecute ("phpgwapi.browser.isMobile", function( data )
{
mobile_device = ( ( data.constructor == Boolean ) ? data : ( data === 'true' ) );
} );
setTimeout('auto_refresh()', time_refresh);
}
function init_offline(){
current_folder = 'local_Inbox';
if (account_id != null) {
if (!is_ie)
Element('tableDivAppbox').width = '100%';
else
connector.createXMLHTTP();
Element('divStatusBar').innerHTML = '
' +
'
' +
'
' +
'
' +
'ExpressoMail Offline - Versão 1.0
' +
'
' +
'
';
ConstructMenuTools();
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');
})
// Get cyrus delimiter
cyrus_delimiter = Element('cyrus_delimiter').value;
cExecute ("$this.db_functions.get_dropdown_contacts_to_cache", function(data) {contacts = data;});
//cExecute ("$this.functions.get_preferences", save_preferences);
}
}
/**
* Carrega a applet java no objeto search_div
* @author Mário César Kolling
*/
function loadApplet(){
var search_div = Element('search_div');
var applet = null;
if (navigator.userAgent.match('MSIE')){
applet = document.createElement('');
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'
//debug:'true'
}
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 = ' ';
}
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);
}
/*
função que remove todos os anexos...
*/
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"));
delete_border(msg_num+'_r','false'); //close email tab
}
};
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 = 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_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)
{
// Abrindo um e-mail criptografado
// Verifica se existe o objeto applet
if (!Element('cert_applet')){
// se não existir, mostra mensagem de erro.
write_msg(get_lang('The preference "%1" isn\'t enabled.', get_lang('Enable digitally sign/cipher the message?')));
} else {
// se existir prepara os dados para serem enviados e chama a
// operação na applet
connector.showProgressBar();
// if ((msg_info.DispositionNotificationTo) && ((msg_info.Unseen == 'U') || (msg_info.Recent == 'N'))){
/* var confNotification = confirm(get_lang("The sender waits your notification of reading. Do you want to confirm this?"), "");
if (confNotification)*/
// cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), handler_sendNotification);
// }
Element('cert_applet').doButtonClickAction('decript',
msg_info.msg_number,
msg_info.source,
msg_info.msg_folder); // Passa os dados para a applet
}
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 id_msg_read = ID+"_r";
if (preferences.use_shortcuts == '1')
select_msg(ID, 'null');
// Call function to draw message
// 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);
resizeWindow();
}
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(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 (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+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject), handler_sendNotification);
}
//Change msg class to read.
if (!msg_is_read(ID))
{
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"); // avoid caducous (lazy) data
}
}
}
}
function auto_refresh(){
refresh(preferences.alert_new_msg);
setTimeout('auto_refresh()', time_refresh);
}
function auto_archiving() {
expresso_mail_sync.start_sync();
setTimeout('auto_archiving()',600000);
}
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)
{
var tr_info = document.createElement("TR");
var td_info = document.createElement("TD");
td_info.setAttribute("colspan", "10");
td_info.setAttribute("background", "#FFF");
td_info.setAttribute("id","msg_info");
td_info.id = "msg_info";
td_info.align = "center";
td_info.style.padding = "25px";
td_info.style.fontWeight = "bold";
td_info.style.fontSize = "11pt";
td_info.innerHTML = get_lang("This mail box is empty");
tr_info.appendChild(td_info);
box.appendChild(td_info);
}
if (data.length > 0){
var msg_info = document.getElementById('msg_info');
if (msg_info != null)
{
var msg_tr = msg_info.parentNode;
msg_tr.removeChild(msg_info);
}
table_element = Element("table_box");
var box = Element("tbody_box");
table_element.appendChild(box);
if (data.msgs_to_delete.length > 0)
for (var i=0; i 0)
alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!");
build_quota(data['quota']);
}
// Update Box BgColor
var box = Element("tbody_box");
if(box.childNodes.length > 1){
updateBoxBgColor(box.childNodes);
}
connector.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));
if(!expresso_offline)
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,archive)
{
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,'INBOX'+cyrus_delimiter+trashfolder,trashfolder);
if(currentTab.toString().indexOf("_r") != -1){
msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
}
if (!archive && (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') {
//Last msg is selected
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 (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;
cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + url_encode(current_folder), show_msg);
}
else
delete_border(currentTab,'false');
}
else
delete_border(currentTab,'false');
}
for (var i=0; i 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){
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].getAttribute('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++){
removeAll(selected_messages[i]);
}
// Update Box BgColor
var box = Element("tbody_box_"+currentTab.substr(7)).childNodes;
if(main_list.length > 1){
updateBoxBgColor(box);
}
connector.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]);
if (tr.getAttribute('name') == new_folder)
{
write_msg(get_lang('At least one message have the same origin'));
return false;
}
trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name'));
selected_param += ','+trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
}
}
else
{
var tr=Element(selected_messages);
if (tr.getAttribute('name') == new_folder)
{
write_msg(get_lang('The origin folder and the destination folder are the same.'));
return false;
}
trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name'));
selected_param=trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
}
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 : (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" : 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 (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;
//cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg);
cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + url_encode(folder), show_msg);
}
else
delete_border(currentTab,'false');
}
else
delete_border(currentTab,'false');
if(msg_to_delete)
mail_msg.removeChild(msg_to_delete);
// Update Box BgColor
var box = Element("tbody_box");
if(box.childNodes.length > 0){
updateBoxBgColor(box.childNodes);
}
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;
}
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) //Caso seja o primeiro arquivamento...
folder_dest = 'local_Inbox';
if (parseInt(id_msgs) > 0 || id_msgs.length > 0)
expresso_mail_sync.archive_msgs(folder,folder_dest,id_msgs);
//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(){
try{
main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild;
}catch(e){
};
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++)
{
if (numBox > 0) {
id_mensagem = main_list[j].id.split('_');
check_box = Element("search_" + numBox + "_check_box_message_" + id_mensagem[0]);
}
else
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){
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));
if(typeof(openTab.type[new_border_ID]) != "undefined") {
if(tabTypes[type] == openTab.type[new_border_ID]) {
return new_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(!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 == false)
{
setTimeout('new_message(\''+type+'\',\''+border_ID+'\');',500);
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("cco_" + border_ID)){
data.cco = document.getElementById("cco_values_" + border_ID).value;
data.cco = data.cco.replace(/</gi,"<");
data.cco = data.cco.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;
}
if(typeof(preferences.signature) == 'undefined')
preferences.signature = "";
var signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, " ");
if(type!="new" && type!="edit")
data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false;
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,data.is_local_message);
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();
config_events( body.contentWindow.document, 'onkeyup', function( e )
{
if ( e.keyCode == 13 )
{
var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' );
for ( p = 0; p < paragraphs.length; p++ )
paragraphs.item( p ).style.margin = '0px';
}
});
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,data.is_local_message);
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 + "