source: trunk/expressoAdmin1_2/js/jscode/users.js @ 2604

Revision 2604, 22.2 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1009 - Corrigindo problemas causados por javascripts inseridos dentro de tags.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1countFiles = 1;
2function validate_fields(type)
3{
4        if (type == 'create_user')
5        {
6                //UID
7                document.forms[0].uid.value = document.forms[0].uid.value.toLowerCase();
8               
9                if (document.forms[0].uid.value == ''){
10                        alert(get_lang('LOGIN field is empty') + '.');
11                        return;
12                }
13                else if (document.forms[0].uid.value.length < document.forms[0].minimumSizeLogin.value){
14                        alert(get_lang('LOGIN field must be bigger than') + ' ' + document.forms[0].minimumSizeLogin.value + ' ' + get_lang('characters') + '.');
15                        return;
16                }
17               
18                // Verifica se o delimitador do Cyrus permite ponto (dot.) nas mailboxes;
19                if (document.forms[0].imapDelimiter.value == '/')
20                        var reUid = /^([a-zA-Z0-9_\.\-])+$/;
21                else
22                        var reUid = /^([a-zA-Z0-9_\-])+$/;
23                if(!reUid.test(document.forms[0].uid.value)){
24                        alert(get_lang('LOGIN field contains characters not allowed') + '.');
25                        return;
26                }
27       
28                //PASSWORD's
29                if (document.forms[0].password1.value == ''){
30                        alert(get_lang('Password field is empty') + '.');
31                        return;
32                }
33                if (document.forms[0].password2.value == ''){
34                        alert(get_lang('repassword field is empty') + '.');
35                        return;
36                }
37        }
38
39        if (document.forms[0].password1.value != document.forms[0].password2.value){
40                alert(get_lang('password and repassword are different') + '.');
41                return;
42        }
43
44        // Corporative Information
45        if (document.forms[0].corporative_information_employeenumber.value != "")
46        {
47                var re_employeenumber = /^([0-9])+$/;
48               
49                if(!re_employeenumber.test(document.forms[0].corporative_information_employeenumber.value))
50                {
51                        alert(get_lang('EmployeeNumber contains characters not allowed') + '. ' + get_lang('Only numbers are allowed') + '.');
52                        document.forms[0].corporative_information_employeenumber.focus();
53                        return;
54                }
55        }
56
57        //MAIL
58        document.forms[0].mail.value = document.forms[0].mail.value.toLowerCase();
59        if (document.forms[0].mail.value == ''){
60                alert(get_lang('Email field is empty') + '.');
61                return;
62        }
63        var reEmail = /^([a-zA-Z0-9_\-])+(\.[a-zA-Z0-9_\-]+)*\@([a-zA-Z0-9_\-])+(\.[a-zA-Z0-9_\-]+)*$/;
64        if(!reEmail.test(document.forms[0].mail.value)){
65                alert(get_lang('Email field is not valid') + '.');
66                return false;
67        }
68       
69        //FIRSTNAME
70        var reGivenname = /^[a-zA-Z0-9 \-\.]+$/;
71        if(!reGivenname.test(document.forms[0].givenname.value)){
72                alert(get_lang('First name field contains characters not allowed') + '.');
73                return false;
74        }
75        else if (document.forms[0].givenname.value == ''){
76                alert(get_lang('First name field is empty') + '.');
77                return;
78        }
79       
80        //LASTNAME
81        var reSn = /^[a-zA-Z0-9 \-\.]+$/;
82        if(!reSn.test(document.forms[0].sn.value)){
83                alert(get_lang('Last name field contains characters not allowed') + '.');
84                return false;
85        }
86        else if (document.forms[0].sn.value == ''){
87                alert(get_lang('Last name field is empty') + '.');
88                return;
89        }
90       
91        //TELEPHONENUMBER
92        if (document.forms[0].telephonenumber.value != '')
93        {
94                reg_tel = /\(\d{2}\)\d{4}-\d{4}$/;
95                if (!reg_tel.exec(document.forms[0].telephonenumber.value))
96                {
97                        alert(get_lang('Phone field is incorrect') + '.');
98                        return;
99                }
100        }
101       
102        //FORWAR ONLY
103        if ((document.forms[0].deliverymode.checked) && (document.forms[0].mailforwardingaddress.value == '')){
104                alert(get_lang('Forward email is empty') + '.');
105                return;
106        }
107       
108        // Email Quota
109        if (document.forms[0].mailquota.value == ''){
110                alert(get_lang('User without email quota') + '.');
111                return;
112        }
113       
114        //GROUPS
115        if (document.getElementById('ea_select_user_groups').length < 1){
116                alert(get_lang('User is not in any group') + '.');
117                return;
118        }
119
120        //SAMBA
121        if (document.getElementById('tabcontent6').style.display != 'none'){
122                if ((document.forms[0].sambalogonscript.value == '') && (!document.forms[0].sambalogonscript.disabled)){
123                        alert(get_lang('Logon script is empty') + '.');
124                        return;
125                }
126                if ((document.forms[0].sambahomedirectory.value == '') && (!document.forms[0].sambahomedirectory.disabled)){
127                        alert(get_lang('Users home directory is empty') + '.');
128                        return;
129                }
130        }
131
132        // Uid, Mail and CPF exist?
133        var attrs_array = new Array();
134        attrs_array['type'] = type;
135        attrs_array['uid'] = document.forms[0].uid.value;
136        attrs_array['mail'] = document.forms[0].mail.value;
137        attrs_array['cpf'] = document.forms[0].corporative_information_cpf.value;
138       
139        if (document.forms[0].mailalternateaddress.value != '')
140                attrs_array['mailalternateaddress'] = document.forms[0].mailalternateaddress.value;
141        var attributes = connector.serialize(attrs_array);
142
143        var handler_validate_fields = function(data)
144        {
145                if (!data.status)
146                {
147                        alert(data.msg);
148                }
149                else
150                {
151                        if ( (data.question) && (!confirm(data.question)) )
152                        {
153                                return false;
154                        }
155
156                        if (type == 'create_user')
157                        {
158                                cExecuteForm ("$this.user.create", document.forms[0], handler_create);
159                        }
160                        else
161                        {
162                                //Turn enabled all checkboxes and inputs
163                                document.getElementById('changepassword').disabled = false;
164                                document.getElementById('phpgwaccountstatus').disabled = false;
165                                document.getElementById('phpgwaccountvisible').disabled = false;
166                                document.getElementById('telephonenumber').disabled = false;
167                                document.getElementById('mailforwardingaddress').disabled = false;
168                                document.getElementById('mailalternateaddress').disabled = false;
169                                document.getElementById('passwd_expired').disabled = false;
170                                document.getElementById('accountstatus').disabled = false;
171                                document.getElementById('deliverymode').disabled = false;
172                                document.getElementById('use_attrs_samba').disabled = false;
173                               
174                                table_apps = document.getElementById('ea_table_apps');
175                                var inputs = table_apps.getElementsByTagName("input");
176                                for (var i = 0; i < inputs.length; i++)
177                                {
178                                        inputs[i].disabled = false;
179                                }
180                                cExecuteForm ("$this.user.save", document.forms[0], handler_save);
181                        }
182                }
183        }
184       
185        // Needed select all options from select
186        select_user_maillists = document.getElementById('ea_select_user_maillists');
187        select_user_groups = document.getElementById('ea_select_user_groups');
188        for(var i=0; i<select_user_maillists.options.length; i++)
189                select_user_maillists.options[i].selected = true;
190        for(var i=0; i<select_user_groups.options.length; i++)
191                select_user_groups.options[i].selected = true;
192        /////////////////////////////////////////////////////////////////////////////////////////////////////////
193        document.getElementById('uid').disabled = false; //Caso o login seja gerado automático, tirar o disabled.
194        cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields);
195}
196
197function generate_login(first_name,second_name) {
198        if ((first_name=='') || (second_name=='')) {
199                alert(get_lang("You must type the first and the second name before generate the login"));
200                return;
201        }
202        var attrs_array = new Array();
203        attrs_array['first_name'] = first_name;
204        attrs_array['second_name'] = second_name;
205        var attributes = connector.serialize(attrs_array);
206       
207        var handler_generate_login = function(data) {
208                if(data['status']) {
209                        document.getElementById('uid').value = data['msg'];
210                        emailSuggestion_expressoadmin('true','true');
211                        document.getElementById("mail").value=document.getElementById("mail1").value;
212                }
213                else
214                        alert(data['msg']);
215        }
216
217        cExecute ('$this.ldap_functions.generate_login&attributes='+attributes, handler_generate_login);
218}
219
220// HANDLER CREATE
221// É necessário 2 funcões de retorno por causa do cExecuteForm.
222function handler_create(data)
223{
224        return_handler_create(data);
225}
226function return_handler_create(data)
227{
228        if (!data.status)
229                alert(data.msg);
230        else
231                alert(get_lang('User successful created') + '.');
232
233        location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users";
234        return;
235}
236
237
238// HANDLER SAVE
239// É necessário 2 funcões de retorno por causa do cExecuteForm.
240function handler_save(data)
241{
242        return_handler_save(data);
243}
244function return_handler_save(data)
245{
246        if (!data.status){
247                alert(data.msg);
248        }
249        else{
250                alert(get_lang('User successful saved') + '.');
251        }
252        location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users";
253        return;
254}
255
256function get_available_groups(context)
257{
258        var handler_get_available_groups = function(data)
259        {
260                select_available_groups = document.getElementById('ea_select_available_groups');
261
262                if ((data) && (data.length > 0))
263                {
264                        // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
265                        select_available_groups.innerHTML = '#' + data;
266                        select_available_groups.outerHTML = select_available_groups.outerHTML;
267                        select_available_groups_clone = select_available_groups.cloneNode(true);
268                        document.getElementById('ea_input_searchGroup').value = '';
269                }
270                else
271                {
272                        // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
273                        select_available_groups.innerHTML = '#';
274                        select_available_groups.outerHTML = select_available_groups.outerHTML;
275                }
276        }       
277               
278        _controller.go( {
279                "access" : "$this.ldap_functions.get_available_groups&context="+context,
280                "handler" : function( data )
281                {
282                        handler_get_available_groups( expresso.connector.unserialize( data ) );
283                }
284        } );
285}
286       
287function add_user2group()
288{
289        select_available_groups = document.getElementById('ea_select_available_groups');
290        select_user_groups = document.getElementById('ea_select_user_groups');
291        combo_primary_user_group = document.getElementById('ea_combo_primary_user_group');
292
293        for (i = 0 ; i < select_available_groups.length ; i++)
294        {
295                if (select_available_groups.options[i].selected)
296                {
297                        isSelected = false;
298                        for(var j = 0;j < select_user_groups.options.length; j++)
299                        {
300                                if(select_user_groups.options[j].value == select_available_groups.options[i].value)
301                                {
302                                        isSelected = true;                                             
303                                        break; 
304                                }
305                        }
306
307                        if(!isSelected)
308                        {
309                                new_option1 = document.createElement('option');
310                                new_option1.value =select_available_groups.options[i].value;
311                                new_option1.text = select_available_groups.options[i].text;
312                                new_option1.selected = true;
313                                select_user_groups.options[select_user_groups.options.length] = new_option1;
314                               
315                                new_option2 = document.createElement('option');
316                                new_option2.value =select_available_groups.options[i].value;
317                                new_option2.text = select_available_groups.options[i].text;
318                                combo_primary_user_group.options[combo_primary_user_group.options.length] = new_option2;
319                        }
320                }
321        }
322               
323        for (j =0; j < select_available_groups.options.length; j++)
324                select_available_groups.options[j].selected = false;
325}       
326       
327function remove_user2group()
328{
329        select_user_groups = document.getElementById('ea_select_user_groups');
330        combo_primary_user_group = document.getElementById('ea_combo_primary_user_group');
331       
332        var x;
333        var j=0;
334        var to_remove = new Array();
335       
336        for(var i = 0;i < select_user_groups.options.length; i++)
337        {
338                if(select_user_groups.options[i].selected)
339                {
340                        to_remove[j] = select_user_groups.options[i].value;
341                        j++;
342                        select_user_groups.options[i--] = null;
343                }
344        }
345       
346        for (x in to_remove)
347        {
348                for(var i=0; i<combo_primary_user_group.options.length; i++)
349                {
350                        if (combo_primary_user_group.options[i].value == to_remove[x])
351                        {
352                                combo_primary_user_group.options[i] = null;
353                        }       
354                }
355        }
356}
357       
358function get_available_maillists(context)
359{
360        var handler_get_available_maillists = function(data)
361        {
362                select_available_maillists = document.getElementById('ea_select_available_maillists');
363
364                if ((data) && (data.length > 0))
365                {
366                        // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
367                        select_available_maillists.innerHTML = '#' + data;
368                        select_available_maillists.outerHTML = select_available_maillists.outerHTML;
369                        select_available_maillists_clone = select_available_maillists.cloneNode(true);
370                        document.getElementById('ea_input_searchMailList').value = '';
371                }
372                else
373                {
374                        // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
375                        select_available_maillists.innerHTML = '#';
376                        select_available_maillists.outerHTML = select_available_maillists.outerHTML;
377                }
378        }
379        _controller.go( {
380                "access" : "$this.ldap_functions.get_available_maillists&context=" + context,
381                "handler" : function( data )
382                {
383                        handler_get_available_maillists( expresso.connector.unserialize( data ) );
384                }
385        } );
386}
387       
388function add_user2maillist()
389{
390        select_available_maillists = document.getElementById('ea_select_available_maillists');
391        select_user_maillists = document.getElementById('ea_select_user_maillists');
392
393        for (i = 0 ; i < select_available_maillists.length ; i++)
394        {
395
396                if (select_available_maillists.options[i].selected)
397                {
398                        isSelected = false;
399                        for(var j = 0;j < select_user_maillists.options.length; j++)
400                        {
401                                if(select_user_maillists.options[j].value == select_available_maillists.options[i].value)
402                                {
403                                        isSelected = true;                                             
404                                        break; 
405                                }
406                        }
407
408                        if(!isSelected)
409                        {
410                                new_option = document.createElement('option');
411                                new_option.value =select_available_maillists.options[i].value;
412                                new_option.text = select_available_maillists.options[i].text;
413                                new_option.selected = true;
414                                       
415                                select_user_maillists.options[select_user_maillists.options.length] = new_option;
416                        }
417                }
418        }
419               
420        for (j =0; j < select_available_maillists.options.length; j++)
421                select_available_maillists.options[j].selected = false;
422}       
423       
424function remove_user2maillist()
425{
426        select_user_maillists = document.getElementById('ea_select_user_maillists');
427
428        for(var i = 0;i < select_user_maillists.options.length; i++)
429                if(select_user_maillists.options[i].selected)
430                        select_user_maillists.options[i--] = null;
431}
432       
433function sinc_combos_org(context)
434{
435        combo_org_groups = document.getElementById('ea_combo_org_groups');
436        combo_org_maillists = document.getElementById('ea_combo_org_maillists');
437
438        for (i=0; i<combo_org_groups.length; i++)
439        {
440                if (combo_org_groups.options[i].value == context)
441                {
442                        combo_org_groups.options[i].selected = true;
443                        combo_org_maillists.options[i].selected = true;
444                }
445        }
446}
447       
448function use_samba_attrs(value)
449{
450        if (value)
451        {
452                if (document.forms[0].sambalogonscript.value == '')
453                {
454                        if (document.forms[0].defaultLogonScript.value == '')
455                        {
456                                document.forms[0].sambalogonscript.value = document.forms[0].uid.value + '.bat';
457                        }
458                        else
459                        {
460                                document.forms[0].sambalogonscript.value = document.forms[0].defaultLogonScript.value;
461                        }
462                }
463                if (document.forms[0].sambahomedirectory.value == '')
464                {
465                        document.forms[0].sambahomedirectory.value = '/home/'+document.forms[0].uid.value+'/';
466                }
467        }
468       
469        if (!document.forms[0].use_attrs_samba.disabled)
470        {
471                document.forms[0].sambaacctflags.disabled = !value;
472                document.forms[0].sambadomain.disabled = !value;
473                document.forms[0].sambalogonscript.disabled = !value;
474                document.forms[0].sambahomedirectory.disabled = !value;
475        }
476}
477       
478function set_user_default_password()
479{
480        var handler_set_user_default_password = function(data)
481        {
482                if (!data.status)
483                        alert(data.msg);
484                else
485                        alert(get_lang('Default password successful saved') + '.');
486                return;
487        }
488        cExecute ('$this.user.set_user_default_password&uid='+document.forms[0].uid.value, handler_set_user_default_password); 
489}
490
491function return_user_password()
492{
493        var handler_return_user_password = function(data)
494        {
495                if (!data.status)
496                        alert(data.msg);
497                else
498                        alert(get_lang('Users password successful returned') + '.');
499                return;
500        }
501        cExecute ('$this.user.return_user_password&uid='+document.forms[0].uid.value, handler_return_user_password);
502}
503
504function delete_user(uid, uidnumber)
505{
506        if (confirm(get_lang("Do you really want delete the user") + " " + uid + "?"))
507        {
508                var handler_delete_user = function(data)
509                {
510                        if (!data.status)
511                                alert(data.msg);
512                        else
513                                alert(get_lang('User successful deleted') + '.');
514                       
515                        location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users";
516                        return;
517                }
518                cExecute ('$this.user.delete&uidnumber='+uidnumber+'&uid='+uid, handler_delete_user);
519        }
520}
521
522function rename_user(uid, uidnumber)
523{
524        if (document.getElementById('accounts_form_imapDelimiter').value == '/')
525                var reUid = /^([a-zA-Z0-9_\.\-])+$/;
526        else
527                var reUid = /^([a-zA-Z0-9_\-])+$/;
528
529        new_uid = prompt(get_lang('Rename users login from') + ': ' + uid + " " + get_lang("to") + ': ', uid);
530
531        if(!reUid.test(new_uid)){
532                alert(get_lang('LOGIN field contains characters not allowed') + '.');
533                document.forms[0].account_lid.focus();
534                return;
535        }
536       
537        if ((new_uid) && (new_uid != uid))
538        {
539                var handler_validate_fields = function(data)
540                {
541                        if (!data.status)
542                                alert(data.msg);
543                        else
544                                cExecute ('$this.user.rename&uid='+uid+'&new_uid='+new_uid, handler_rename);
545                       
546                        return;
547                }
548               
549                // New uid exist?
550                attrs_array = new Array();
551                attrs_array['type'] = 'rename_user';
552                attrs_array['uid'] = new_uid;
553                attributes = connector.serialize(attrs_array);
554       
555                cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields);
556        }
557}
558
559// HANDLER RENAME
560function handler_rename(data)
561{
562        if (!data.status)
563                alert(data.msg);
564        else{
565                alert(get_lang('User login successful renamed') + "\n" + data.exec_return);
566                location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users";
567        }
568        return;
569
570}
571
572
573// Variaveis Locais
574var finderTimeout_maillist = '';
575
576// Funcoes Find MailList
577function optionFinderTimeout_maillist(obj)
578{
579        clearTimeout(finderTimeout_maillist);
580        var oWait = document.getElementById("ea_span_searching_maillist");
581        oWait.innerHTML = get_lang('Searching') + '...';
582        finderTimeout_maillist = setTimeout("optionFinder_maillist('"+obj.id+"')",500);
583}
584function optionFinder_maillist(id) {
585        var oWait = document.getElementById("ea_span_searching_maillist");
586        var oText = document.getElementById(id);
587               
588        //Limpa todo o select
589        for(var i = 0;i < select_available_maillists.options.length; i++)
590                select_available_maillists.options[i--] = null;
591       
592        var RegExp_name = new RegExp(oText.value, "i");
593       
594        //Inclui as listas começando com a pesquisa
595        for(i = 0; i < select_available_maillists_clone.length; i++){
596                if (RegExp_name.test(select_available_maillists_clone[i].text))
597                {
598                        sel = select_available_maillists.options;
599                        option = new Option(select_available_maillists_clone[i].text,select_available_maillists_clone[i].value);                               
600                        sel[sel.length] = option;
601                }
602        }
603        oWait.innerHTML = '&nbsp;';
604}                       
605
606// Variaveis Locais
607var finderTimeout_group = '';
608
609
610// Funcoes Find Group
611function optionFinderTimeout_group(obj)
612{
613        clearTimeout(finderTimeout_group);
614        var oWait = document.getElementById("ea_span_searching_group");
615        oWait.innerHTML = get_lang('Searching') + '...';
616        finderTimeout_group = setTimeout("optionFinder_group('"+obj.id+"')",500);
617}
618function optionFinder_group(id) {       
619        var oWait = document.getElementById("ea_span_searching_group");
620        var oText = document.getElementById(id);
621               
622        //Limpa todo o select
623        for(var i = 0;i < select_available_groups.options.length; i++)
624                select_available_groups.options[i--] = null;
625       
626        var RegExp_name = new RegExp(oText.value, "i");
627       
628        //Inclui as listas começando com a pesquisa
629        for(i = 0; i < select_available_groups_clone.length; i++){
630                if (RegExp_name.test(select_available_groups_clone[i].text))
631                {
632                        sel = select_available_groups.options;
633                        option = new Option(select_available_groups_clone[i].text,select_available_groups_clone[i].value);                             
634                        sel[sel.length] = option;
635                }
636        }
637        oWait.innerHTML = '&nbsp;';
638}
639
640function get_available_sambadomains(context, type)
641{
642        if ((type == 'create_user') && (document.getElementById('tabcontent7').style.display != 'none'))
643        {
644                var handler_get_available_sambadomains = function(data)
645                {
646                        document.forms[0].use_attrs_samba.checked = data.status;
647                        use_samba_attrs(data.status);
648                       
649                        if (data.status)
650                        {
651                                combo_sambadomains = document.getElementById('ea_combo_sambadomains');
652                                for (i=0; i<data.sambaDomains.length; i++)
653                                {
654                                        for (j=0; j<combo_sambadomains.length; j++)
655                                        {
656                                                if (combo_sambadomains.options[j].text == data.sambaDomains[i])
657                                                {
658                                                        combo_sambadomains.options[j].selected = true;
659                                                        break;
660                                                }
661                                        }
662                                }
663                               
664                        }
665                }
666               
667                cExecute ('$this.ldap_functions.exist_sambadomains_in_context&context='+context, handler_get_available_sambadomains);
668        }
669}
670
671function empty_inbox(uid)
672{
673        var action = get_lang('Cleanned user mailbox');
674        var handler_write_log = function(){}
675        var handler_empty_inbox = function(data)
676        {
677                if (!data.status)
678                        alert(data.msg);
679                else{
680                        cExecute ('$this.user.write_log_from_ajax&_action='+action+'&userinfo='+uid, handler_write_log);
681                        alert(get_lang('Emptied')+' '+ data.inbox_size + ' ' + get_lang('MB from user inbox'));
682                        document.getElementById('mailquota_used').value = data.mailquota_used;
683                }
684        }
685        cExecute ('$this.imap_functions.empty_user_inbox&uid='+uid, handler_empty_inbox);
686}
687
688function validarCPF(cpf)
689{
690        if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
691                cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
692                cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
693                cpf == "88888888888" || cpf == "99999999999"){
694          return false;
695   }
696
697        soma = 0;
698        for(i = 0; i < 9; i++)
699                soma += parseInt(cpf.charAt(i)) * (10 - i);
700        resto = 11 - (soma % 11);
701        if(resto == 10 || resto == 11)
702                resto = 0;
703        if(resto != parseInt(cpf.charAt(9)))
704        {
705                return false;
706        }
707       
708        soma = 0;
709        for(i = 0; i < 10; i ++)
710                soma += parseInt(cpf.charAt(i)) * (11 - i);
711        resto = 11 - (soma % 11);
712        if(resto == 10 || resto == 11)
713                resto = 0;
714        if(resto != parseInt(cpf.charAt(10))){
715                return false;
716        }
717        return true;
718}
719
720function search_organization(key, element)
721{
722        var organizations = document.getElementById(element);
723        var RegExp_org = new RegExp("\\b"+key, "i");
724       
725        for(i = 0; i < organizations.length; i++)
726        {
727                if (RegExp_org.test(organizations[i].text))
728                {
729                        organizations[i].selected = true;
730                        return;
731                }
732        }
733}
734
735function add_input_mailalternateaddress()
736{
737        var input = document.createElement("INPUT");
738        input.size = 30;
739        input.name = "mailalternateaddress[]";
740        input.setAttribute("autocomplete","off");
741        document.getElementById("td_input_mailalternateaddress").appendChild(document.createElement("br"));
742        document.getElementById("td_input_mailalternateaddress").appendChild(input);
743}
744
745function add_input_mailforwardingaddress()
746{
747        var input = document.createElement("INPUT");
748        input.size = 30;
749        input.name = "mailforwardingaddress[]";
750        input.setAttribute("autocomplete","off");
751        document.getElementById("td_input_mailforwardingaddress").appendChild(document.createElement("br"));
752        document.getElementById("td_input_mailforwardingaddress").appendChild(input);
753}
754
755function set_changepassword()
756{
757        if (document.getElementById('passwd_expired').checked)
758                {
759                document.getElementById('changepassword').checked = true;
760                document.getElementById('changepassword').disabled = true;
761                }
762                else
763                {
764                document.getElementById('changepassword').disabled =false;
765                }
766}
767
768
Note: See TracBrowser for help on using the repository browser.