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

Revision 2618, 20.9 KB checked in by amuller, 14 years ago (diff)

Ticket #911 - Usando xconnector e transformando lang para API

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