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

Revision 5661, 95.0 KB checked in by angelo, 12 years ago (diff)

Ticket #2518 - Correcao em elementos da janela cadastro e alteracao de contatos

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