source: trunk/expressoMail1_2/js/jscode/common_functions.js @ 2692

Revision 2692, 21.0 KB checked in by niltonneto, 14 years ago (diff)

Ticket #1050 - Estilo entre msgs lidas e não-lidas alterado para melhorar distinção.

Line 
1// BEGIN: FUNCTION RESIZE WINDOW
2if (!expresso_offline) {
3        var _showBar = showBar;
4        var _hideBar = hideBar;
5}
6
7function __showBar(){
8        _showBar();
9        resizeWindow();
10}
11
12function __hideBar(){
13        _hideBar();
14        resizeWindow();
15}
16showBar = __showBar;
17hideBar = __hideBar;
18
19XEvents.add( window, 'onresize', resizeWindow );
20
21function resizeWindow(){
22
23        var bar = Element("toolbar");
24        var offset = 0;
25        if(bar.style.visibility != 'hidden')
26                offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);     
27
28        var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
29        var defaultHeight = screenHeight - offset;
30
31        if(typeof(BordersArray) != 'undefined') {
32                for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) {
33                        var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence);
34                        var div = Element("content_id_"+BordersArray[i].sequence);
35
36                        if(div)
37                                div.style.height = ( defaultHeight - 90 ) + 'px';
38                        if(div_scroll)
39                                div_scroll.style.height = ( defaultHeight - 130 ) + 'px';
40                }
41        }
42
43        if(Element('content_folders'))
44                Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150);
45        if(Element("divScrollMain_"+numBox))
46                Element("divScrollMain_"+numBox).style.height   = defaultHeight - (is_ie ? 111 : 110);
47}
48// END: FUNCTION RESIZE WINDOW
49
50var _beforeunload_ = window.onbeforeunload;
51
52window.onbeforeunload = function()
53{
54        return unloadMess();
55};
56
57function unloadMess(){
58        if (typeof(expresso_mail_sync) != "undefined" && expresso_mail_sync.working) {
59                var mess = get_lang("You're about archiving your e-mails from server. Do you really want to stop this action?");
60                return mess;
61        }
62        else {
63                var mess = get_lang("Your message has not been sent and will be discarted.");
64                for (var i = 0; i < BordersArray.length; i++) {
65                        var body = Element('body_' + BordersArray[i].sequence);
66                        if (body && body.contentWindow && body.contentWindow.document.designMode.toLowerCase() == 'on') {
67                                return mess;
68                        }
69                }
70        }
71}
72
73// Change the class of message.
74// In refresh, the flags UnRead and UnSeen don't exist anymore.
75function set_msg_as_read(msg_number, selected){
76        tr_message = Element(msg_number);
77        if (exist_className(tr_message, 'tr_msg_unread'))
78                decrement_folder_unseen();
79        remove_className(tr_message, 'tr_msg_unread');
80        remove_className(tr_message, 'selected_msg');
81        Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='"+URL_SERVER+"expressoMail1_2/templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>";
82        expresso.connector.purgeCache();
83        return true;
84}
85
86function msg_is_read(msg_number, selected){
87        tr_message = Element(msg_number);
88        return !(tr_message && LTrim(tr_message.className).match('tr_msg_unread'));
89}
90
91function set_msg_as_unread(msg_number){
92        tr_message = Element(msg_number);
93        if ((exist_className(tr_message, 'tr_msg_read') || exist_className(tr_message, 'tr_msg_read2')) && (!exist_className(tr_message, 'tr_msg_unread')))
94                increment_folder_unseen();     
95        remove_className(tr_message, 'selected_msg');
96        add_className(tr_message, 'tr_msg_unread');
97        Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='"+URL_SERVER+"expressoMail1_2/templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>";
98}
99
100function set_msg_as_flagged(msg_number){
101        var msg = Element(msg_number);
102        remove_className(msg, 'selected_msg');
103        add_className(msg, 'flagged_msg');
104        Element("td_message_important_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/important.gif' title='"+get_lang('Important')+"'>";
105}
106
107function set_msg_as_unflagged(msg_number){
108        var msg = Element(msg_number);
109        remove_className(msg, 'selected_msg');
110        remove_className(msg, 'flagged_msg');
111        Element("td_message_important_"+msg_number).innerHTML = "&nbsp;&nbsp;&nbsp;";
112}
113
114
115function get_current_folder(){
116        return current_folder;
117}
118
119// Kill current box (folder or page).
120function kill_current_box(){
121        var box = document.getElementById("table_box");
122        if (box != null)
123                box.parentNode.removeChild(box);
124        else
125                return false;
126}
127
128// Kill current paging.
129function kill_current_paging(){
130        var paging = Element("span_paging");
131        if (paging != null)
132                paging.parentNode.removeChild(paging);
133}
134
135function show_hide_span_paging(ID){
136        if ((ID != "0") && Element("span_paging"))
137                Element("span_paging").style.display = 'none';
138        else
139                if (Element("span_paging"))
140                        Element("span_paging").style.display = '';
141}
142
143//Get the current number of messages in a page.
144function get_messages_number_in_page(){
145        //Get element tBody.
146        main = document.getElementById("tbody_box");
147               
148        // Get all TR (messages) in tBody.
149        main_list = main.childNodes;
150       
151        return main_list.length;
152}
153
154function download_local_attachment(url) {
155        if (div_attachment == null){
156                var div_attachment = document.createElement("DIV");
157                div_attachment.id="id_div_attachment";
158                document.body.appendChild(div_attachment);
159        }
160        div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='"+url+"'></iframe>";
161}
162
163function download_attachments(msg_folder, msg_number, idx_file, msg_part, encoding, new_file_name, show_iframe){
164        div_attachment = document.getElementById("id_div_attachment");
165        var params = '';
166       
167        if (div_attachment == null){
168                var div_attachment = document.createElement("DIV");
169                div_attachment.id="id_div_attachment";
170                document.body.appendChild(div_attachment);
171        }
172        if(new_file_name)
173                params = "&newfilename="+escape(new_file_name);
174        if(encoding)
175                params += "&encoding="+encoding;
176
177        div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='inc/gotodownload.php?msg_folder="+msg_folder+"&msg_number="+msg_number+"&idx_file="+idx_file+"&msg_part="+msg_part+params+"'></iframe>";
178}
179
180function download_all_attachments(msg_folder, msg_number){
181        var handler_source = function(data){           
182                download_attachments(null, null, data, null,null,'anexos.zip');
183        };
184        cExecute("expressoMail1_2.exporteml.download_all_attachments",handler_source,"folder="+msg_folder+"&num_msg="+msg_number);
185}
186//ADD forwarded files
187function addForwardedFile(id_border,file_name,link){
188        divFiles = document.getElementById("divFiles_"+id_border);
189
190        if (! divFiles)
191                return false;
192       
193        if (divFiles.lastChild)
194                var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1;
195
196        if (! countDivFiles)
197                var countDivFiles = 1;
198       
199        divFile = document.createElement('DIV');
200       
201
202        if (!expresso_offline) {
203                if (!is_ie) {
204                        var inputFile = document.createElement("INPUT");
205                       
206                        var tmp_id_border = document.createAttribute('id_border');
207                        tmp_id_border.value = id_border;
208                       
209                        inputFile.setAttributeNode(tmp_id_border);
210                        inputFile.id = "inputFile_" + id_border + "_" + countDivFiles;
211                        inputFile.type = 'file';
212                        inputFile.size = 50;
213                        inputFile.maxLength = 255;
214                        inputFile.name = 'file_' + countDivFiles;
215                        inputFile.style.display = "none";
216                }
217                else {
218                        var inputFile = document.createElement("link");
219                       
220                        var tmp_id_border = document.createAttribute('id_border');
221                        tmp_id_border.value = id_border;
222                       
223                        inputFile.setAttributeNode(tmp_id_border);
224                        inputFile.id = "inputFile_" + id_border + "_" + countDivFiles;
225                        inputFile.name = 'file_' + countDivFiles;
226                       
227                       
228                }
229               
230        }
231        else {
232                var inputFile = document.createElement("input");
233                inputFile.type = 'hidden';
234                inputFile.name = 'offline_forward_' + countDivFiles;
235        }       
236        divFile.appendChild(inputFile);
237
238        var a_tmp = new Array();
239        a_tmp[0] = "local_";
240        a_tmp[1] = 'file_' + countDivFiles;
241        a_tmp[2] = file_name;
242        s_tmp = escape(expresso.connector.serialize(a_tmp));
243        var checkbox = document.createElement("INPUT");
244        checkbox.type = "checkbox";
245        checkbox.id = "checkbox_"+id_border+"_"+countDivFiles;
246        checkbox.name = "local_attachments[]";
247       
248        checkbox.value = s_tmp;
249        divFile.appendChild(checkbox);
250       
251        var link_attachment = document.createElement("A");
252        link_attachment.setAttribute("href", link);
253       
254        link_attachment.innerHTML = file_name;
255        divFile.appendChild(link_attachment);
256       
257        countDivFiles++;
258        divFile.id = "divFile_"+id_border+"_"+countDivFiles;   
259        divFiles.appendChild(divFile);
260
261        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...
262        return inputFile;
263}
264
265// Add Input File Dynamically.
266function addFile(id_border){
267        divFiles = document.getElementById("divFiles_"+id_border);
268        if (! divFiles)
269                return false;
270       
271        if (divFiles.lastChild)
272                var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1;
273
274        if (! countDivFiles)
275                var countDivFiles = 1;
276       
277        divFile = document.createElement('DIV');
278       
279       
280        divFile.innerHTML = "<input type='file' id_border='"+id_border+"' size='50' maxLength='255' onchange=\"function () {validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border'));};\" id='"+"inputFile_"+id_border+"_"+countDivFiles+"' name='file_"+countDivFiles+"'>";
281
282       
283        var linkFile = document.createElement("A");
284        linkFile.id = "linkFile_"+id_border+"_"+countDivFiles;
285        linkFile.href='javascript:void(0)';
286        linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;};
287        linkFile.innerHTML=get_lang("Remove"); 
288        //divFile.innerHTML += "&nbsp;&nbsp;";
289        divFile.appendChild(linkFile);
290        divFile.id = "divFile_"+id_border+"_"+countDivFiles;   
291        divFiles.appendChild(divFile);
292
293       
294
295        return document.getElementById("inputFile_"+id_border+"_"+countDivFiles);
296}
297
298var setTimeout_write_msg = 0;
299var old_msg = false;
300// Funcao usada para escrever mensagem
301// notimeout = True : mensagem nao apaga
302function write_msg(msg, notimeout){     
303       
304        if (setTimeout_write_msg)
305                clearTimeout(setTimeout_write_msg);
306       
307        var msg_div = Element('em_div_write_msg');
308        var old_divStatusBar = Element("divStatusBar");
309
310        if(!msg_div) {
311                msg_div = document.createElement('DIV');
312                msg_div.id = 'em_div_write_msg';
313                msg_div.className = 'em_div_write_msg';
314                old_divStatusBar.parentNode.insertBefore(msg_div,old_divStatusBar);
315        }
316       
317        if( document.getElementById('JabberMessenger'))
318                loadscript.adIcon();
319
320        msg_div.innerHTML = '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><th width="40%"></th><th noWrap class="action_info_th">'+msg+'</th><th width="40%"></th></tr></tbody></table>';
321
322        old_divStatusBar.style.display = 'none';
323        msg_div.style.display = '';     
324        // Nao ponha var na frente!! jakjr
325        handle_write_msg = function(){
326                try{
327                        if(!old_msg)
328                                clean_msg();
329                        else
330                                write_msg(old_msg, true);                       
331                }
332                catch(e){}
333        };
334        if(notimeout)
335                old_msg = msg;
336        else
337                setTimeout_write_msg = setTimeout("handle_write_msg();", 5000);
338}
339// Funcao usada para apagar mensagem sem timeout
340function clean_msg(){
341        old_msg = false;
342        var msg_div = Element('em_div_write_msg');
343        var old_divStatusBar = Element("divStatusBar");
344        if(msg_div)
345                msg_div.style.display = 'none';
346        old_divStatusBar.style.display = '';   
347}
348
349function make_body_reply(body, to, date_day, date_hour){
350        to = to.replace("<","&lt;");
351        to = to.replace(">","&gt;");
352        block_quoted_body ="<br><br>";
353        block_quoted_body += get_lang('At %1, %2 hours, %3 wrote:', date_day, date_hour, to);
354        block_quoted_body += "<blockquote style=\"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;\">";
355        block_quoted_body += body;
356        block_quoted_body += "</blockquote>";
357        return block_quoted_body;
358}
359
360function make_forward_body(body, from, date, subject, to, cc){
361        from = from.replace(/</g,"&lt;");
362        from = from.replace(/>/g,"&gt;");
363        to = to.replace(/</g,"&lt;");
364        to = to.replace(/>/g,"&gt;");
365        var forward_body = '<BR><BR>---------- ' + get_lang('Forwarded message') + ' ----------<BR>';
366        forward_body += get_lang('From') + ': ' + from + '<BR>';
367        forward_body += get_lang('Date') + ': ' + date + '<BR>';
368        forward_body += get_lang('Subject') + ': ' + subject + '<BR>';
369        forward_body += get_lang('To') + ': ' + to+ '<BR>';
370        if(cc != undefined){
371                cc = cc.replace(/</g,"&lt;");
372                cc = cc.replace(/>/g,"&gt;");
373                forward_body += get_lang('CC') + ': ' + cc+ '<BR><BR>';
374        }
375        forward_body += body;
376        return forward_body;
377}
378
379function emMessageSearch(e,value){
380        var     e  = is_ie ? window.event : e;
381        if(e.keyCode == 13) {
382                search_emails(value);
383        }
384}
385
386function emQuickSearch(emailList, field, ID){
387        var quickSearchKeyBegin;
388        var quickSearchKeyEnd;
389        if(expresso_offline) {
390                alert(get_lang('Not allowed in offline mode'));
391                return;
392        }
393               
394        var handler_emQuickSearch = function(data)
395        {
396                window_DropDownContacts = Element('tipDiv');
397                if (window_DropDownContacts.style.visibility != 'hidden'){
398                        window_DropDownContacts.style.visibility = 'hidden';
399                }
400               
401                if ((!data.status) && (data.error == "many results")){
402                        alert(get_lang('More than %1 results. Please, try to refine your search.',200));
403                        return false;
404                }
405                       
406                if (data.length > 0){
407                        if ((field != 'null') && (ID != 'null'))
408                        {
409                                expresso.connector.loadScript("jscode/QuickCatalogSearch");
410                                QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd);
411                        }
412                        else
413                        {
414                                expresso.connector.loadScript("jscode/QuickSearchUser");
415                                QuickSearchUser.showList(data);
416                        }
417                }
418                else
419                        alert(get_lang('None result was found.'));
420                return true;
421        };
422       
423        if ((field != 'null') && (ID != 'null'))
424        {
425                Element(field +'_'+ ID).focus(); //It requires for IE.
426                var i = getPosition(Element(field +'_'+ ID)); //inputBox.selectionStart;
427                var j = --i;
428
429                // Acha o inicio
430        while ((j >= 0) && (emailList.charAt(j) != ',')){j--};
431            quickSearchKeyBegin = ++j;
432
433            // Acha o final
434        while ((i <= emailList.length) && (emailList.charAt(i) != ',')){i++};
435            quickSearchKeyEnd = i;
436
437            // A Chave da Pesquisa
438        var search_for = trim(emailList.substring(quickSearchKeyBegin, quickSearchKeyEnd));
439        }
440        else
441                var search_for = emailList;
442       
443        if (search_for.length < preferences.search_characters_number){
444            alert(get_lang('Your search argument must be longer than %1 characters.', preferences.search_characters_number));
445            return false;
446        }
447       
448        cExecute ("expressoMail1_2.ldap_functions.quicksearch&search_for="+search_for+"&field="+field+"&ID="+ID, handler_emQuickSearch);
449}
450
451function folderbox(){
452        expresso.connector.loadScript("jscode/TreeS");
453        ttree.make_Window();
454}
455
456function filterbox(){
457        expresso.connector.loadScript("jscode/filter");
458        expresso.connector.loadScript("jscode/filters");
459        filters.Forms();
460}
461
462function sharebox(){
463        var handler_imap_getacl = function(data)
464        {
465                var options = '';
466                for (var x in data)
467                {
468                        options += "<option value='"+data[x].uid+"'>"+data[x].cn+"</option>";
469                }
470                expresso.connector.loadScript("jscode/sharemailbox");
471                sharemailbox.makeWindow(options);
472        };
473        cExecute ("expressoMail1_2.imap_functions.getacl", handler_imap_getacl);
474}
475
476function preferences_mail(){
477        location.href="../preferences/preferences.php?appname=expressoMail1_2";
478}
479
480function search_emails(value){
481        expresso.connector.loadScript("jscode/search");
482        EsearchE.showForms(value);
483}
484
485function source_msg(id_msg,folder){
486        var num_msg = id_msg.substr(0,(id_msg.length - 2));
487        var handler_source = function(data){
488                download_attachments(null, null, data, null,null,'fonte_da_mensagem.eml');
489        };
490        cExecute("expressoMail1_2.exporteml.export_msg",handler_source,"folder="+url_decode(folder)+"&msgs_to_export="+num_msg);
491}
492
493function Element (el) {
494        return  document.getElementById(el);
495}
496
497function getPosition(obj)
498{
499        if(typeof obj.selectionStart != "undefined")
500        {
501        return obj.selectionStart;
502        }
503        else if(document.selection && document.selection.createRange)
504        {
505                var M = document.selection.createRange();
506                try
507                {
508                        var Lp = M.duplicate();
509                        Lp.moveToElementText(obj);
510                }
511                catch(e)
512                {
513                        var Lp=obj.createTextRange();
514                }
515               
516                Lp.setEndPoint("EndToStart",M);
517                var rb=Lp.text.length;
518               
519                if(rb > obj.value.length)
520                {
521                        return -1;
522                }
523                return rb;
524        }
525};
526
527function increment_folder_unseen(){
528        var folder_id = get_current_folder();
529
530        var folder_unseen = Element('dftree_'+folder_id+'_unseen');
531        var abas_unseen = Element('new_m').innerHTML;
532        abas_unseen = abas_unseen.match( /[0-9]+/);
533
534        if (folder_unseen)
535        {
536                folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) + 1);
537        }
538        else
539        {
540                tree_folders.getNodeById(folder_id).alter({caption: tree_folders.getNodeById(current_folder).caption + '<font style=color:red>&nbsp(</font><span id="dftree_'+current_folder+'_unseen" style=color:red>1</span><font style=color:red>)</font>'});
541                tree_folders.getNodeById(folder_id)._refresh();
542        }
543        if (abas_unseen)
544        {
545                abas_unseen = parseInt(abas_unseen) + 1;
546                Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>';
547        }
548        else{
549                abas_unseen = Element('new_m').innerHTML;
550                abas_unseen = abas_unseen.match( /[0-9]+/);
551                abas_unseen = parseInt(abas_unseen) + 1;
552                Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>';
553        }
554        if ( current_folder.indexOf( 'INBOX' ) !== 0 && current_folder.indexOf( 'local_' ) !== 0 )
555        {
556                var display_unseen_in_shared_folders = Element('dftree_user_unseen');
557                if ( display_unseen_in_shared_folders )
558                        tree_folders.getNodeById( 'user' ).alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">' + ( parseInt( display_unseen_in_shared_folders.innerHTML) + 1 ) + '</span><font style=color:red>]</font>' + get_lang("Shared folders")});
559                else
560                        tree_folders.getNodeById( 'user' ).alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">1</span><font style=color:red>]</font>' + get_lang("Shared folders")});
561                tree_folders.getNodeById( 'user' )._refresh();
562        }
563        var display_unseen_in_mailbox = Element('dftree_root_unseen');
564        if(!expresso_offline)
565                var node_to_refresh = 'root';
566        else
567                var node_to_refresh = 'local_root';
568        tree_folders.getNodeById( node_to_refresh )._refresh();
569}
570function decrement_folder_unseen(){
571        var folder_id = get_current_folder();
572
573        var folder_unseen = Element('dftree_'+folder_id+'_unseen');
574        var abas_unseen = Element('new_m').innerHTML;
575        abas_unseen = abas_unseen.match( /[0-9]+/);
576
577        if(!folder_unseen || !abas_unseen)
578                return;
579
580        if ((folder_unseen) && (parseInt(folder_unseen.innerHTML) > 1))
581        {
582                folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) - 1);
583        }
584        else if (parseInt(folder_unseen.innerHTML) <= 1)
585        {
586                var tmp_folder_name = tree_folders.getNodeById(folder_id).caption.split('<');
587                var folder_name = tmp_folder_name[0];
588                tree_folders.getNodeById(folder_id).alter({caption: folder_name});
589                tree_folders.getNodeById(folder_id)._refresh();
590        }
591        if ((abas_unseen) && (parseInt(abas_unseen) > 1))
592        {
593                abas_unseen = (parseInt(abas_unseen) - 1);
594                Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>';
595        }
596        else if (parseInt(abas_unseen) <= 1)
597        {
598                Element('new_m').innerHTML = '0';
599        }
600        if ( current_folder.indexOf( 'INBOX' ) !== 0 )
601        {
602                var display_unseen_in_shared_folders = Element('dftree_user_unseen');
603                if ( display_unseen_in_shared_folders )
604                {
605                        var unseen_in_shared_folders = parseInt( display_unseen_in_shared_folders.innerHTML );
606                        unseen_in_shared_folders--;
607                        if ( unseen_in_shared_folders > 0 )
608                                tree_folders.getNodeById( 'user' ).alter({caption:'<font style=color:red>[</font><span id="dftree_root_unseen" style="color:red">' + unseen_in_shared_folders + '</span><font style=color:red>]</font>' + get_lang("My Folders")});
609                        else
610                                tree_folders.getNodeById( 'user' ).alter({caption:get_lang("Shared folders")});
611                        tree_folders.getNodeById( 'user' )._refresh();
612                }
613        }
614        var display_unseen_in_mailbox = Element('dftree_root_unseen');
615        if ( display_unseen_in_mailbox )
616        {
617                var unseen_in_mailbox = parseInt( display_unseen_in_mailbox.innerHTML );
618                unseen_in_mailbox--;
619                //if ( unseen_in_mailbox > 0 )
620                //      tree_folders.getNodeById( 'root' ).alter({caption:'<font style=color:red>[</font><span id="dftree_root_unseen" style="color:red">' + unseen_in_mailbox + '</span><font style=color:red>]</font>' + get_lang("My Folders")});
621                //else
622                if(!expresso_offline)
623                        var node_to_refresh = 'root';
624                else
625                        var node_to_refresh = 'local_root';
626                tree_folders.getNodeById( node_to_refresh ).alter({caption:get_lang("My Folders")});
627                tree_folders.getNodeById( node_to_refresh )._refresh();
628        }
629}
630
631//changes MENU background color.
632function set_menu_bg(menu)
633{
634        menu.style.backgroundColor = 'white';
635        menu.style.border = '1px solid black';
636        menu.style.padding = '0px 0px';
637}
638//changes MENU background color.
639function unset_menu_bg(menu)
640{
641        menu.style.backgroundColor = '';
642        menu.style.border = '0px';
643        menu.style.padding = '1px 0px';
644}
645
646function array_search(needle, haystack) {
647        var n = haystack.length;
648        for (var i=0; i<n; i++) {
649                if (haystack[i]==needle) {
650                        return true;
651                }
652        }
653        return false;
654}
655
656function lang_folder(fn) {
657        if (fn.toUpperCase() == "INBOX") return get_lang("Inbox");
658        if (special_folders[fn] && typeof(special_folders[fn]) == 'string') {
659                return get_lang(special_folders[fn]);
660        }
661        return fn;
662}
663
664function select_all_messages(select)
665{
666        var main = Element("tbody_box");
667        var main_list = main.childNodes;
668        var len_main_list = main_list.length;
669       
670        if (select)
671        {
672                for (i=0; i<len_main_list; i++)
673                {
674                        Element("check_box_message_"+main_list[i].id).checked = true;
675                        add_className(Element(main_list[i].id), 'selected_msg');
676                }
677        }
678        else
679        {
680                for (i=0; i<len_main_list; i++)
681                {
682                        Element("check_box_message_"+main_list[i].id).checked = false;
683                        remove_className(Element(main_list[i].id), 'selected_msg');
684                }
685        }
686};
Note: See TracBrowser for help on using the repository browser.