source: trunk/contactcenter/js/cc.js @ 5794

Revision 5794, 95.2 KB checked in by thiago, 12 years ago (diff)

Ticket #2508 - Edição de Contato no Modo Avançado.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1  /******************************************************************************\
2  * eGroupWare - Contacts Center                                                                                                *
3  * http://www.egroupware.org                                                                                                   *
4  * Written by:                                                                                                                                 *
5  *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>                   *
6  *  - Jonas Goes <jqhcb@users.sourceforge.net>                                                                 *
7  *  sponsored by Thyamad - http://www.thyamad.com                                                              *
8  * -------------------------------------------------------------------------   *
9  *  This program is free software; you can redistribute it and/or modify it    *
10  *  under the terms of the GNU General Public License as published by the              *
11  *  Free Software Foundation; either version 2 of the License, or (at your             *
12  *  option) any later version.                                                                                                 *
13  \******************************************************************************/
14
15/***********************************************\
16*                      TODO                     *
17\***********************************************/
18
19/*
20 * function setHeightSpace ()
21 *
22 */
23
24/***********************************************\
25*                   CONSTANTS                   *
26\***********************************************/
27
28var CC_STATUS_FULL_ADD = 2;
29var CC_STATUS_QUICK_ADD = 1;
30
31var CC_card_image_width = 245;
32var CC_card_image_height = 130;
33var CC_card_extra = 16;
34
35
36/***********************************************\
37*               GLOBALS VARIABLES               *
38\***********************************************/
39
40var owners = new Array();
41var flag_compartilhado = false;
42var qtd_compartilhado = 0;
43
44var CC_visual = 'table';
45/* Cards Variables */
46var CC_actual_letter = 'a';
47var CC_last_letter = 'a';
48var CC_actual_page = 1;
49var CC_npages = 0;
50var CC_max_cards = new Array();
51var CC_conn_count=0;
52
53var CC_old_icon_w = 0;
54var CC_old_icon_h = 0;
55
56/* Tabs Variables */
57var CC_last_tab = 0;
58
59/* Pseudo-Semafores */
60var CC_tree_available = false;
61var CC_full_add_const = false;
62var CC_full_add_photo = false;
63
64var CC_last_height = window.innerHeight;
65var CC_last_width = window.innerWidth;
66
67/* Contact Full Info */
68var CC_contact_full_info;
69var CC_br_index;
70
71/* Addresses Variables */
72var CC_addr_last_selected = 0;
73
74/* Connections Variables */
75var CC_conn_last_selected = 0;
76var not_informed_text;
77/* Grupos inicialmente selecionados */
78var CC_initial_selected_grps = new Array();
79
80
81
82/***********************************************\
83 *           FULL ADD/EDIT FUNCTIONS           *
84\***********************************************/
85
86function createPhotoFrame()
87{
88        photo_frame = document.createElement('iframe');
89        document.body.appendChild(photo_frame);
90
91        if (is_ie)
92        {
93                photo_form  = photo_frame.contentWindow.document.createElement('form');
94                photo_input = photo_frame.contentWindow.document.createElement('input');
95        }
96        else
97        {
98                 photo_form  = photo_frame.contentDocument.createElement('form');
99                 photo_input = photo_frame.contentDocument.createElement('input');
100        }
101
102        photo_frame.id = 'cc_photo_frame';
103        photo_frame.style.position = 'absolute';
104        //photo_frame.style.visibility = 'hidden';
105        photo_frame.style.top = '600px';
106        photo_frame.style.left = '0px';
107
108        photo_form.id = 'cc_photo_form';
109        photo_form.method = 'POST';
110        photo_form.enctype = 'multipart/form-data';
111
112        photo_input.id = 'cc_photo_input';
113        photo_input.type = 'file';
114
115        if (is_ie)
116        {
117                photo_frame.contentWindow.document.body.appendChild(photo_form);
118        }
119        else
120        {
121                photo_frame.contentDocument.body.appendChild(photo_form);
122        }
123        photo_form.appendChild(photo_input);
124
125}
126
127/********* Full Add Auxiliar Functions ****************/
128function selectOption (id, option)
129{
130        var obj = Element(id);
131        var max = obj.options.length;
132
133        if (option == undefined)
134        {
135                obj.selectedIndex = 0;
136        }
137        else
138        {
139                for (var i = 0; i < max; i++)
140                {
141                        if (obj.options[i].value == option)
142                        {
143                                obj.selectedIndex = i;
144                                break;
145                        }
146                }
147        }
148}
149
150function selectRadio (id, index)
151{
152        var obj = Element(id);
153        var max = obj.options.length;
154        for (var i = 0; i < max; i++)
155        {
156                i == index ? obj.options[i].checked = true : obj.options[i].checked = false;
157        }
158}
159
160function clearSelectBox(obj, startIndex)
161{
162        var nOptions = obj.options.length;
163
164        for (var i = nOptions - 1; i >= startIndex; i--)
165        {
166                obj.removeChild(obj.options[i]);
167        }
168}
169/********** Open/Close FullAdd *************/
170function openFullAdd(){
171        // Build the FullAdd Window.
172        if(!fullAddWin && !is_ie)
173                __f();
174
175        resetFullAdd();
176        populateFullAddConst();
177        fullAddWin.open();
178        tabs._showTab('cc_contact_tab_0');
179        Element('cc_full_add_window_clientArea').style.background = '#EEE';
180        Element("cc_conn_type_1").checked = false;
181        Element("cc_conn_type_2").checked = false;
182        Element("cc_conn_type_sel").disabled = true;
183        Element("cc_conn_type_sel").selectedIndex = 0;
184        Element("cc_contact_sharing").style.display = 'none';
185}
186
187function openFullAddShared(){
188        if (flag_compartilhado)
189        {
190                if(!fullAddWin && !is_ie)
191                        __f();
192
193                resetFullAdd();
194                populateFullAddConst();
195                fullAddWin.open();
196                tabs._showTab('cc_contact_tab_0');
197                Element("cc_conn_type_1").checked = false;
198                Element("cc_conn_type_2").checked = false;
199                Element("cc_conn_type_sel").disabled = true;
200                Element("cc_conn_type_sel").selectedIndex = 0;
201                Element("cc_contact_sharing").align = 'center';
202                Element("cc_contact_sharing").style.display = 'block';
203                Element("cc_contact_shared_types").disabled = true;
204                populateSharingSelect();
205        } else
206        {
207                if(qtd_compartilhado != 0)
208                {
209                        ccTree.select(0.2);
210                        ccTree.setCatalog(0.2);
211                        if(!fullAddWin && !is_ie)
212                                __f();
213                        resetFullAdd();
214                        populateFullAddConst();
215                        fullAddWin.open();
216                        tabs._showTab('cc_contact_tab_0');
217                        Element("cc_conn_type_1").checked = false;
218                        Element("cc_conn_type_2").checked = false;
219                        Element("cc_conn_type_sel").disabled = true;
220                        Element("cc_conn_type_sel").selectedIndex = 0;
221                        Element("cc_contact_sharing").aling = 'center';
222                        Element("cc_contact_sharing").style.display = 'block';
223                        Element("cc_contact_shared_types").disabled = true;
224                        populateSharingSelect();
225                } else
226                        showMessage(Element('cc_msg_err_shared').value);
227        }
228}
229
230function closeFullAdd(){
231        fullAddWin.close();
232}
233/******** Contact details ***********/
234function openContactDetails(id){
235        // Build the ContactDetails Window.
236        if((typeof(contactdetailsWin) == 'undefined') && !is_ie)
237                __cdWin();
238
239        contactdetailsWin.open();
240       
241        populateContactDetails(id);
242}
243
244function populateContactDetails(id)
245{
246        var handler = function(responseText)
247        {
248                var fieldsDiv = Element('id_cc_contact_details_fields');
249                var data = unserialize(responseText);
250                //alert(responseText);
251                fieldsDiv.innerHTML = "";
252                if (data && data.length > 0)
253                {
254                        //fieldsDiv.innerHTML = "";
255                        var table = document.createElement("table");
256                        table.border=0;
257                        //table.style.borderBottom = '1px solid #999';
258                        //table.cellSpacing = '0';
259                        table.width = '480px';
260                        var attr_name_size = '50%';
261                        var attr_value_size = '50%';
262                        for(i = 0; i < data.length; i++)
263                        {
264                                var row = table.insertRow(i);
265                                if ((i % 2) == 0)
266                                        row.setAttribute('class', 'row_off');
267                                else
268                                        row.setAttribute('class', 'row_on');
269                                //row.style.borderBottom = '1px solid #999';
270                                attr_name = row.insertCell(0);
271                                attr_value = row.insertCell(1);
272                                attr_name.style.width = attr_name_size;
273                                attr_value.style.width = attr_value_size;
274                                attr_name.innerHTML = data[i]['name'];
275                                if (data[i]['type'] == 'text')
276                                        attr_value.innerHTML = data[i]['value'];
277                                else
278                                {
279                                        var multivalue_div = document.createElement("div");
280                                        multivalue_div.style.overflow = 'auto';
281                                        multivalue_div.style.height = '100px';
282                                        multivalue_div.style.border = '1px solid #999';
283                                        //multivalue_div.style.backgroundColor = 'transparent';
284                                        for (j = 0; j < data[i]['value'].length; j++)
285                                        {
286                                                multivalue_div.appendChild(document.createTextNode(data[i]['value'][j]));
287                                                multivalue_div.appendChild(document.createElement("br"));
288                                        }
289                                        attr_value.appendChild(multivalue_div);
290                                }       
291                        }
292                        fieldsDiv.appendChild(table);
293                }
294                else
295                        fieldsDiv.innerHTML = Element('cc_contact_details_no_fields').value;
296        };
297        Connector.newRequest('populateContactDetails', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_contact_details&id=' + id, 'GET', handler);
298}
299
300function closeContactDetails(){
301        contactdetailsWin.close();
302}
303/********** New Contact *************/
304function newContact(){
305        openFullAdd();
306}
307function newSharedContact(){
308        openFullAddShared();
309}
310/************ Edit Contact *************/
311function editContact (id){
312        openFullAdd();
313        populateFullEdit(id,'bo_people_catalog');
314}
315function editSharedContact (id){
316        openFullAdd();
317        populateFullEdit(id,'bo_shared_people_manager');
318}
319/************ Edit Group *************/
320function editGroup(id){
321        populateEditGroup(id);
322        ccAddGroup.window.open();
323}
324
325function editSharedGroup(id,shared){
326        populateEditSharedGroup(id, shared);   
327}
328
329/*
330        Updates all the constant fields in the
331        full add window, like Prefixes, Suffixes,
332        Countries and Types
333*/
334
335function populateSharingSelect()
336{
337        var handler = function(responseText)
338        {
339                var data = unserialize(responseText);
340                        var sharers = Element('cc_contact_shared_types');
341
342                if (typeof(data) != 'object')
343            {
344                showMessage(Element('cc_msg_err_contacting_server').value);
345                fullAddWin.close();
346                                return;
347            }else{
348                                sharers.disabled = false;
349                                j = 1;
350                                for (var i in data)
351                                {
352                                                sharers.options[j] = new Option(data[i]['cn'], i);
353                                                owners[j] = i;
354                                                j++;
355                                }
356                                return;
357                 }
358        };
359        Connector.newRequest('populateSharingSelect', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_list_owners_perms_add', 'POST', handler);
360}
361
362function populateFullAddConst()
363{
364        CC_full_add_const = false;
365
366        setTimeout('populateFullAddConstAsync()', 10);
367}
368
369function populateFullAddConstAsync()
370{
371        var handler = function(responseText)
372        {
373                //Element('cc_debug').innerHTML = responseText;
374                var data = unserialize(responseText);
375                var i = 1;
376                var j;
377
378                if (typeof(data) != 'object')
379                {
380                        showMessage(Element('cc_msg_err_contacting_server').value);
381                        return;
382                }
383
384                /* Populate Prefixes */
385                for (j in data[0])
386                {
387                        Element('cc_pd_prefix').options[i] = new Option(data[0][j], j);
388                        i++;
389                }
390
391                /* Populate Suffixes */
392                i = 1;
393                for (j in data[1])
394                {
395                        Element('cc_pd_suffix').options[i] = new Option(data[1][j], j);
396                        i++;
397                }
398
399                /* Populate Addresses Types */
400                i = 1;
401                for (j in data[2])
402                {
403                        Element('cc_addr_types').options[i] = new Option(data[2][j], j);
404                        i++;
405                }
406
407                /* Populate Countries */
408                i = 1;
409                for (j in data[3])
410                {
411                        Element('cc_addr_countries').options[i] = new Option(data[3][j], j);
412
413                        if (j == 'BR' || j == 'br')
414                        {
415                                CC_br_index = i;
416                        }
417
418                        i++;
419                }
420
421                /* Populate Connection Types */
422                /*
423                 * Código não funcional com o expresso.
424                 */
425                /*i = 1;
426                for (j in data[4])
427                {
428                        Element('cc_conn_type').options[i] = new Option(data[4][j], j);
429                        i++;
430                }*/
431               
432                /* Populate Relations Types */
433                /*
434                 * Código conflitante com a modificação de seleção de grupos durante
435                 * a criação de um novo contato. Também foi verificado que este código não
436                 * é funcional.
437                 */
438                /*
439                i = 0;
440                for (j in data[5])
441                {
442                        Element('cc_rels_type').options[i] = new Option(data[5][j], j);
443                        i++;
444                }*/
445               
446                /* Populate available groups */
447                i = 0;
448                var grupos = data[5];
449                for (var grupo in grupos)
450                {
451                        Element('id_grps_available').options[i] = new Option(grupos[grupo]['title'], grupos[grupo]['id_group']);
452                        i++;
453                }
454
455                CC_full_add_const = true;
456
457        };
458
459        Connector.newRequest('populateFullAddConst', CC_url+'get_contact_full_add_const', 'GET', handler);
460}
461
462/*
463 * Função que faz a seleção do grupo.
464 * Autor: Luiz Carlos Viana Melo - Prognus
465 */
466function selectGroup()
467{
468        grps_avail = Element('id_grps_available');
469        grps_selec = Element('id_grps_selected');
470       
471        for (i = 0; i < grps_avail.length; i++)
472        {
473                if (grps_avail.options[i].selected) {
474                        isSelected = false;
475
476                        for(var j = 0;j < grps_selec.options.length; j++) {                                                                                                                                                     
477                                if(grps_selec.options[j].value === grps_avail.options[i].value){
478                                        isSelected = true;
479                                        break; 
480                                }
481                        }
482
483                        if(!isSelected){
484
485                                option = document.createElement('option');
486                                option.value = grps_avail.options[i].value;
487                                option.text = grps_avail.options[i].text;
488                                option.selected = false;
489                                grps_selec.options[grps_selec.options.length] = option;
490                                                                               
491                        }
492                                                                                       
493                }
494        }
495       
496        for (j =0; j < grps_avail.options.length; j++)
497                grps_avail.options[j].selected = false;
498}
499
500/*
501 * Função que remove um grupo selecionado.
502 * Autor: Luiz Carlos Viana Melo - Prognus
503 */
504function deselectGroup()
505{
506        grps_selec = Element('id_grps_selected');
507
508        for(var i = 0;i < grps_selec.options.length; i++)                               
509                if(grps_selec.options[i].selected)
510                        grps_selec.options[i--] = null;
511}
512
513function populateFullEdit (id,catalog)
514{
515        var handler = function(responseText)
516        {
517                //Element('cc_debug').innerHTML = responseText;
518                var data = unserialize(responseText);
519
520                if (typeof(data) != 'object' || data['result'] != 'ok')
521                {
522                        showMessage(Element('cc_msg_err_contacting_server').value);
523                        return;
524                }
525
526                resetFullAdd();
527
528                CC_contact_full_info = data;
529                Element('cc_full_add_contact_id').value = data['cc_full_add_contact_id'];
530                populatePersonalData(data['personal']);
531                populateContactGroups(data['groups']);
532                //populateRelations(data['relations']);
533        };
534        Connector.newRequest('populateFullEdit', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_full_data&id=' + id + "&catalog="+catalog, 'GET', handler);
535}
536
537/*
538 * Função que preenche a lista de grupos a qual o contato pertence.
539 * Autor: Luiz Carlos Viana Melo - Prognus
540 */
541function populateContactGroups(groupsData)
542{
543        groups_selected = Element('id_grps_selected');
544        var i = 0;
545        CC_initial_selected_grps = new Array();
546        for (var group in groupsData)
547        {
548                var id_group = groupsData[group]['id_group'];
549                option = document.createElement('option');
550                option.value = id_group;
551                option.text = groupsData[group]['title'];
552                option.selected = false;
553                groups_selected.options[i++] = option;
554                CC_initial_selected_grps[id_group] = new Array();
555                CC_initial_selected_grps[id_group]['id_group'] = id_group;
556                CC_initial_selected_grps[id_group]['title'] = groupsData[group]['title'];
557                CC_initial_selected_grps[id_group]['short_name'] = groupsData[group]['short_name'];
558        }
559}
560
561function populateEditGroup (id)
562{
563        populateEditSharedGroup(id,false);
564}
565
566function populateEditSharedGroup(id,shared) {
567        var handler = function(responseText)
568        {                       
569                var data = unserialize(responseText);
570
571                Element('group_id').value = data['id_group'];                                                           
572                var options_contact_list = Element('span_contact_list');
573                var select_contact_list = '<select id="contact_list" multiple name="contact_list[]" style="width:280px" size="10">';
574                select_contact_list += data['contact_list'] + "</select>";
575                options_contact_list.innerHTML = select_contact_list;
576               
577                if(data['id_group']) {
578                        Element('title').value =  data['title'];       
579                        if(data['contact_in_list']) {                                   
580                                for(i = 0; i < data['contact_in_list'].length; i++) {                           
581                                        option = document.createElement('option');
582                                        option.value = data['contact_in_list'][i]['id_connection'];
583                                        option.text = data['contact_in_list'][i]['names_ordered']+' ('+data['contact_in_list'][i]['connection_value']+')';                             
584                                        Element('contact_in_list').options[Element('contact_in_list').options.length] = option;
585                                }
586                        }               
587                       
588                        Element('title').value =  data['title'];
589                }
590                               
591                if (typeof(data) != 'object' || data['result'] != 'ok')
592                {
593                        showMessage(Element('cc_msg_err_contacting_server').value);
594                        return;
595                }
596                ccAddGroup.setSelectedSourceLevel(ccTree.actualLevel);
597                ccAddGroup.openEditWindow();
598        };
599               
600        id = typeof(id) == 'undefined' ? id = 0 :  id;
601       
602        ccAddGroup.clear(true);                 
603        if(!shared)
604                Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id, 'GET', handler);
605        else
606                Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id+'&shared_from='+shared, 'GET', handler);
607}
608
609
610
611function resetFullAdd()
612{
613        /* Groups */
614        gprs_selected = Element('id_grps_selected');
615        if(gprs_selected != null){
616                for (j =0; j < gprs_selected.options.length; j++) {
617                        gprs_selected.options[j].selected = false;
618                        gprs_selected.options[j--] = null;
619                }
620        }
621        /* Clear information container */
622        CC_contact_full_info = new Array();
623
624        /* Clear Fields */
625        Element('cc_full_add_form_personal').reset();
626        Element('cc_full_add_form_addrs').reset();
627        if(Element('cc_contact_type').value=='advanced')
628                Element('cc_full_add_form_corporative').reset();
629        /* Personal Data */
630        Element('cc_full_add_contact_id').value = null;
631        Element('cc_pd_photo').src = 'templates/default/images/photo.png';
632
633        /* Addresses */
634        resetAddressFields();
635
636        /* Connections */
637        CC_conn_last_selected = '_NONE_';
638        Element("cc_phone_default").options.selectedIndex = '-1';
639        Element("cc_email_default").options.selectedIndex = '-1';
640        Element("div_cc_conn_is_default").style.display = 'none';
641        clearConn();
642}
643
644function postFullAdd()
645{
646        if (!checkFullAdd())
647        {
648                return false;
649        }
650
651        /* First thing: Send Photo */
652        if (Element('cc_pd_select_photo').value != '' && !is_ie)
653        {
654                var nodes;
655                var form, frame, old_frame;
656
657                CC_full_add_photo = false;
658
659                old_frame = Element('cc_photo_frame');
660                if (!old_frame)
661                {
662                        frame = document.createElement('iframe');
663                }
664                else
665                {
666                        frame = old_frame;
667                }
668
669                frame.id = 'cc_photo_frame';
670                frame.style.visibility = 'hidden';
671                frame.style.top = '0px';
672                frame.style.left = '0';
673                frame.style.position = 'absolute';
674                document.body.appendChild(frame);
675
676                form = frame.contentDocument.createElement('form');
677
678                var id_contact = Element('cc_full_add_contact_id').value;
679                form.id = 'cc_form_photo';
680                form.method = 'POST';
681                form.enctype = 'multipart/form-data';
682                form.action = 'http://'+ document.domain + Element('cc_root_dir').value+'../index.php?menuaction=contactcenter.ui_data.data_manager&method=post_photo&id='+(id_contact != '' && id_contact != 'null' ? id_contact : '');
683
684                var input_clone = Element('cc_pd_select_photo').cloneNode(false);
685                form.appendChild(input_clone);
686
687                frame.contentDocument.body.appendChild(form);
688                form.submit();
689
690                CC_full_add_photo = true;
691        }
692        else if (Element('cc_pd_select_photo_t').value != '' && is_ie)
693        {
694                CC_full_add_photo = false;
695
696                var frame = Element('cc_photo_frame');
697                var form = frame.contentWindow.document.all['cc_photo_form'];
698                var id_contact = Element('cc_full_add_contact_id').value;
699                form.action = 'http://'+ document.domain + Element('cc_root_dir').value+'../index.php?menuaction=contactcenter.ui_data.data_manager&method=post_photo&id='+(id_contact != '' && id_contact != 'null' ? id_contact : '');
700
701                form.submit();
702
703                setTimeout('Element(\'cc_photo_frame\').src = \'cc_photo_frame.html\'', 1000);
704                CC_full_add_photo = true;
705        }
706        if (Element('cc_contact_sharing').style.display == 'none')
707        setTimeout('postFullAddInfo()', 100);
708        else
709                setTimeout('postFullAddInfoShared()', 100);
710
711        updateCards();
712}
713
714function postFullAddInfo()
715{
716        var handler = function (responseText)
717        {
718                var data = unserialize(responseText);
719
720                if (typeof(data) != 'object')
721                {
722                        showMessage(Element('cc_msg_err_contacting_server').value);
723                        return;
724                }
725
726                if (data['status'] != 'ok')
727                {
728                        showMessage(data['msg']);
729                        return;
730                }
731
732                fullAddWin.close();
733                updateCards();
734        };
735
736        Connector.newRequest('postFullAddInfo', CC_url+'post_full_add', 'POST', handler, getFullAddData());
737}
738
739function postFullAddInfoShared()
740{
741        var handler = function (responseText)
742        {
743                var data = unserialize(responseText);
744                if (typeof(data) != 'object')
745                {
746                        showMessage(Element('cc_msg_err_contacting_server').value);
747                        return;
748                }
749
750                if (data['status'] != 'ok')
751                {
752                        showMessage(data['msg']);
753                        return;
754                }
755
756                fullAddWin.close();
757                updateCards();
758        };
759        Connector.newRequest('postFullAddInfoShared', CC_url+'post_full_add_shared', 'POST', handler, getFullAddData());
760}
761
762function getFullAddData()
763{
764        var data = new Array();
765        var empty = true;
766        var replacer = '__##AND##__';
767
768        data['commercialAnd'] = replacer;
769
770        if (Element('cc_full_add_contact_id').value != '' && Element('cc_full_add_contact_id').value != 'null')
771        {
772                data['id_contact'] = replaceComAnd(Element('cc_full_add_contact_id').value, replacer);
773                data.length++;
774        }
775
776        /* Owner do contato (Para o caso de adicao de contato compartilhado) */
777        if (Element('cc_contact_sharing').style.display == 'block')
778        {
779                var index = Element('cc_contact_shared_types').selectedIndex;
780                data['owner'] = replaceComAnd(owners[index], replacer);
781                data.length++;
782        }
783
784        /* Status: Full Added */
785        data['id_status'] = CC_STATUS_FULL_ADD;
786
787        /* Personal Data */
788        data['alias']         = replaceComAnd(Element('cc_pd_alias').value, replacer);
789        data['id_prefix']     = replaceComAnd(Element('cc_pd_prefix').value, replacer);
790        data['given_names']   = replaceComAnd(Element('cc_pd_given_names').value, replacer);
791        data['family_names']  = replaceComAnd(Element('cc_pd_family_names').value, replacer);
792        data['names_ordered'] = replaceComAnd(data['given_names']+" "+data['family_names'], replacer);
793        data['id_suffix']     = replaceComAnd(Element('cc_pd_suffix').value, replacer);;
794        data['birthdate_0']   = replaceComAnd(Element('cc_pd_birthdate_0').value, replacer);
795        data['birthdate_1']   = replaceComAnd(Element('cc_pd_birthdate_1').value, replacer);
796        data['birthdate_2']   = replaceComAnd(Element('cc_pd_birthdate_2').value, replacer);
797//      data['sex']           = Element('cc_pd_sex').value == 1 ? 'M' : Element('cc_pd_sex').value == 2 ? 'F' : null;
798        data['pgp_key']       = replaceComAnd(Element('cc_pd_gpg_finger_print').value, replacer);
799        data['notes']         = replaceComAnd(Element('cc_pd_notes').value, replacer);
800
801        data.length += 14;
802        //corporative
803
804        if (document.getElementById('cc_contact_type').value == 'advanced') {
805                data['corporate_name'] = replaceComAnd(document.getElementById('cc_name_corporate').value, replacer);
806                data['job_title'] = replaceComAnd(document.getElementById('cc_job_title').value, replacer);
807                data['department'] = replaceComAnd(document.getElementById('cc_department').value, replacer);
808                data['web_page'] = replaceComAnd(document.getElementById('cc_web_page').value, replacer);
809                data.length += 18;
810        }
811
812        /* Addresses */
813        saveAddressFields();
814        data['addresses'] = CC_contact_full_info['addresses'];
815
816        /* Connection */
817        saveConnFields();
818
819        if (CC_contact_full_info['connections'])
820        {
821                var connNumber = 0;
822                for (var type in CC_contact_full_info['connections'])
823                {
824                        if (type == 'length')
825                        {
826                                continue;
827                        }
828
829                        if (typeof(data['connections']) != 'object')
830                        {
831                                data['connections'] = new Array();
832                        }
833
834                        for (var i in CC_contact_full_info['connections'][type])
835                        {
836                                if (i == 'length')
837                                {
838                                        continue;
839                                }
840
841                                if (typeof(data['connections']['connection'+connNumber]) != 'object')
842                                {
843                                        data['connections']['connection'+connNumber] = new Array(5);
844                                }
845
846                                data['connections']['connection'+connNumber]['id_connection'] = CC_contact_full_info['connections'][type][i]['id'];
847                                data['connections']['connection'+connNumber]['id_typeof_connection'] = type;
848                                data['connections']['connection'+connNumber]['connection_name'] = CC_contact_full_info['connections'][type][i]['name'];
849                                data['connections']['connection'+connNumber]['connection_value'] = CC_contact_full_info['connections'][type][i]['value'];
850                                if(Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default").value) {
851                                        if(Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default").value == CC_contact_full_info['connections'][type][i]['name']){
852                                                data['connections']['connection'+connNumber]['connection_is_default']  = 'TRUE';
853                                        }
854                                        else
855                                                data['connections']['connection'+connNumber]['connection_is_default']  = 'FALSE';
856                                }
857
858//                              data['connections']['connection'+connNumber].length = 5;
859
860                                empty = false;
861                                connNumber++;
862                                data['connections'].length++;
863                        }
864
865                }
866
867                if (!empty)
868                {
869                        data.length++;
870                        empty = true;
871                }
872        }
873
874        if (CC_contact_full_info['removed_conns'])
875        {
876                empty = false;
877
878                if (typeof(data['connections']) != 'object')
879                {
880                        data['connections'] = new Array();
881                        data.length++;
882                }
883
884                data['connections']['removed_conns'] = CC_contact_full_info['removed_conns'];
885                data['connections'].length++;
886        }
887
888        data['groups'] = getAddedRemovedGroups();
889       
890        var serial = serialize(data);
891        return 'data=' + escape(serialize(data));
892}
893
894/*
895 * Função que retorna os grupos que foram anteriormente selecionados, adicionados ou removidos pelo
896 * usuário. O formato retornado é um array contendo:
897 * ['previous_selected'] {
898 *      [id_group] {
899 *              'id_group'              => o ID do grupo
900 *              'title'                 => o título do grupo
901 *      }
902 * ['added'] {
903 *      [id_group] {
904 *              'id_group'              => o ID do grupo
905 *              'title'                 => o título do grupo
906 *      }
907 * },
908 * ['removed'] {
909 *      [id_group] {
910 *              'id_group'              => o ID do grupo
911 *              'title'                 => o título do grupo
912 *      }
913 * }
914 * Autor: Luiz Carlos Viana Melo - Prognus
915 */
916function getAddedRemovedGroups()
917{
918        var selected_groups = getSelectedGroups();
919        var added_groups = diffContactIDArray(selected_groups, CC_initial_selected_grps);
920        var removed_groups = diffContactIDArray(CC_initial_selected_grps, selected_groups);
921        var groups = new Array();
922        groups['previous_selected'] = CC_initial_selected_grps;
923        groups['added'] = added_groups;
924        groups['removed'] = removed_groups;
925        return groups;
926}
927
928/*
929 * Função que retorna os grupos que foram selecionados pelo usuário. O formato retornado é:
930 * [id_group] {
931 *      'id_group'              => o ID do grupo
932 *      'title'                 => o título do grupo
933 * }
934 * Autor: Luiz Carlos Viana Melo - Prognus
935 */
936function getSelectedGroups()
937{
938        var gprs_selected = Element('id_grps_selected');
939        var data = new Array();
940        for(i = 0; i < gprs_selected.options.length; i++)
941        {
942                var id_group = gprs_selected.options[i].value;
943                data[id_group] = new Array();
944                data[id_group]['id_group'] = id_group;
945                data[id_group]['title'] = gprs_selected.options[i].text;
946        }
947        return data;
948}
949
950/*
951 * Função que retorna a diferença entre 2 arrays com ID dos contatos.
952 * Autor: Luiz Carlos Viana Melo - Prognus
953 */
954function diffContactIDArray(array1, array2)
955{
956        var diff = new Array();
957        for (var group in array1)
958        {
959                if (!array2[group])
960                        diff.push(array1[group]);
961        }
962        return diff;
963}
964
965function checkFullAdd()
966{
967
968        /* Checa se o listbox esta desativado ou é nulo, ou seja, não existe catálogos compartilhados com o user atual */
969
970        if (!(Element('cc_contact_sharing').style.display == 'none' ))
971        {
972                if (Element('cc_contact_shared_types').disabled == true)
973                {
974                        showMessage('Nenhum catálogo compartilhado existente');
975                        return false;
976                }
977                if (Element('cc_contact_shared_types').selectedIndex == 0)
978                {
979                        showMessage('Nenhum catálogo selecionado');
980                        return false;
981                }
982        }
983
984        /* Check Personal Data */
985
986        if (Element('cc_pd_given_names').value == '')
987        {
988                showMessage(Element('cc_msg_err_empty_field').value + " => " + Element('cc_pd_given_names').name);
989                return false;
990        }
991
992        /* Check Addresses */
993
994        /* Check Connections */
995
996        saveConnFields();
997
998        var comp = /^[a-zA-Z\d(-)\.@_ -]{0,200}$/;
999    haveConnections = false;
1000    if (CC_contact_full_info['connections']){       
1001        for (var type in CC_contact_full_info['connections']){
1002            haveConnections = true;
1003                        var reEmail = /^[a-zA-Z0-9][_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*$/;
1004            for (var i in CC_contact_full_info['connections'][type]){
1005                                if(type == 1){
1006                                        if(!reEmail.test(CC_contact_full_info['connections'][type][i]['value'])){
1007                                                showMessage('Endereço para conexão de ' + CC_contact_full_info['connections'][type][i]['name'] + ', não é válido');
1008                                                return false;
1009                                        }
1010                                }
1011                                else{
1012                if((CC_contact_full_info['connections'][type][i]['value'].length < 4) ||
1013                    (!comp.test(CC_contact_full_info['connections'][type][i]['value']))){
1014                    showMessage('Endereço para conexão de ' + CC_contact_full_info['connections'][type][i]['name'] + ', não é válido');
1015                    return false;
1016                }
1017            }
1018            }
1019            var _options_default = Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default");
1020            if(_options_default.value == '-1') {
1021                alert("É necessário escolher um "+ (type == 1 ? 'E-mail' : 'Telefone')+" como padrão!");
1022                return false;
1023            }
1024        }
1025    }
1026
1027    /* Check Relations */
1028
1029    return true;
1030
1031}
1032
1033/********* Personal Data Functions *********/
1034/*
1035 * data[0] => cc_pd_select_photo
1036 * data[1] => cc_pd_alias
1037 * data[2] => cc_pd_given_names
1038 * data[3] => cc_pd_family_names
1039 * data[4] => cc_pd_full_name
1040 * data[5] => cc_pd_suffix
1041 * data[6] => cc_pd_birthdate
1042 * data[7] => cc_pd_sex SELECT
1043 * data[8] => cc_pd_prefix
1044 * data[9] => cc_pd_gpg_finger_print
1045 * data[10] => cc_pd_notes
1046 */
1047
1048function populatePersonalData (data)
1049{
1050        for (i in data)
1051        {
1052                switch(i)
1053                {
1054                        case 'cc_pd_suffix':
1055                        case 'cc_pd_sex':
1056                        case 'cc_pd_prefix':
1057                                selectOption(i, data[i]);
1058                                break;
1059
1060                        case 'cc_pd_photo':
1061                                if (data[i])
1062                                {
1063                                        //Codigo para exibicao da imagem do contato no IE
1064                                        //Douglas Lopes Gomes - Prognus Software Livre
1065                                        if (Element(i)[1] && Element(i)[1].src){ //Se o navegador éo IE
1066                                                Element(i)[1].src = data[i] + '&'+ Math.random();
1067                                        } else { //Se o navegador não é o IE
1068                                        Element(i).src =  data[i] + '&'+ Math.random();
1069                                        }
1070                                }
1071                                break;
1072
1073                        default:
1074                                Element(i).value = data[i] == undefined ? '' : unescape(data[i]);
1075                }
1076        }
1077
1078        return;
1079}
1080
1081/********* End Personal Data Functions *********/
1082
1083
1084/********* Addresses Functions *********/
1085function resetAddressFields()
1086{
1087        Element('cc_addr_types').selectedIndex = 0;
1088
1089        Element('cc_addr_countries').selectedIndex = 0;
1090        Element('cc_addr_countries').disabled = true;
1091
1092        Element('cc_addr_states').selectedIndex = 0;
1093        Element('cc_addr_states').disabled = true;
1094        Element('cc_addr_states_new').disabled = true;
1095        Element('cc_addr_states_new').readonly = true;
1096        Element('cc_addr_states_new').value = '';
1097
1098        Element('cc_addr_cities').selectedIndex = 0;
1099        Element('cc_addr_cities').disabled = true;
1100        Element('cc_addr_cities_new').disabled = true;
1101        Element('cc_addr_cities_new').readonly = true;
1102        Element('cc_addr_cities_new').value = '';
1103
1104        Element('cc_addr_id').value = '';
1105
1106        resetAddrFillingFields();
1107}
1108
1109function resetAddrFillingFields()
1110{
1111        Element('cc_addr_1').value = '';
1112        Element('cc_addr_2').value = '';
1113        Element('cc_addr_other').value = '';
1114        Element('cc_addr_complement').value = '';
1115        Element('cc_addr_postal_code').value = '';
1116        Element('cc_addr_po_box').value = '';
1117        Element('cc_addr_is_default').checked = false;
1118}
1119
1120function disableAddrFillingFields()
1121{
1122        Element('cc_addr_1').readonly = true;
1123        Element('cc_addr_1').disabled = true;
1124        Element('cc_addr_2').readonly = true;
1125        Element('cc_addr_2').disabled = true;
1126        Element('cc_addr_other').readonly = true;
1127        Element('cc_addr_other').disabled = true;
1128        Element('cc_addr_complement').readonly = true;
1129        Element('cc_addr_complement').disabled = true;
1130        Element('cc_addr_postal_code').readonly = true;
1131        Element('cc_addr_postal_code').disabled = true;
1132        Element('cc_addr_po_box').readonly = true;
1133        Element('cc_addr_po_box').disabled = true;
1134        Element('cc_addr_is_default').readonly = true;
1135        Element('cc_addr_is_default').disabled = true;
1136}
1137
1138function updateAddressFields()
1139{
1140        var type = Element('cc_addr_types');
1141        var oldSelected = type.value;
1142
1143        saveAddressFields();
1144
1145        if (oldSelected == '_NONE_')
1146        {
1147                resetAddressFields();
1148                return true;
1149        }
1150
1151        CC_addr_last_selected = type.selectedIndex;
1152
1153        Element('cc_addr_countries').disabled = false;
1154
1155        var data = CC_contact_full_info['addresses'];
1156        var addrIndex  = 'address'+Element('cc_addr_types').value;
1157
1158        if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object')
1159        {
1160                resetAddressFields();
1161                Element('cc_addr_countries').disabled = false;
1162                Element('cc_addr_countries').selectedIndex = CC_br_index;
1163                type.value = oldSelected;
1164                updateAddrStates();
1165                return true;
1166        }
1167
1168        var addrTypeID = Element('cc_addr_types').value;
1169
1170        data = CC_contact_full_info['addresses'][addrIndex];
1171
1172        Element('cc_addr_id').value                              = data['id_address']           ? data['id_address']                    : '';
1173        Element('cc_addr_1').value                              = data['address1']                      ? data['address1']                              : '';
1174        Element('cc_addr_2').value                              = data['address2']                      ? data['address2']                              : '';
1175        Element('cc_addr_complement').value   = data['complement']              ? data['complement']            : '';
1176        Element('cc_addr_other').value                          = data['address_other'] ? data['address_other'] : '';
1177        Element('cc_addr_postal_code').value    = data['postal_code']           ? data['postal_code']           : '';
1178        Element('cc_addr_po_box').value                 = data['po_box']                                ? data['po_box']                : '';
1179        Element('cc_addr_is_default').checked   = data['address_is_default'] == '1' ? true: false;
1180
1181        Element('cc_addr_countries').value    = data['id_country'];
1182        updateAddrStates();
1183}
1184
1185function updateAddrStates()
1186{
1187        var states = Element('cc_addr_states');
1188        if (Element('cc_addr_countries').value == '_NONE_')
1189        {
1190                states.disabled = true;
1191                states.selectedIndex = 0;
1192                clearSelectBox(states, 4);
1193                updateAddrCities();
1194                return;
1195        }
1196
1197        updateAddrFillingFields();
1198        populateStates();
1199}
1200
1201function populateStates()
1202{
1203        var states = Element('cc_addr_states');
1204        var cities = Element('cc_addr_cities');
1205        var handler = function (responseText)
1206        {
1207                var data = unserialize(responseText);
1208
1209                clearSelectBox(states, 1);
1210
1211                if (typeof(data) != 'object')
1212                {
1213                        showMessage(Element('cc_msg_err_contacting_server').value);
1214
1215                        return;
1216                }
1217
1218                if (data['status'] == 'empty')
1219                {
1220                        states.disabled = true;
1221                        cities.disabled = true;
1222                        states.selectedIndex = 0;
1223                        cities.selectedIndex = 0;
1224                        return;
1225                }
1226                else if (data['status'] != 'ok')
1227                {
1228                        showMessage(data['msg']);
1229                        states.disabled = true;
1230                        states.selectedIndex = 0;
1231                        updateAddrCities();
1232                        return;
1233                }
1234                states.disabled = false;
1235                var i = 1;
1236                for (var j in data['data'])
1237                {
1238                        states.options[i] = new Option(data['data'][j], j);
1239                        if(i == 1) data['data'] = data['data'].sort();
1240                        i++;
1241                }
1242
1243                states.disabled = false;
1244                states.selectedIndex = 0;
1245
1246                data = CC_contact_full_info['addresses'];
1247                var addrIndex = 'address'+Element('cc_addr_types').value;
1248                if (data && data[addrIndex])
1249                {
1250                        states.value = data[addrIndex]['id_state'];
1251                        if (states.value == '_NEW_')
1252                        {
1253                                if (CC_contact_full_info['addresses']['new_states'][addrIndex])
1254                                {
1255                                        Element('cc_addr_states_new').value = CC_contact_full_info['addresses']['new_states'][addrIndex];
1256                                }
1257                                updateAddrNewStateOnMouseOut();
1258                        }
1259                        updateAddrCities();
1260                }
1261        };
1262
1263        Connector.newRequest('populateStates', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_states&country='+Element('cc_addr_countries').value, 'GET', handler);
1264}
1265
1266function updateAddrCities()
1267{
1268        var states = Element('cc_addr_states');
1269        var cities = Element('cc_addr_cities');
1270        var newState = Element('cc_addr_states_new');
1271        var requestStr;
1272
1273        switch (states.value)
1274        {
1275                case '_NONE_':
1276                        newState.readonly = true;
1277                        newState.disabled = true;
1278                        newState.value = '';
1279
1280                        cities.disabled = true;
1281                        cities.selectedIndex = 0;
1282                        updateAddrFillingFields();
1283                        return;
1284
1285                case '_NEW_':
1286
1287                        newState.readonly = false;
1288                        newState.disabled = false;
1289                        updateAddrNewStateOnMouseOut();
1290
1291                        cities.disabled = false;
1292                        clearSelectBox(cities, 3);
1293                        cities.selectedIndex = 1;
1294                        updateAddrFillingFields();
1295                        return;
1296
1297                case '_SEP_': return;
1298
1299                case '_NOSTATE_':
1300                        clearSelectBox(cities, 3);
1301
1302                        cities.disabled = false;
1303                        cities.selectedIndex = 0;
1304
1305                        requestStr = 'country='+Element('cc_addr_countries').value;
1306                        break;
1307
1308                default:
1309                        requestStr = 'country='+Element('cc_addr_countries').value+'&state='+states.value;
1310        }
1311
1312        newState.readonly = true;
1313        newState.disabled = true;
1314        newState.value = '';
1315
1316        populateCities(requestStr);
1317}
1318
1319function populateCities(requestStr)
1320{
1321        var cities = Element('cc_addr_cities');
1322
1323        var handler = function (responseText)
1324        {
1325                var data = unserialize(responseText);
1326
1327                clearSelectBox(cities, 1);
1328
1329                if (typeof(data) != 'object')
1330                {
1331                        showMessage(Element('cc_msg_err_contacting_server').value);
1332
1333                        return;
1334                }
1335
1336                if (data['status'] == 'empty')
1337                {
1338                        cities.disabled = true;
1339                        cities.selectedIndex = 0;
1340                        return;
1341                }
1342                else if (data['status'] != 'ok')
1343                {
1344                        showMessage(data['msg']);
1345                        cities.disabled = true;
1346                        cities.selectedIndex = 0;
1347                        updateAddrFillingFields();
1348                        return;
1349                }
1350                cities.disabled = false;
1351                var i = 1;
1352                for (var j in data['data'])
1353                {
1354                        cities.options[i] = new Option(data['data'][j], j);
1355                        i++;
1356                }
1357
1358                cities.disabled = false;
1359                cities.selectedIndex = 0;
1360
1361                data = CC_contact_full_info['addresses'];
1362                var addrIndex = 'address'+Element('cc_addr_types').value;
1363                if (data && data[addrIndex])
1364                {
1365                        cities.value = data[addrIndex]['id_city'];
1366
1367                        if (cities.value == '_NEW_')
1368                        {
1369                                if (CC_contact_full_info['addresses']['new_cities'][addrIndex])
1370                                {
1371                                        Element('cc_addr_cities_new').value = CC_contact_full_info['addresses']['new_cities'][addrIndex];
1372                                }
1373                                updateAddrNewCityOnMouseOut();
1374                        }
1375                }
1376        };
1377
1378        Connector.newRequest('populateCities', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cities&'+requestStr, 'GET', handler);
1379}
1380
1381function updateAddrNewStateOnMouseOver ()
1382{
1383        if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1)
1384        {
1385                Element('cc_addr_states_new').value = '';
1386        }
1387}
1388
1389function updateAddrNewStateOnMouseOut ()
1390{
1391        if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1)
1392        {
1393                Element('cc_addr_states_new').value = Element('cc_msg_type_state').value;
1394        }
1395}
1396
1397function updateAddrFillingFields()
1398{
1399        var countries = Element('cc_addr_countries');
1400        var cities = Element('cc_addr_cities');
1401        var newCity = Element('cc_addr_cities_new');
1402
1403        if (countries.value == '_NONE_')
1404        {
1405                newCity.readonly = true;
1406                newCity.disabled = true;
1407                newCity.value = '';
1408                disableAddrFillingFields();
1409                return;
1410        }
1411
1412        Element('cc_addr_1').readonly = false;
1413        Element('cc_addr_1').disabled = false;
1414
1415        Element('cc_addr_2').readonly = false;
1416        Element('cc_addr_2').disabled = false;
1417
1418        Element('cc_addr_other').readonly = false;
1419        Element('cc_addr_other').disabled = false;
1420
1421        Element('cc_addr_complement').readonly = false;
1422        Element('cc_addr_complement').disabled = false;
1423
1424        Element('cc_addr_postal_code').readonly = false;
1425        Element('cc_addr_postal_code').disabled = false;
1426
1427        Element('cc_addr_po_box').readonly = false;
1428        Element('cc_addr_po_box').disabled = false;
1429
1430        Element('cc_addr_is_default').readonly = false;
1431        Element('cc_addr_is_default').disabled = false;
1432
1433        switch (cities.value)
1434        {
1435                case '_NONE_':
1436                        newCity.readonly = true;
1437                        newCity.disabled = true;
1438                        newCity.value = '';
1439
1440                        //resetAddrFillingFields();
1441
1442                        return;
1443
1444                case '_NEW_':
1445
1446                        newCity.readonly = false;
1447                        newCity.disabled = false;
1448                        updateAddrNewCityOnMouseOut();
1449
1450                        break;
1451
1452                case '_SEP_': return;
1453
1454                default:
1455                        newCity.readonly = true;
1456                        newCity.disabled = true;
1457                        newCity.value = '';
1458        }
1459}
1460
1461function updateAddrNewCityOnMouseOver ()
1462{
1463        if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1)
1464        {
1465                Element('cc_addr_cities_new').value = '';
1466        }
1467}
1468
1469function updateAddrNewCityOnMouseOut ()
1470{
1471        if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1)
1472        {
1473                Element('cc_addr_cities_new').value = Element('cc_msg_type_city').value;
1474        }
1475}
1476
1477function saveAddressFields ()
1478{
1479        var lastIndex = CC_addr_last_selected;
1480
1481        if (lastIndex == 0)
1482        {
1483                return true;
1484        }
1485
1486        var addrFields = new Array('cc_addr_1',
1487                                   'cc_addr_2',
1488                                                           'cc_addr_complement',
1489                                                           'cc_addr_other',
1490                                                           'cc_addr_postal_code',
1491                                                           'cc_addr_po_box',
1492                                                           'cc_addr_countries',
1493                                                           'cc_addr_states',
1494                                                           'cc_addr_cities');
1495
1496        var empty = true;
1497
1498        for (var i = 0; i < 8; i++)
1499        {
1500                var field = Element(addrFields[i]);
1501                if (field.value && field.value != '_NONE_' && field.value != '_SEP_')
1502                {
1503                        empty = false;
1504                }
1505        }
1506
1507        if (empty)
1508        {
1509                return true;
1510        }
1511
1512        if (!CC_contact_full_info['addresses'])
1513        {
1514                CC_contact_full_info['addresses'] = new Array();
1515        }
1516
1517        var addrInfo = CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value];
1518
1519        if (!addrInfo)
1520        {
1521                addrInfo = new Array();
1522        }
1523
1524        addrInfo['id_address'] = Element('cc_addr_id').value;
1525
1526        switch(Element('cc_addr_countries').value)
1527        {
1528                case '_SEP_':
1529                case '_NONE_':
1530                        addrInfo['id_country'] = false;
1531                        break;
1532
1533                default:
1534                        addrInfo['id_country'] = Element('cc_addr_countries').value;
1535
1536        }
1537
1538        switch(Element('cc_addr_states').value)
1539        {
1540                case '_SEP_':
1541                case '_NONE_':
1542                case '_NEW_':
1543                case '_NOSTATE_':
1544                        addrInfo['id_state'] = false;
1545                        break;
1546
1547                default:
1548                        addrInfo['id_state'] = Element('cc_addr_states').value;
1549
1550        }
1551
1552        switch(Element('cc_addr_cities').value)
1553        {
1554                case '_SEP_':
1555                case '_NONE_':
1556                case '_NEW_':
1557                        addrInfo['id_city'] = false;
1558                        break;
1559
1560                default:
1561                        addrInfo['id_city'] = Element('cc_addr_cities').value;
1562
1563        }
1564
1565        addrInfo['id_typeof_address']  = Element('cc_addr_types').options[lastIndex].value;
1566        addrInfo['address1']           = Element('cc_addr_1').value ? Element('cc_addr_1').value : false;
1567        addrInfo['address2']           = Element('cc_addr_2').value ? Element('cc_addr_2').value : false;
1568        addrInfo['complement']         = Element('cc_addr_complement').value ? Element('cc_addr_complement').value : false;
1569        addrInfo['address_other']      = Element('cc_addr_other').value ? Element('cc_addr_other').value : false;
1570        addrInfo['postal_code']        = Element('cc_addr_postal_code').value ? Element('cc_addr_postal_code').value : false;
1571        addrInfo['po_box']             = Element('cc_addr_po_box').value ? Element('cc_addr_po_box').value : false;
1572        addrInfo['address_is_default'] = Element('cc_addr_is_default').checked ? '1' : '0';
1573
1574        CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value] = addrInfo;
1575
1576        if (Element('cc_addr_cities').value == '_NEW_' &&
1577            Element('cc_msg_type_city').value !=  Element('cc_addr_cities_new').value &&
1578                Element('cc_addr_cities_new').value != '')
1579        {
1580                var addrRootInfo = CC_contact_full_info['addresses']['new_cities'];
1581
1582                if (!addrRootInfo)
1583                {
1584                        addrRootInfo = new Array();
1585                }
1586
1587                var i = addrRootInfo.length;
1588                addrRootInfo[addrInfo['id_typeof_address']] = new Array();
1589                addrRootInfo[addrInfo['id_typeof_address']]['id_country'] = Element('cc_addr_countries').value;
1590                addrRootInfo[addrInfo['id_typeof_address']]['id_state']   = Element('cc_addr_states').value.charAt(0) != '_' ? Element('cc_addr_states').value : null;
1591                addrRootInfo[addrInfo['id_typeof_address']]['city_name']  = Element('cc_addr_cities_new').value;
1592                CC_contact_full_info['addresses']['new_cities'] = addrRootInfo;
1593        }
1594
1595        if (Element('cc_addr_states').value == '_NEW_' &&
1596            Element('cc_msg_type_state').value !=  Element('cc_addr_states_new').value &&
1597                Element('cc_addr_states_new').value != '')
1598        {
1599                var addrRootInfo = CC_contact_full_info['addresses']['new_states'];
1600
1601                if (!addrRootInfo)
1602                {
1603                        addrRootInfo = new Array();
1604                }
1605
1606                var i = addrRootInfo.length;
1607                addrRootInfo[addrInfo['id_typeof_address']] = new Array();
1608                addrRootInfo[addrInfo['id_typeof_address']]['id_country'] = Element('cc_addr_countries').value;
1609                addrRootInfo[addrInfo['id_typeof_address']]['state_name'] = Element('cc_addr_states_new').value;
1610                CC_contact_full_info['addresses']['new_states'] = addrRootInfo;
1611        }
1612
1613        return true;
1614}
1615
1616
1617/********* End Addresses Functions *********/
1618
1619
1620
1621/********* Begin Connections Functions ************/
1622function connGetHTMLLine ()
1623{
1624        var _label = (CC_contact_full_info['connections']
1625                && typeof(CC_contact_full_info['connections'][CC_conn_last_selected])!= 'undefined'
1626                && typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) != 'undefined'
1627                ? CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]['name']
1628                : Element("cc_conn_type_sel").value);
1629
1630        var cc_conn_default = Element("cc_phone_default").style.display == '' ? Element("cc_phone_default") : Element("cc_email_default");
1631        cc_conn_default.disabled = false;
1632        var idx_conn = 0;
1633        for(idx_conn; idx_conn < cc_conn_default.options.length; idx_conn++)
1634                if(cc_conn_default.options[idx_conn].value == _label)
1635                        break;
1636
1637        if(idx_conn == cc_conn_default.options.length)
1638                cc_conn_default.options[idx_conn] = new Option (_label,_label, false,false);
1639
1640        if (!document.all)
1641        {
1642                if (Element("cc_conn_type_1").checked)
1643                {
1644                        return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+
1645                        //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+
1646                        '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px; padding-left: 55px;" align="left"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+':'+'</span></td>' +
1647                        '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" onkeyup="javascript:emailTolower(\'cc_conn_value_' + CC_conn_count + '\')" style="width: 150px;" maxlength="100" type="text">&nbsp;' +
1648                        '<img align="top" alt="X" title="X" src="templates/default/images/x.png" style="width:18px; height:18px; cursor:pointer;" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>';
1649                }
1650                else if (Element("cc_conn_type_2").checked)
1651                {
1652                        return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+
1653                        //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+
1654                        '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px; padding-left: 55px;" align="left"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+':'+'</span></td>' +
1655                        '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" onkeyup="javascript:emailTolower(\'cc_conn_value_' + CC_conn_count + '\')" style="width: 150px;" maxlength="30" type="text" onkeyup="formatPhone(this)">&nbsp;' +
1656                        '<img align="top" alt="X" title="X" src="templates/default/images/x.png" style="width:18px; height:18px; cursor:pointer;" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>';
1657                }
1658        }
1659        else
1660        {
1661                var tds = new Array();
1662                var inputs = new Array();
1663                var img = document.createElement('img');
1664
1665                for (var i = 0; i < 4; i++)
1666                {
1667                        tds[i] = document.createElement('td');
1668                }
1669
1670                tds[0].style.position = 'absolute';
1671                tds[0].style.visibility = 'hidden';
1672                tds[0].style.zIndex = '-1';
1673
1674                var remove_id = 'cc_conn_tr_'+CC_conn_count;
1675                img.alt = 'X';
1676                img.src = 'templates/default/images/x.png';
1677                img.style.width = '18px';
1678                img.style.height = '18px';
1679                img.style.cursor = 'pointer';
1680                img.align = 'top';
1681                img.onclick = function(e){ removeConnField(remove_id);};
1682
1683                for (var i = 0; i < 3; i++)
1684                {
1685                        inputs[i] = document.createElement('input');
1686                }
1687
1688                inputs[0].id = 'cc_conn_id_'+CC_conn_count;
1689                inputs[0].type = 'hidden';
1690                inputs[0].value = '_NEW_';
1691
1692                inputs[1].id = 'cc_conn_name_'+CC_conn_count;
1693                inputs[1].type = 'hidden';
1694
1695                inputs[2].id = 'cc_conn_value_'+CC_conn_count;
1696                inputs[2].type = 'text';
1697                inputs[2].style.width = '150px';
1698
1699                var _span = document.createElement("SPAN");
1700                _span.style.width = "100px";
1701                _span.id = "cc_conn_label_"+CC_conn_count;
1702                _span.innerHTML = _label + ':';
1703                tds[0].appendChild(inputs[0]);
1704                tds[1].width = '40px';
1705                tds[1].appendChild(inputs[1]);
1706                tds[1].align = 'left';
1707                tds[1].style.padding = "0px 0px 0px 75px";
1708                tds[1].appendChild(_span);
1709                tds[2].appendChild(inputs[2]);
1710                tds[2].align = 'left';
1711                tds[2].innerHTML +="&nbsp;";
1712                tds[2].appendChild(img);
1713
1714                return tds;
1715        }
1716}
1717
1718function connAddNewLine ()
1719{
1720
1721        var _emptyLine = (!CC_contact_full_info['connections']
1722                || typeof(CC_contact_full_info['connections'][CC_conn_last_selected]) == 'undefined'
1723                || typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) == 'undefined');
1724
1725        if(_emptyLine) {
1726
1727                if(Element("cc_conn_type_sel").value == '-1'){
1728                                return false;
1729                }
1730
1731                for(k = 0; k < CC_conn_count; k++) {
1732                        if(Element("cc_conn_name_"+k) && Element("cc_conn_name_"+k).value != "" && Element("cc_conn_name_"+k).value == Element("cc_conn_type_sel").value) {
1733                                alert('Você já possui uma entrada para o tipo "'+Element("cc_conn_type_sel").value+'"!');
1734                                Element("cc_conn_type_sel").options.selectedIndex = 0;
1735                                return false;
1736                        }
1737                }
1738        }
1739        if (!document.all)
1740        {
1741                var obj = addHTMLCode('cc_conn', 'cc_conn_tr_'+CC_conn_count, connGetHTMLLine(),'tr');
1742        }
1743        else
1744        {
1745                var tds = connGetHTMLLine();
1746                var tr = document.createElement('tr');
1747                var tbody = Element('cc_conn');
1748
1749                tr.id = 'cc_conn_tr_'+CC_conn_count;
1750                tbody.appendChild(tr);
1751
1752                for (var i = 0; i < 4; i++)
1753                {
1754                        tr.appendChild(tds[i]);
1755                }
1756        }
1757        Element("cc_conn_name_"+CC_conn_count).value = Element("cc_conn_type_sel").value;
1758        Element("cc_conn_type_sel").options.selectedIndex = 0;
1759        CC_conn_count++;
1760
1761        return CC_conn_count;
1762}
1763
1764function connRemoveLine(id)
1765{
1766        var p = Element(id).parentNode;
1767        var cc_conn_default = Element("cc_phone_default").style.display == '' ? Element("cc_phone_default") : Element("cc_email_default");
1768        var _label = Element("cc_conn_label_"+(id.substring(11,13))).innerHTML;
1769        for(var i = 0;i < cc_conn_default.options.length; i++) {
1770                if(cc_conn_default.options[i].value == _label) {
1771                        cc_conn_default.options[i] = null;
1772                        break;
1773                }
1774        }
1775        if(cc_conn_default.options.length == 1)
1776                cc_conn_default.disabled = true;
1777
1778        removeHTMLCode(id);
1779
1780        return;
1781        connRefreshClass(p.childNodes);
1782}
1783
1784function connRefreshClass(Nodes)
1785{
1786        for (var i = 2; i < Nodes.length; i++)
1787        {
1788                Nodes.item(i).className = i % 2 ? 'row_on' : 'row_off';
1789        }
1790}
1791
1792function clearConn()
1793{
1794        var connParent = Element('cc_conn').childNodes;
1795        var i;
1796
1797        for (i = connParent.length - 1; i >= 0; i--)
1798        {
1799                if (connParent[i].id)
1800                {
1801                        connRemoveLine(connParent[i].id);
1802                }
1803        }
1804
1805        CC_conn_count = 0;
1806}
1807
1808function removeConnField(id)
1809{
1810        var count = id.substring(id.lastIndexOf('_')+1);
1811        if (Element('cc_conn_id_'+count).value != '_NEW_')
1812        {
1813                if (typeof(CC_contact_full_info['removed_conns']) != 'object')
1814                {
1815                        CC_contact_full_info['removed_conns'] = new Array();
1816                }
1817
1818                CC_contact_full_info['removed_conns'][CC_contact_full_info['removed_conns'].length] = Element('cc_conn_id_'+count).value;
1819        }
1820
1821        connRemoveLine(id);
1822}
1823
1824function emailTolower(obj){
1825        document.getElementById(obj).value = document.getElementById(obj).value.toLowerCase();
1826
1827}
1828
1829function updateConnFields()
1830{
1831
1832        var connID;
1833        var i;
1834        var cc_conn_type_sel = Element("cc_conn_type_sel");
1835        var cc_phone_default = Element("cc_phone_default");
1836        var cc_email_default = Element("cc_email_default");
1837        var div_cc_conn_is_default = Element("div_cc_conn_is_default");
1838        var cc_conn_is_default = '';
1839        var selected_index = '';
1840
1841        cc_conn_type_sel.disabled = false;
1842        div_cc_conn_is_default.style.display = "";
1843
1844        for(var i = 0;i < cc_conn_type_sel.options.length; i++)
1845                cc_conn_type_sel.options[i--] = null;
1846
1847        if(Element('cc_conn_type_1').checked) {
1848            var lang_new_email = Element('cc_msg_new_email').value;
1849            var lang_main = Element('cc_msg_main').value;
1850            var lang_alternative = Element('cc_msg_alternative').value;
1851            cc_conn_type_sel[0] = new Option(lang_new_email,'-1');
1852            cc_conn_type_sel[1] = new Option(lang_main,lang_main);
1853            cc_conn_type_sel[2] = new Option(lang_alternative,lang_alternative);
1854                connID = 1;
1855                selected_index = cc_email_default.options.selectedIndex;
1856                for(var i = 0;i < cc_email_default.options.length; i++) {
1857                        cc_email_default.options[i--] = null;
1858                }
1859
1860                var lang_select_email = Element('cc_msg_select_email').value;
1861                cc_email_default.options[0] = new Option(lang_select_email,'-1');
1862                cc_phone_default.style.display = 'none';
1863                cc_email_default.style.display = '';
1864                cc_conn_is_default = cc_email_default;
1865        }
1866        else if(Element('cc_conn_type_2').checked) {
1867            var lang_new_telephone = Element('cc_msg_new_phone').value;
1868            var lang_home = Element('cc_msg_home').value;
1869            var lang_cellphone = Element('cc_msg_cellphone').value;
1870            var lang_work = Element('cc_msg_work').value;
1871            var lang_fax = Element('cc_msg_fax').value;
1872            var lang_pager = Element('cc_msg_pager').value;
1873                var lang_corporative_cellphone = Element('cc_msg_corporative_cellphone').value;
1874                var lang_corporative_fax = Element('cc_msg_corporative_fax').value;
1875                var lang_corporative_pager = Element('cc_msg_corporative_pager').value;
1876
1877            cc_conn_type_sel[0] = new Option(lang_new_telephone,'-1');
1878            cc_conn_type_sel[1] = new Option(lang_home,lang_home);
1879            cc_conn_type_sel[2] = new Option(lang_cellphone,lang_cellphone);
1880            cc_conn_type_sel[3] = new Option(lang_work,lang_work);
1881            cc_conn_type_sel[4] = new Option(lang_fax,lang_fax);
1882            if (document.getElementById('cc_contact_type').value == 'advanced') {
1883                        cc_conn_type_sel[5] = new Option(lang_pager, lang_pager);
1884                        cc_conn_type_sel[6] = new Option(lang_corporative_cellphone, lang_corporative_cellphone);
1885                        cc_conn_type_sel[7] = new Option(lang_corporative_fax, lang_corporative_fax);
1886                        cc_conn_type_sel[8] = new Option(lang_corporative_pager, lang_corporative_pager);
1887                }
1888
1889                connID = 2;
1890                selected_index = cc_phone_default.options.selectedIndex;
1891                for(var i = 0;i < cc_phone_default.options.length; i++) {
1892                        cc_phone_default.options[i--] = null;
1893                }
1894
1895                var lang_choose_phone = Element('cc_msg_choose_phone').value;
1896                cc_phone_default.options[0] = new Option(lang_choose_phone,'-1');
1897                cc_email_default.style.display = 'none';
1898                cc_phone_default.style.display = '';
1899                cc_conn_is_default = cc_phone_default;
1900        }
1901
1902        Element("cc_conn_type_sel").options.selectedIndex = 0;
1903        /* First save the data */
1904        saveConnFields();
1905
1906        CC_conn_last_selected = connID;
1907
1908        clearConn();
1909
1910        if (connID == '_NONE_')
1911        {       cc_conn_is_default.disabled = true;
1912                return;
1913        }
1914
1915        /* If no data already available, return */
1916        if (!CC_contact_full_info['connections'])
1917        {
1918                cc_conn_is_default.disabled = true;
1919                return;
1920        }
1921        cc_conn_is_default.disabled = (!CC_contact_full_info['connections'][connID] || CC_contact_full_info['connections'][connID].length == 0);
1922        /* Put the information that's already available */
1923        for (i in CC_contact_full_info['connections'][connID])
1924        {
1925                var num = connAddNewLine();
1926                Element('cc_conn_id_'+i).value = CC_contact_full_info['connections'][connID][i]['id'];
1927                Element('cc_conn_name_'+i).value = CC_contact_full_info['connections'][connID][i]['name'];
1928                Element('cc_conn_value_'+i).value = CC_contact_full_info['connections'][connID][i]['value'];
1929
1930                if(!selected_index || (selected_index == '-1' && CC_contact_full_info['connections'][connID][i]['is_default'])){
1931                        for(var j = 0;j < cc_conn_is_default.options.length; j++){
1932                                if(cc_conn_is_default.options[j].value == CC_contact_full_info['connections'][connID][i]['name']) {
1933                                        selected_index = j;
1934                                        break;
1935                                }
1936                        }
1937                }
1938        }
1939        if(cc_conn_is_default.options.length > selected_index)
1940                cc_conn_is_default.options.selectedIndex = (selected_index == "-1" ? 0 : selected_index);
1941}
1942
1943function saveConnFields()
1944{
1945        if (CC_conn_last_selected != 0 && CC_conn_last_selected != '_NONE_')
1946        {
1947                var nodes = Element('cc_conn').childNodes;
1948                var k = 0;
1949
1950                if (typeof(CC_contact_full_info['connections']) != 'object' || CC_contact_full_info['connections'] == null)
1951                {
1952                        CC_contact_full_info['connections'] = new Array();
1953                        CC_contact_full_info['connections'][CC_conn_last_selected] = new Array();
1954                }
1955                else if (typeof(CC_contact_full_info['connections'][CC_conn_last_selected]) != 'object')
1956                {
1957                        CC_contact_full_info['connections'][CC_conn_last_selected] = new Array();
1958                }
1959                else
1960                {
1961                        delete CC_contact_full_info['connections'][CC_conn_last_selected];
1962                        CC_contact_full_info['connections'][CC_conn_last_selected] = new Array();
1963                }
1964
1965                for (var i = 0; i < nodes.length; i++)
1966                {
1967                        if (nodes[i].id)
1968                        {
1969                                var subNodes = nodes[i].childNodes;
1970                                var found = false;
1971
1972                                for (var j = 0; j < subNodes.length; j++)
1973                                {
1974                                        if (subNodes[j].childNodes.length > 0 &&
1975                                            subNodes[j].childNodes[0].id)
1976                                        {
1977                                                /* Check for the Connection Info array */
1978                                                if (typeof(CC_contact_full_info['connections'][CC_conn_last_selected][k]) != 'object')
1979                                                {
1980                                                        CC_contact_full_info['connections'][CC_conn_last_selected][k] = new Array();
1981                                                }
1982
1983                                            if (subNodes[j].childNodes[0].id.indexOf('cc_conn_name') != -1)
1984                                                {
1985                                                        if (subNodes[j].childNodes[0].value)
1986                                                        {
1987                                                                CC_contact_full_info['connections'][CC_conn_last_selected][k]['name'] = subNodes[j].childNodes[0].value;
1988                                                        }
1989                                                        else
1990                                                        {
1991                                                                CC_contact_full_info['connections'][CC_conn_last_selected][k]['name'] = '';
1992                                                        }
1993                                                }
1994                                                else if (subNodes[j].childNodes[0].id.indexOf('cc_conn_value') != -1)
1995                                                {
1996                                                        if (subNodes[j].childNodes[0].value)
1997                                                        {
1998                                                                CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = subNodes[j].childNodes[0].value;
1999                                                        }
2000                                                        else
2001                                                        {
2002                                                                CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = '';
2003                                                        }
2004                                                }
2005                                                else if (subNodes[j].childNodes[0].id.indexOf('cc_conn_id') != -1)
2006                                                {
2007                                                        CC_contact_full_info['connections'][CC_conn_last_selected][k]['id'] = subNodes[j].childNodes[0].value;
2008                                                }
2009
2010                                                found = true;
2011                                        }
2012                                }
2013
2014                                if (found)
2015                                {
2016                                        k++;
2017                                }
2018                        }
2019                }
2020
2021                if (CC_contact_full_info['connections'].length == 0)
2022                {
2023                        delete CC_contact_full_info['connections'];
2024                }
2025
2026                if (CC_contact_full_info['connections'][CC_conn_last_selected].length == 0)
2027                {
2028                        delete CC_contact_full_info['connections'][CC_conn_last_selected];
2029                }
2030
2031        }
2032
2033        return;
2034}
2035
2036/***********************************************\
2037*               VIEW CARDS FUNCTIONS            *
2038\***********************************************/
2039function removeAllEntries()
2040{
2041        var handler = function (responseText)
2042        {
2043                var data = unserialize(responseText);
2044                if (typeof(data) != 'object') {
2045                        showMessage(Element('cc_msg_err_contacting_server').value);
2046                        return;
2047                }
2048                if (data['status'] != 'ok')     {
2049                        showMessage(data['msg']);
2050                        return;
2051                }
2052                setTimeout('updateCards()',80);
2053        };
2054        var number = randomString().toLowerCase();
2055        var result = '';
2056
2057        if(!is_ie)
2058                result = prompt("Essa operação removerá TODOS os seus \ncontatos pessoais,  e  NÃO  PODERÁ  ser \ndesfeita. Digite o código abaixo:\n\tCódigo de confirmação: "+number);
2059        else
2060                result = prompt("Essa operação removerá TODOS os seus contatos pessoais,  e  NÃO  PODERÁ  ser desfeita. Digite o seguinte código de confirmação: "+number,"");
2061
2062        if(result) {
2063                if(result.toLowerCase() == number)
2064                        Connector.newRequest('removeAllEntries', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_all_entries', 'GET', handler);
2065                else
2066                        alert('Código Incorreto');
2067        }
2068}
2069
2070function removeEntry(id, type)
2071{
2072        var question = showMessage(type == 'groups' ? Element('cc_msg_group_remove_confirm').value: Element('cc_msg_card_remove_confirm').value, 'confirm');
2073
2074        if (!question)
2075        {
2076                return;
2077        }
2078
2079        var handler = function (responseText)
2080        {
2081                var data = unserialize(responseText);
2082
2083                if (typeof(data) != 'object')
2084                {
2085                        showMessage(Element('cc_msg_err_contacting_server').value);
2086                        return;
2087                }
2088
2089                if (data['status'] != 'ok')
2090                {
2091                        showMessage(data['msg']);
2092                        return;
2093                }
2094
2095                setTimeout('updateCards()',80);;
2096        };
2097
2098        typeArg = (type == 'groups' ? 'group' : 'entry');
2099
2100        Connector.newRequest('removeEntry', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_'+typeArg+'&remove=' + id, 'GET', handler);
2101}
2102
2103function updateCards()
2104{
2105        setHeightSpace();
2106        setMaxCards(getMaxCards());
2107        showCards(getActualLetter(), getActualPage());
2108}
2109
2110
2111window.onresize = function ()
2112{
2113        updateCards();
2114}
2115
2116
2117function setHeightSpace ()
2118{
2119        /*
2120        var w_height = 0;
2121        var w_extra = 200;
2122
2123        if (document.body.clientHeight)
2124        {
2125                w_height = parseInt(document.body.clientHeight);
2126        }
2127        else
2128        {
2129                w_height = 500;
2130        }
2131        if (w_height < 500)
2132        {
2133                w_height = 500;
2134        }
2135        Element('cc_card_space').style.height = (w_height - w_extra) + 'px';
2136        */
2137}
2138
2139function selectLetter (letter_id)
2140{
2141        for (var i = 0; i < 28; i++)
2142        {
2143                if ( i == letter_id )
2144                {
2145                        Element('cc_letter_' + i).className = 'letter_box_active';
2146                }
2147                else
2148                {
2149                        Element('cc_letter_' + i).className = 'letter_box';
2150                }
2151        }
2152}
2153
2154function clearLetterSelection()
2155{
2156        for (var i = 0; i < 28; i++)
2157        {
2158                Element('cc_letter_' + i).className = 'letter_box';
2159        }
2160}
2161
2162function getActualPage ()
2163{
2164        return CC_actual_page;
2165}
2166
2167function getActualLetter ()
2168{
2169        return CC_actual_letter;
2170}
2171
2172function getFirstPage ()
2173{
2174        return 1;
2175}
2176
2177function getPreviousPage ()
2178{
2179        if ( CC_actual_page > 1 )
2180        {
2181                return CC_actual_page - 1;
2182        }
2183        else
2184        {
2185                return 1;
2186        }
2187}
2188
2189function getNextPage ()
2190{
2191        if ( CC_actual_page < CC_npages )
2192        {
2193                return CC_actual_page + 1;
2194        }
2195        else
2196        {
2197                return CC_npages;
2198        }
2199}
2200
2201function getLastPage ()
2202{
2203        return CC_npages;
2204}
2205
2206function setPages (npages, actual_page, showing_page)
2207{
2208        var html_pages = '';
2209        var n_lines = 0;
2210        var page_count = 0;
2211
2212        if (CC_npages == 0)
2213        {
2214                html_pages = '';
2215        }
2216        else
2217        {
2218                var page = 1;
2219                if (showing_page > 10 || (!showing_page && actual_page > 10))
2220                {
2221                        var final_page = showing_page? showing_page-11 : actual_page-11;
2222                        if (final_page < 1)
2223                        {
2224                                final_page = 1;
2225                        }
2226
2227                        html_pages += '<a href="javascript:setPages('+npages+', '+ actual_page +', '+ final_page +')">...</a> ';
2228
2229                        page = showing_page ? showing_page : actual_page;
2230                }
2231
2232                for (; page <= npages; page++)
2233                {
2234                        if (page_count > 10)
2235                        {
2236                                html_pages += '<a href="javascript:setPages('+npages+', '+ actual_page +', '+ page +');">...</a>';
2237                                break;
2238                        }
2239                        if ( page == actual_page )
2240                        {
2241                                html_pages += '<b>'+page+'</b>';
2242                        }
2243                        else
2244                        {
2245                                html_pages += '<a href="javascript:showCards(\'' + CC_actual_letter + '\',' + page + ')">' + page + '</a>';
2246                        }
2247                        html_pages += '&nbsp;';
2248                        page_count++;
2249                }
2250        }
2251
2252        if (actual_page <= 1)
2253        {
2254                Element('cc_panel_arrow_first').onclick = '';
2255                Element('cc_panel_arrow_previous').onclick = '';
2256                Element('cc_panel_arrow_first').style.cursor = 'auto';
2257                Element('cc_panel_arrow_previous').style.cursor = 'auto';
2258        }
2259        else
2260        {
2261                Element('cc_panel_arrow_first').onclick = function (event) { showCards(getActualLetter(), getFirstPage()); };
2262                Element('cc_panel_arrow_previous').onclick = function (event) { showCards(getActualLetter(), getPreviousPage()); };
2263                if (is_mozilla)
2264                {
2265                        Element('cc_panel_arrow_first').style.cursor = 'pointer';
2266                        Element('cc_panel_arrow_previous').style.cursor = 'pointer';
2267                }
2268                Element('cc_panel_arrow_first').style.cursor = 'hand';
2269                Element('cc_panel_arrow_previous').style.cursor = 'hand';
2270        }
2271
2272        if (actual_page == CC_npages)
2273        {
2274                Element('cc_panel_arrow_next').onclick = '';
2275                Element('cc_panel_arrow_last').onclick = '';
2276                Element('cc_panel_arrow_next').style.cursor = 'auto';
2277                Element('cc_panel_arrow_last').style.cursor = 'auto';
2278        }
2279        else
2280        {
2281                Element('cc_panel_arrow_next').onclick = function (event) { showCards(getActualLetter(), getNextPage()); };
2282                Element('cc_panel_arrow_last').onclick = function (event) { showCards(getActualLetter(), getLastPage()); };
2283                if (is_mozilla)
2284                {
2285                        Element('cc_panel_arrow_next').style.cursor = 'pointer';
2286                        Element('cc_panel_arrow_last').style.cursor = 'pointer';
2287                }
2288                Element('cc_panel_arrow_next').style.cursor = 'hand';
2289                Element('cc_panel_arrow_last').style.cursor = 'hand';
2290        }
2291
2292        Element('cc_panel_pages').innerHTML = html_pages;
2293}
2294
2295function populateCards(data, type)
2296{
2297        if (data[3].length >= 100 )
2298        {
2299                alert("Critério de pesquisa muito abrangente, achados " + data[3].length + " resultados");
2300                for (i = 0; i < (Math.sqrt(data[3].length)-1); i++)
2301                        for (j = 0; j < 3; j++)
2302                                document.getElementById("cc_card:"+j+":"+i).innerHTML = '';
2303                        return false;
2304        }
2305
2306        if(type == 'groups' || type =='shared_groups')
2307                return populateGroupsInCards(data,type);
2308
2309        var pos = 0;
2310        var ncards = data[3].length;
2311
2312        if (typeof(data[3]) == 'object' && ncards > 0)
2313        {
2314                for (var i = 0; i < CC_max_cards[1]; i++)
2315                {
2316                        for (var j = 0; j < CC_max_cards[0]; j++)
2317                        {
2318                                id = 'cc_card:'+j+':'+i;
2319
2320                                for (var k = 0; k < data[2].length; k++)
2321                                {
2322                                        if(!(ccTree.catalog_perms & 2))
2323                                        {
2324                                                switch(data[2][k])
2325                                                {
2326                                                        case 'cc_mail' :
2327
2328                                                                if(data[3][pos][k] === 'none')
2329                                                                        data[3][pos][k] = not_informed_text;
2330                                                                break;
2331                                                        case 'cc_phone' :
2332
2333                                                                if(data[3][pos][k] === 'none')
2334                                                                        data[3][pos][k] = not_informed_text;
2335                                                                break;
2336                                                }
2337
2338                                        }
2339
2340
2341                                        /*if(data[2][k] ==  'cc_mail' && data[3][pos][k] == 'none' && !(ccTree.catalog_perms & 2) ) {
2342                                                Element(id).style.display = 'none';
2343                                                continue;
2344                                        }*/
2345
2346                                        if(data[3][pos][k] != 'none')
2347                                        {
2348                                                data[3][pos][k] = unescape(data[3][pos][k]);
2349                                                switch (data[2][k])
2350                                                {
2351                                                        case 'cc_name':
2352                                                                if (data[3][pos][k].length > 50)
2353                                                                {
2354                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 50);
2355                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2356                                                                }
2357                                                                else
2358                                                                {
2359                                                                        Element(id+':'+data[2][k]).innerHTML = data[3][pos][k];
2360                                                                }
2361                                                                if(data[3][pos][12])
2362                                                                        Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][12]+"</i></font></span>";
2363                                                                break;
2364
2365                                                        case 'cc_mail':
2366                                                                if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20))
2367                                                                {
2368                                                                        Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ adjustString(data[3][pos][k], (CC_visual == 'table'  ? 50 : 20))+'</span>';
2369                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2370                                                                }
2371                                                                else
2372                                                                {
2373                                                                        if(data[3][pos][k] != not_informed_text)
2374                                                                        Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>';
2375                                                                        else
2376                                                                                Element(id+':'+data[2][k]).innerHTML = data[13] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>';
2377                                                                }
2378                                                                break;
2379
2380                                                        case 'cc_phone':
2381                                                                if (data[3][pos][k].length > 20)
2382                                                                {
2383                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
2384                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2385                                                                }
2386                                                                else
2387                                                                {
2388                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
2389                                                                }
2390                                                                if(data[3][pos][k] != " ")
2391                                                                Element(id+':cc_phone').innerHTML = (data[3][pos][k].length < 23) ? data[3][pos][k]:data[3][pos][k].substr(0,22)+"<br>"+data[3][pos][k].substr(22,data[3][pos][k].length);
2392                                                                else
2393                                                                        Element(id+':cc_phone').innerHTML = not_informed_text;
2394                                                                break;
2395
2396                                                        case 'cc_title':
2397                                                                if(preferences.departmentShow && ccTree.catalog_perms == 1){
2398                                                                        if(data[3][pos][k] == " " || data[3][pos][k] == "" || data[3][pos][k] == "undefined"){
2399                                                                                Element(id+':'+data[2][k]).innerHTML = not_informed_text;
2400                                                                        }
2401                                                                        else if (data[3][pos][k].length > 15)
2402                                                                {
2403                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15);
2404                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2405                                                                }
2406                                                                else
2407                                                                {
2408                                                                        Element(id+':'+data[2][k]).innerHTML = data[3][pos][k];
2409                                                                }
2410                                                                break;
2411                                                                }else{
2412                                                                        break;
2413                                                                }
2414                                                        case 'cc_id':
2415                                                                var id_contact = data[3][pos][k];
2416                                                                Element(id+':'+data[2][k]).value = data[3][pos][k];
2417                                                                Element(id+':cc_photo').src = '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_photo' + (data[4][pos] != 0 ? '&id='+data[3][pos][k] : '');
2418                                                                if(ccTree.catalog_perms == 1)
2419                                                                {
2420                                                                        Element(id+':cc_icon_data').innerHTML =  '<span title="'+Element('cc_msg_copy_to_catalog').value+'" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccQuickAddContact.showList(\''+ Element(id+':cc_id').value + '\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/address-conduit-16.png" align="center"></span>';
2421                                                                        if (data[12] == true || data[12] == 'true')
2422                                                                                Element(id+':cc_icon_data').innerHTML += "  |  " + '<span title="'+ Element('cc_msg_show_extra_detail').value+'" id="' + id + ':ccContactDetails" onclick="javascript:openContactDetails(\'' + Element(id+':cc_id').value + '\');" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/addressbook-mini.png" align="center"></span>';
2423                                                                }
2424                                                                break;
2425
2426                                                        case 'cc_forwarding_address':
2427                                                                var account_type = data[3][pos][k];
2428
2429                                                                if( !account_type)
2430                                                                        break;
2431                                                                else
2432                                                                        if (account_type == 'list' || account_type == 'group')
2433                                                                                icon = '<img src="templates/default/images/people-mini.png" align="center">';
2434                                    else
2435                                                                                icon = '';
2436                                                                           
2437                                Element(id+':cc_icon_group').innerHTML =  '<span title="'+Element('cc_participants').value+'"  onmouseout="window.status=\'\';" onclick="ccListParticipants.showList(\''+ Element(id+':cc_id').value + '\',null,null,null,\''+account_type+'\');return true;" style="cursor: pointer; cursor: hand; z-index: 1">'+icon+'&nbsp;&nbsp;</span>';
2438                                break;
2439
2440
2441                                                        //Para tratar tamanho do campo "celular" do empregado
2442                                                        case 'cc_mobile':
2443                                                                if(preferences.cellShow && ccTree.catalog_perms == 1){
2444                                                                if (data[3][pos][k].length > 20)
2445                                                                {
2446                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
2447                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2448                                                                }
2449                                                                else
2450                                                                {
2451                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
2452                                                                }
2453                                                                Element(id+':cc_mobile').innerHTML = data[3][pos][k];
2454                                                                break;
2455                                                                }else{
2456                                                                        break;
2457                                                                }               
2458                                                        //Para tratar tamanho do campo "matricula" do empregado
2459                                                        case 'cc_empNumber':
2460                                                                if(preferences.empNumShow && ccTree.catalog_perms == 1){
2461                                                                if (data[3][pos][k].length > 20)
2462                                                                {
2463                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
2464                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2465                                                                }
2466                                                                else
2467                                                                {
2468                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
2469                                                                }
2470                                                                Element(id+':cc_empNumber').innerHTML = data[3][pos][k];
2471                                                                break;
2472                                                                }else{
2473                                                                        break;
2474                                                                }
2475                                                        //Para tratar tamanho do campo "departamento" do empregado
2476                                                        case 'cc_department':
2477                                                                if (data[3][pos][k].length > 15)
2478                                                                {
2479                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15);
2480                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2481                                                                }
2482                                                                else
2483                                                                {
2484                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15);
2485                                                                }
2486                                                                Element(id+':cc_department').innerHTML = data[3][pos][k];
2487                                                                break;
2488
2489                                                        default:
2490                                                                if (data[3][pos][k].length > 10)
2491                                                                {
2492                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 10);
2493                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2494                                                                }
2495                                                                else
2496                                                                {
2497                                                                        if (Element(id+':'+data[2][k]) == null) alert('É nulo');
2498                                                                        Element(id+':'+data[2][k]).innerHTML = data[3][pos][k];
2499                                                                }
2500                                                }
2501                                        }else{
2502                                                data[3][pos][k] = unescape(data[3][pos][k]);
2503                                                switch (data[2][k])
2504                                                {
2505                                                        case 'cc_mail':
2506                                                                Element(id+':'+data[2][k]).innerHTML = data[13] + not_informed_text + '\')">'+ not_informed_text +'</span>';
2507                                                                break;
2508
2509                                                        case 'cc_phone':
2510                                                                Element(id+':cc_phone').innerHTML = not_informed_text;
2511                                                                break;
2512                                                        case 'cc_empNumber':
2513                                                                if(preferences.empNumShow && ccTree.catalog_perms == 1){
2514                                                                        var cc_empNumberTD = Element(id+':cc_empNumber').parentNode;
2515                                                                        if(cc_empNumberTD.tagName != "DIV")
2516                                                                                //cc_empNumberTD.parentNode.removeChild(cc_empNumberTD);
2517                                                                                Element(id+':cc_empNumber').innerHTML = not_informed_text;
2518                                                                        else
2519                                                                                cc_empNumberTD.removeChild(Element(id+':cc_empNumber'));
2520                                                                }
2521                                                                break;
2522                                                        case 'cc_mobile':
2523                                                                if(preferences.cellShow && ccTree.catalog_perms == 1){
2524                                                                        var cc_mobileTD = Element(id+':cc_mobile').parentNode;
2525                                                                        if(cc_mobileTD.tagName != "DIV")
2526                                                                                //cc_mobileTD.parentNode.removeChild(cc_mobileTD);
2527                                                                                Element(id+':cc_mobile').innerHTML = not_informed_text;
2528                                                                        else
2529                                                                                cc_mobileTD.removeChild(Element(id+':cc_mobile'));
2530                                                                }
2531                                                                break;
2532                                                        case 'cc_title':
2533                                                                if(preferences.departmentShow && ccTree.catalog_perms == 1){
2534                                                                        var cc_titleTD = Element(id+':cc_title').parentNode;
2535                                                                        if(cc_titleTD.tagName != "DIV")
2536                                                                                Element(id+':cc_title').innerHTML = not_informed_text;
2537                                                                        else
2538                                                                                cc_titleTD.removeChild(Element(id+':cc_title'));
2539                                                                }
2540                                                                break;
2541                                                }
2542                                        }
2543                                }
2544                               
2545                               
2546                                if (type == "shared_contacts") {
2547                                        if (data[3][pos][11] & 4)
2548                                                eval("document.getElementById(id + ':cc_card_edit').onclick = function(){editSharedContact(Element('"+id+"' + ':cc_id').value);};");
2549                                        else
2550                                                document.getElementById(id + ':cc_card_edit').onclick = function(){
2551                                                        alert(Element('cc_msg_not_allowed').value);
2552                                                };
2553                                        if (data[3][pos][11] & 8)
2554                                                eval("document.getElementById(id + ':cc_card_remove').onclick = function(){removeEntry(Element('" + id + "' + ':cc_id').value);};");
2555                                        else
2556                                                document.getElementById(id + ':cc_card_remove').onclick = function(){
2557                                                        alert(Element('cc_msg_not_allowed').value);
2558                                                };
2559                                }
2560
2561                                if (--ncards == 0)
2562                                {
2563                                        j = CC_max_cards[0];
2564                                        i = CC_max_cards[1];
2565                                }
2566
2567                                pos++;
2568                        }
2569                }
2570        }
2571        deleteBlankFields("cc_name_empNumber");
2572        deleteBlankFields("cc_name_mobile");
2573        deleteBlankFields("cc_name_title");
2574}
2575function deleteBlankFields(field){
2576                var saia = true;
2577                var empNumbers = document.getElementsByName(field);
2578                for(var i = 0; i < empNumbers.length; i++){
2579                        if(empNumbers[i].getElementsByTagName("SPAN")[0].innerHTML != not_informed_text){
2580                                saia = false;
2581                                i = empNumbers.length;
2582                        }
2583                }
2584                if(saia){
2585                        for(var i = 0; i < empNumbers.length; i++){
2586                                empNumbers[i].style.display = "none";
2587                        }
2588                }
2589}
2590function populateGroupsInCards(data,type)
2591{
2592        var pos = 0;
2593        var contacts = data[5];
2594        var ncards = data[3].length;
2595
2596        if (typeof(data[3]) == 'object' && ncards > 0)
2597        {
2598                for (var i = 0; i < CC_max_cards[1]; i++)
2599                {
2600                        for (var j = 0; j < CC_max_cards[0]; j++)
2601                        {
2602                                id = 'cc_card:'+j+':'+i;
2603
2604                                for (var k = 0; k < data[2].length; k++)
2605                                {
2606
2607                                        if(data[3][pos][k] != 'none')
2608                                        {
2609
2610                                                switch (data[2][k])
2611                                                {
2612                                                        case 'cc_title':
2613                                                                if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20))
2614                                                                {
2615                                                                        Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], (CC_visual == 'table'  ? 50 : 20));
2616                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2617                                                                }
2618                                                                else
2619                                                                {
2620                                                                        Element(id+':'+data[2][k]).innerHTML = data[3][pos][k];
2621                                                                }
2622                                                                if(data[3][pos][5])
2623                                                                        Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][5]+"</i></font></span>";
2624                                                                break;
2625
2626                                                        case 'cc_short_name':
2627                                                                if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20))
2628                                                                {
2629                                                                        Element(id+':'+data[2][k]).innerHTML = data[5] + ''+data[3][pos][k]+'::'+data[3][pos][6] +'\')">'+adjustString(data[3][pos][k], (CC_visual == 'table'  ? 50 : 20))+'</span>';
2630                                                                        Element(id+':'+data[2][k]).title = data[3][pos][k];
2631                                                                }
2632                                                                else
2633                                                                {
2634                                                                        Element(id+':'+data[2][k]).innerHTML = data[5] + ''+data[3][pos][k]+(data[3][pos][6] ? '::'+data[3][pos][6] : "") + '\')">'+data[3][pos][k]+'</span>';
2635                                                                }
2636                                                                break;
2637
2638                                                        case 'cc_contacts':
2639
2640                                                                var id_group = data[3][pos][k-1];
2641                                                                var title = data[3][pos][k-3];
2642                                                                contacts = data[3][pos][k];
2643                                                                var contact = "";
2644                                                                var email = "";
2645
2646                                                                for (var d = 0; d < contacts.length; d++) {
2647                                                                        contact += contacts[d]['names_ordered']+ ",";
2648                                                                        email += contacts[d]['connection_value']+",";
2649                                                                }
2650
2651                                                                Element(id+':cc_participantes').innerHTML = '<span title="Ver Participantes" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccListParticipants.showList(\''+ Element(id+':cc_id').value+'value\', \''+contact+'\', \''+email+'\', \''+title+'\', \''+id_group+'\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img title="Ver participantes" align="center" src="templates/default/images/people-mini.png">&nbsp;&nbsp</span>';
2652
2653                                                                break;
2654
2655                                                        case 'cc_id':
2656                                                                var id_contact = data[3][pos][k];
2657                                                                Element(id+':'+data[2][k]).value = data[3][pos][k];
2658
2659                                                                break;
2660
2661                                                }
2662                                        }
2663                                }
2664
2665                                if (type == "shared_groups") {
2666                                       
2667                                        if (data[3][pos][4] & 4)
2668                                                eval("document.getElementById(id + ':cc_card_edit').onclick = function(){editSharedGroup(Element('"+id+"' + ':cc_id').value,"+data[3][pos][7]+");};");
2669                                        else
2670                                                document.getElementById(id + ':cc_card_edit').onclick = function(){     alert(Element('cc_msg_not_allowed').value); };
2671                                                                               
2672                                        if (data[3][pos][4] & 8)
2673                                                eval("document.getElementById(id + ':cc_card_remove').onclick = function(){removeEntry(Element('" + id + "' + ':cc_id').value,'groups');};");
2674                                        else
2675                                                document.getElementById(id + ':cc_card_remove').onclick = function(){
2676                                                        alert(Element('cc_msg_not_allowed').value);
2677                                                };
2678                                }                               
2679
2680                                if (--ncards == 0)
2681                                {
2682                                        j = CC_max_cards[0];
2683                                        i = CC_max_cards[1];
2684                                }
2685
2686                                pos++;
2687                        }
2688                }
2689        }
2690}
2691
2692function adjustString (str, max_chars)
2693{
2694        if (str.length > max_chars)
2695        {
2696                return str.substr(0,max_chars) + '...';
2697        }
2698        else
2699        {
2700                return str;
2701        }
2702}
2703
2704function setMaxCards (maxcards)
2705{
2706        CC_max_cards = maxcards;
2707        ncards = maxcards[0] * maxcards[1];
2708
2709        var handler = function (responseText)
2710        {
2711                showMessage('ok');
2712        };
2713
2714        Connector.newRequest('setMaxCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=set_n_cards&ncards=' + ncards, 'GET');
2715}
2716
2717function getMaxCards ()
2718{
2719        var coord = new Array();
2720
2721        card_space_width = parseInt(Element('cc_main').offsetWidth) - parseInt(Element('cc_left').offsetWidth) - parseInt(CC_card_extra);
2722        card_space_height = parseInt(Element('cc_card_space').offsetHeight) - parseInt(CC_card_extra);
2723
2724        card_width = CC_card_image_width + CC_card_extra;
2725        card_height = CC_card_image_height + CC_card_extra;
2726
2727        ncols = parseInt(card_space_width / card_width);
2728        nlines = parseInt(card_space_height / card_height);
2729
2730        coord[0] = ncols;
2731        coord[1] = 10;
2732
2733        return coord;
2734}
2735
2736function getCardHTML (id, type)
2737{
2738                if(type == 'groups' || type == 'shared_groups') {
2739                        html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' +
2740            '<div style="border: 0px solid #999; position: relative;">' +
2741                                '<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +
2742                                '<img title="'+Element('cc_msg_group_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editGroup(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' +
2743                                '<img title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="position: absolute; top: 78px; left: 223px; width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' +
2744                                '<span id="' + id + ':cc_title" style="position: absolute; top: 30px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_name_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_name_full\').style.visibility=\'hidden\'"></span>' +
2745                                '<span id="' + id + ':cc_participantes" style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 15px; left: 15px"></span>' +
2746                                '<span onMouseOver="this.title = \''+Element('cc_send_mail').value+'\'" id="' + id + ':cc_short_name" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
2747                                '<input id="' + id + ':cc_id" type="hidden">' +
2748                        '</div>' + '</td>';
2749
2750                }
2751                else {
2752                        html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' +
2753                                '<div style="border: 0px solid #999; position: relative;">' +
2754                                        '<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +
2755                                                ( ccTree.catalog_perms == 1 ?
2756                                                '<span id="' + id + ':cc_icon_data" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1"></span>':'') +
2757                                                (ccTree.catalog_perms & 2 ?
2758                                                '<img title="'+Element('cc_msg_card_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editContact(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' +
2759                                                '<img title="'+Element('cc_msg_card_remove').value+'" id="' + id + ':cc_card_remove" style="position: absolute; top: 78px; left: 223px; width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' : '') +
2760                                                '<img id="' + id + ':cc_photo" style="position: absolute; top: 15px; left: 7px;" src="" border="0" ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +
2761                                                '<span id="' + id + ':cc_company" style="position: absolute; top: 5px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_company_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_company_full\').style.visibility=\'hidden\'"></span>' +
2762                                                '<span style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 100px; left: 35px"  valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>'+
2763                                                //Para exibir a matricula do empregado nos cartoes
2764                                                '<span id="' + id + ':cc_empNumber" style="position: absolute; top: 20px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' +
2765                                                '<span id="' + id + ':cc_name" style="position: absolute; top: 30px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_name_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_name_full\').style.visibility=\'hidden\'"></span>' +
2766                                                '<span id="' + id + ':cc_title" style="position: absolute; top: 90px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 12px; text-align: center; height: 10px;"></span>' +
2767                                                //Para exibir o setor/lotacao do empregado nos cartoes
2768                                                '<span id="' + id + ':cc_department" style="position: absolute; top: 60px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
2769                                                '<span id="' + id + ':cc_phone" style="position: absolute; top: 75px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
2770                                                //Para exibir o celular empresarial do empregado na tabela
2771                                                '<span id="' + id + ':cc_mobile" style="position: absolute; top: 90px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
2772                                                '<span id="' + id + ':cc_mail" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
2773                                                '<span id="' + id + ':cc_alias" style="position: absolute; top: 95px; left: 10px; width: 60px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' +
2774                                        '<input id="' + id + ':cc_id" type="hidden">' +
2775                                '</div>' + '</td>';
2776                }
2777
2778        return html_card;
2779}
2780
2781function getTableHTML (id, type)
2782{
2783                        var bg = "";
2784                        if(!is_ie)
2785                                bg = "this.style.background=\'\'";
2786                        else
2787                                bg = "this.style.background=\'#EEEEEE\'";
2788                        if(type == 'groups' || type == 'shared_groups') {
2789                                html_card = '<tr width="40%" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE"><td width="auto" style="font-weight: normal; font-size: 10px; text-align: left; height: 10px;">' +
2790                                        '<span id="' + id + ':cc_participantes" style="cursor: pointer; cursor: hand; z-index: 1"></span>' +
2791                                        '<span id="' + id + ':cc_title"></span></td>' +
2792                                        '<td width="40%" style="solid #999; font-weight: normal; font-size: 10px; text-align: left; height: 10px"><span id="' + id + ':cc_short_name"></span></td>' +
2793                                        '<td align="center" width="10%">'+
2794                                        '<img  title="'+Element('cc_msg_group_edit').value+'" id="' + id + ':cc_card_edit" style=" cursor: pointer; cursor: hand; z-index: 1;width: 18px; height: 18px;"  onclick="editGroup(Element(\'' + id + ':cc_id\').value);" src="templates/default/images/cc_card_edit.png">' +
2795                                        '&nbsp;&nbsp;|&nbsp;&nbsp;'+
2796                                        '<img  title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" src="templates/default/images/cc_x.png">'  +
2797                                        '<input id="' + id + ':cc_id" type="hidden">'+
2798                                        '</td></tr>';
2799            }
2800            else {
2801                                html_card = '<tr  style="height:20px" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE">' +
2802                                        //Para exibir a matricula do empregado na tabela
2803                                        (preferences.empNumShow && ccTree.catalog_perms == 1 ? '<td align="center" width="10%" name="cc_name_empNumber" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_empNumber"></span></td>' : '') +
2804                                        '<td width="auto" style="font-weight: normal; font-size: 10px; text-align: left; height: 10px;"><span valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="' + id + ':cc_name"></span></td>' +
2805                                        '<td width="20%" align="center" name="cc_name_send_mail" style="solid #999; font-weight: normal; font-size: 10px; height: 10px"><span onMouseOver="this.title = \''+Element('cc_send_mail').value+' => '+'\'+document.getElementById(\''+id + ':cc_name\').innerHTML" id="' + id + ':cc_mail"></span></td>' +
2806                                        '<td width="20%" align="center" name="cc_name_phone" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_phone"></span></td>' +
2807                                        //Para exibir o celular empresarial do empregado na tabela
2808                                        (preferences.cellShow && ccTree.catalog_perms == 1 ?    '<td align="center" name="cc_name_mobile" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_mobile"></span></td>' : '') +
2809                                        //Para exibir o setor/lotacao do empregado na tabela
2810                                        (preferences.departmentShow && ccTree.catalog_perms == 1 ? '<td align="center" name="cc_name_title" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_title"></span></td>' : '') +
2811                                        ( ccTree.catalog_perms == 1 ?
2812                                        '<td align="center" width="10%"><span valign="bottom" id="' + id + ':cc_icon_data"></span></td>':'') +                                 
2813                                        (ccTree.catalog_perms & 2 ?
2814                                        '<td align="center" width="10%" >'+
2815                                        '<img  title="'+Element('cc_msg_card_edit').value+'" id="' + id + ':cc_card_edit" style=" cursor: pointer; cursor: hand; z-index: 1;width: 18px; height: 18px;"  onclick="editContact(Element(\'' + id + ':cc_id\').value);" src="templates/default/images/cc_card_edit.png">' +
2816                                        '&nbsp;&nbsp;|&nbsp;&nbsp;'+
2817                                        '<img title="'+Element('cc_msg_card_remove').value+'" id="' + id + ':cc_card_remove" style="width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value);" src="templates/default/images/cc_x.png">' : '') +
2818                                        '<input id="' + id + ':cc_id" type="hidden">'+
2819                                        '<input type="hidden" id="' + id + ':cc_photo">' +
2820                                        //'<span id="' + id + ':cc_mobile" style="display:none"></span>' +
2821                                        '<span id="' + id + ':cc_alias" style="display:none"></span>' +
2822                                        // Esse campo é necessário se o contato possui dados no campo cc_company
2823                                        '<span id="' + id + ':cc_company" style="display:none"></span>' +
2824                                        '</td></tr>';
2825                        }
2826
2827        return html_card;
2828}
2829
2830function drawTable(ncards, type)
2831{
2832        var pos;
2833        this.not_informed_text = Element("cc_msg_not_informed").value;
2834        html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1"><table width="100%" border="0" cellpadding="0" cellspacing="3">';
2835       
2836        if (ncards > 0)
2837        {
2838
2839                for (var i = 0; i < CC_max_cards[1]; i++)
2840                {
2841                        html_cards += '';
2842                        for (var j = 0; j < CC_max_cards[0]; j++)
2843                        {
2844                                html_cards += getTableHTML('cc_card:' + j + ':' + i, type);
2845                                if (--ncards == 0)
2846                                {
2847                                        j = CC_max_cards[0];
2848                                        i = CC_max_cards[1];
2849                                }
2850                        }
2851                        html_cards += '';
2852                }
2853                if((ccTree.catalog_perms & 2) && type != 'groups' && type !='shared_contacts' && type !='shared_groups')
2854                        html_cards += '<tr><td colspan=4 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>';
2855        }
2856        else if (CC_max_cards != 0)
2857        {
2858                html_cards += '<tr><td  align="center">' + Element('cc_msg_no_cards').value + '</td></tr>';
2859        }
2860        else
2861        {
2862                html_cards += '<tr><td  align="center">' + Element('cc_msg_err_no_room').value + '</td></tr>';
2863        }
2864
2865        html_cards += '</table></div>';
2866
2867        Element('cc_card_space').innerHTML = html_cards;
2868}
2869
2870function drawCards(ncards, type)
2871{
2872        var pos;
2873        html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1">';
2874        html_cards += '<table  border="0" cellpadding="0" cellspacing="' + CC_card_extra + '">';
2875
2876        if (ncards > 0)
2877        {
2878                for (var i = 0; i < CC_max_cards[1]; i++)
2879                {
2880                        html_cards += '<tr>';
2881                        for (var j = 0; j < CC_max_cards[0]; j++)
2882                        {
2883                                html_cards += getCardHTML('cc_card:' + j + ':' + i, type);
2884                                if (--ncards == 0)
2885                                {
2886                                        j = CC_max_cards[0];
2887                                        i = CC_max_cards[1];
2888                                }
2889                        }
2890                        html_cards += '</tr>';
2891                }
2892                if((ccTree.catalog_perms & 2) && type != 'groups' && type !='shared_contacts' && type !='shared_groups')
2893                        html_cards += '<tr><td colspan=3 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>';
2894        }
2895        else if (CC_max_cards != 0)
2896        {
2897                html_cards += '<tr><td>' + Element('cc_msg_no_cards').value + '</td></tr>';
2898        }
2899        else
2900        {
2901                html_cards += '<tr><td>' + Element('cc_msg_err_no_room').value + '</td></tr>';
2902        }
2903
2904        html_cards += '</table></div>';
2905
2906        Element('cc_card_space').innerHTML = html_cards;
2907}
2908
2909function showCards (letter,page, ids)
2910{
2911        this.not_informed_text = Element("cc_msg_not_informed").value;
2912       
2913        var data  = new Array();
2914        flag_compartilhado = false;
2915        if ( letter != CC_actual_letter )
2916        {
2917                CC_actual_page = '1';
2918        }
2919        else
2920        {
2921                CC_actual_page = page;
2922        }
2923
2924        CC_actual_letter = letter;
2925
2926        if (CC_max_cards[0] == 0)
2927        {
2928
2929                if(CC_visual == 'cards')
2930                        drawCards(0);
2931                else if(CC_visual == 'table')
2932                        drawTable(0);
2933
2934                setPages(0,0);
2935                return;
2936        }
2937
2938        var handler = function (responseText)
2939        {
2940                var data = new Array();
2941                data = unserialize(responseText);
2942                if (data[0] == '0')
2943                {
2944                        Element('cc_type_contact').value = data[1];
2945                        CC_npages = 0;
2946                        CC_actual_page = 1;
2947                        if(CC_visual == 'cards')
2948                                drawCards(0);
2949                        else if(CC_visual == 'table')
2950                                drawTable(0);
2951                        setPages(0,0);
2952                        return;
2953                }
2954                else
2955                Element('cc_type_contact').value = data[10];
2956
2957//              Element('cc_debug').innerHTML = responseText;
2958
2959                if (typeof(data) != 'object')
2960                {
2961                        showMessage(Element('cc_msg_err_contacting_server').value);
2962                        return;
2963                }
2964
2965                if (typeof(data[3]) == 'object')
2966                {
2967                        if (data[8] == 'bo_shared_people_manager')
2968                        {
2969                                flag_compartilhado = true;
2970                        }
2971                        else
2972                        {
2973                                flag_compartilhado = false;
2974                        }
2975                        qtd_compartilhado = data[9];
2976                        CC_npages = parseInt(data[0]);
2977                        CC_actual_page = parseInt(data[1]);
2978                        if(CC_visual == 'cards')
2979                                drawCards(data[3].length, data[10]);
2980                        else if(CC_visual == 'table')
2981                                drawTable(data[3].length, data[10]);
2982                        resizeWindow();
2983                        populateCards(data, data[10]);
2984                        setPages(data[0], data[1]);
2985
2986                }
2987                else if (data['error'])
2988                {
2989                        showMessage(data['error']);
2990                }
2991                else
2992                {
2993                        showMessage(Element('cc_msg_err_contacting_server').value);
2994                        return;
2995                }
2996        };
2997
2998        var info = "letter="+letter+"&page="+CC_actual_page+"&ids="+ids;
2999        Connector.newRequest('showCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cards_data', 'POST', handler, info);
3000}
3001
3002
3003function clearCards()
3004{
3005        clearLetterSelection();
3006        setHeightSpace();
3007        setMaxCards(getMaxCards());
3008
3009        if(CC_visual == 'cards')
3010                drawCards(0);
3011        else if(CC_visual == 'table')
3012                drawTable(0);
3013
3014        setPages(0,0);
3015        return;
3016}
3017
3018/***********************************************\
3019*        COMMON ENTRY FUNCTIONS                *
3020\***********************************************/
3021
3022function ccChangeVisualization(type)
3023{
3024        var table_h = Element('cc_panel_table');
3025        var cards_h = Element('cc_panel_cards');
3026
3027        switch (type)
3028        {
3029                case 'cards':
3030                        cards_h.style.display = 'none';
3031                        table_h.style.display = 'inline';
3032                        break;
3033
3034                case 'table':
3035                        table_h.style.display = 'none';
3036                        cards_h.style.display = 'inline';
3037                        break;
3038        }
3039
3040        CC_visual = type;
3041        showCards(getActualLetter(), getActualPage());
3042}
3043
3044function ccSearchUpdate()
3045{
3046        Element('cc_panel_letters').style.display = 'none';
3047        Element('cc_panel_search').style.display  = 'inline';
3048
3049        if(CC_visual == 'cards')
3050                drawCards(0);
3051        else if(CC_visual == 'table')
3052                drawTable(0);
3053
3054        if (CC_actual_letter != 'search')
3055        {
3056                CC_last_letter = CC_actual_letter;
3057        }
3058}
3059
3060function ccSearchHidePanel()
3061{
3062        Element('cc_panel_search').style.display  = 'none';
3063        Element('cc_panel_letters').style.display = 'inline';
3064        if (CC_actual_letter == 'search')
3065        {
3066                CC_actual_letter = CC_last_letter;
3067        }
3068}
3069
3070function ccSearchHide()
3071{
3072        Element('cc_panel_search').style.display  = 'none';
3073        Element('cc_panel_letters').style.display = 'inline';
3074        clearCards();
3075}
3076
3077/***********************************************\
3078*               QUICK ADD FUNCTIONS             *
3079\***********************************************/
3080
3081
3082function resetQuickAdd ()
3083{
3084        Element('cc_qa_alias').value = '';
3085        Element('cc_qa_given_names').value = '';
3086        Element('cc_qa_family_names').value = '';
3087        Element('cc_qa_phone').value = '';
3088        Element('cc_qa_email').value = '';
3089}
3090
3091function getQuickAdd ()
3092{
3093        var data = new Array();
3094        data[0] = Element('cc_qa_alias').value;
3095        data[1] = Element('cc_qa_given_names').value;
3096        data[2] = Element('cc_qa_family_names').value;
3097        data[3] = Element('cc_qa_phone').value;
3098        data[4] = Element('cc_qa_email').value;
3099
3100        return data;
3101}
3102
3103function sendQuickAdd ()
3104{
3105        var data = getQuickAdd();
3106
3107        var str = serialize(data);
3108
3109        if (!str)
3110        {
3111                return false;
3112        }
3113
3114        var handler = function (responseText)
3115        {
3116                setTimeout('updateCards()',100);;
3117        }
3118
3119        resetQuickAdd();
3120
3121        Connector.newRequest('quickAdd', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=quick_add', 'POST', handler, 'add='+escape(str));
3122}
3123
3124       
3125function connectVoip (phoneUser, typePhone){
3126        var handler_voip = function (responseText){
3127                if(!responseText) {
3128                        alert("Erro conectando servidor VoIP.");
3129                }
3130                else{
3131                    data = unserialize(responseText);
3132                        alert("Requisitando chamada para o ramal: "+data);
3133        }
3134        }
3135        Connector.newRequest('voip', "../../expressoMail1_2/controller.php?action=expressoMail1_2.functions.callVoipconnect&to="+phoneUser+"&typePhone="+typePhone, 'POST', handler_voip);
3136        }
Note: See TracBrowser for help on using the repository browser.