source: trunk/expressoMail1_2/js/common_functions.js @ 470

Revision 470, 20.1 KB checked in by niltonneto, 16 years ago (diff)

Correção do índice de mensagens novas na pasta, que ficava em
vermelho mesmo tendo "0 mensagens novas", quando se usava o
filtro de relevância.

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