Commit cb5ba584e695c242ccb19047bc5334f9fae10731

Authored by Eriksen Costa
1 parent 9cda1b29
Exists in master

Refactoring para coding standards

Showing 1 changed file with 1140 additions and 943 deletions   Show diff stats
ieducar/intranet/scripts/padrao.js
1   -function openfoto( foto, altura, largura )
  1 +/**
  2 + * i-Educar - Sistema de gestão escolar
  3 + *
  4 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  5 + * <ctima@itajai.sc.gov.br>
  6 + *
  7 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  8 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  9 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  10 + * qualquer versão posterior.
  11 + *
  12 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  13 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  14 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  15 + * do GNU para mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  18 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  19 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  20 + *
  21 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  22 + * @license @@license@@
  23 + * @since Arquivo disponível desde a versão 1.0.0
  24 + * @version $Id$
  25 + */
  26 +
  27 +function openfoto(foto, altura, largura)
2 28 {
3   - abrir = 'visualizarfoto.php?id_foto='+foto;
4   - apr = 'width='+altura+', height='+largura+', scrollbars=no, top=10, left=10';
5   - var foto_ = window.open( abrir, 'JANELA_FOTO', apr );
6   - foto_.focus();
  29 + abrir = 'visualizarfoto.php?id_foto=' + foto;
  30 + apr = 'width=' + altura + ', height=' + largura + ', scrollbars=no, top=10, left=10';
  31 + var foto_ = window.open(abrir, 'JANELA_FOTO', apr);
  32 + foto_.focus();
7 33 }
8 34  
9   -function setFocus(campo){
10   - if(document.getElementById){
11   - var campo_ = document.getElementById(campo);
12   - campo_.focus();
13   - }
14   - else{
15   - if(document.forms[0]){
16   - var elements_ = document.forms[0].elements;
17   - for(var ct = 0 ; ct < elements_.length ; ct++){
18   - if(elements_[ct].getAttribute('type') != "hidden" && elements_[ct].disabled == false){
19   - elements_[ct].focus();
20   - break;
21   - }
22   - }
23   - }
24   - }
  35 +/**
  36 + * @TODO Remover função, chamadas no i-Educar comentadas (código nunca invocado).
  37 + * Ver: $ egrep -rn 'setFocus[ ]{0,3}\(' intranet/
  38 + */
  39 +function setFocus(campo)
  40 +{
  41 + if (document.getElementById) {
  42 + var campo_ = document.getElementById(campo);
  43 + campo_.focus();
  44 + }
  45 + else {
  46 + if (document.forms[0]) {
  47 + var elements_ = document.forms[0].elements;
  48 +
  49 + for (var ct = 0 ; ct < elements_.length ; ct++){
  50 + if (elements_[ct].getAttribute('type') != 'hidden' && elements_[ct].disabled == false){
  51 + elements_[ct].focus();
  52 + break;
  53 + }
  54 + }
  55 + }
  56 + }
25 57 }
26 58  
27   -function openfotoagricultura( foto, altura, largura )
  59 +/**
  60 + * @TODO Remover função, sem chamadas no i-Educar.
  61 + */
  62 +function openfotoagricultura(foto, altura, largura)
28 63 {
29   - abrir = 'visualizarfotoagricultura.php?id_foto='+foto;
30   - apr = 'width='+altura+', height='+largura+', scrollbars=no, top=10, left=10';
31   - var foto_ = window.open( abrir, 'JANELA_FOTO', apr );
32   - foto_.focus();
  64 + abrir = 'visualizarfotoagricultura.php?id_foto=' + foto;
  65 + apr = 'width=' + altura + ', height=' + largura + ', scrollbars=no, top=10, left=10';
  66 + var foto_ = window.open(abrir, 'JANELA_FOTO', apr);
  67 + foto_.focus();
33 68 }
34 69  
  70 +/**
  71 + * @TODO Remover função, chamadas no i-Educar comentadas (código nunca invocado).
  72 + * Remover também o código legado que o referencia, funcionalidades inúteis.
  73 + * Ver: $ egrep -rn 'openurl[ ]{0,3}\(' intranet/
  74 + */
35 75 function openurl(url)
36 76 {
37   - window.open(url,'PROCURAR','width=800, height=300, top=10, left=10, scrollbars=yes');
  77 + window.open(url, 'PROCURAR', 'width=800, height=300, top=10, left=10, scrollbars=yes');
38 78 }
39 79  
  80 +/**
  81 + * @TODO Remover função, sem chamadas no i-Educar.
  82 + */
40 83 function openurlmaximized(url)
41 84 {
42   - var janela = window.open(url,'PROCURAR','status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=yes, fullscreen=yes, scrollbars=yes');
43   - janela.innerWidth = screen.width;
44   - janela.innerHeight = screen.height;
45   - janela.screenX = 0;
46   - janela.screenY = 0;
  85 + var janela = window.open(url, 'PROCURAR',
  86 + 'status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=yes, fullscreen=yes, scrollbars=yes'
  87 + );
  88 +
  89 + janela.innerWidth = screen.width;
  90 + janela.innerHeight = screen.height;
  91 + janela.screenX = 0;
  92 + janela.screenY = 0;
47 93 }
48 94  
49   -
50   -
  95 +/**
  96 + * @TODO Remover função, chamadas no i-Educar são em código legado em
  97 + * funcionalidades inúteis.
  98 + * Ver: $ egrep -rn 'retorna[ ]{0,3}\(' intranet/
  99 + */
51 100 function retorna(form, campo, valor)
52 101 {
53   - //window.opener.document.getElementById(campo).value=valor;
54   - window.parent.document.getElementById(campo).value=valor;
55   - campo = campo + "_";
56   - //window.opener.document.getElementById(campo).value=valor;
57   - window.parent.document.getElementById(campo).value=valor;
58   - //window.opener.insereSubmit();
59   - window.parent.insereSubmit();
60   - window.close();
61   - window.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));
  102 + window.parent.document.getElementById(campo).value=valor;
  103 +
  104 + campo = campo + '_';
  105 + window.parent.document.getElementById(campo).value=valor;
  106 +
  107 + window.parent.insereSubmit();
  108 + window.close();
  109 +
  110 + window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
62 111 }
63   -function insereSubmit( )
64   -{
65   - document.getElementById('tipoacao').value = "";
66   - //document.formcadastro.tipoacao.value = "";
67   - document.getElementById('formcadastro').submit();
68   - //document.formcadastro.submit();
69 112  
  113 +/**
  114 + * @TODO Remover função, chamadas no i-Educar são em código legado em
  115 + * funcionalidades inúteis.
  116 + * Ver: $ egrep -rn 'insereSubmit[ ]{0,3}\(' intranet/
  117 + */
  118 +function insereSubmit()
  119 +{
  120 + document.getElementById('tipoacao').value = '';
  121 + document.getElementById('formcadastro').submit();
70 122 }
71   -function insereSubmitLista( )
  123 +
  124 +function insereSubmitLista()
72 125 {
73   - document.getElementById('tipoacao').value = "";
74   - document.getElementById('lista').value = "1";
75   - document.getElementById('formcadastro').submit();
  126 + document.getElementById('tipoacao').value = '';
  127 + document.getElementById('lista').value = '1';
  128 +
  129 + document.getElementById('formcadastro').submit();
76 130 }
77 131  
  132 +/**
  133 + * @TODO Remover função, sem chamadas no i-Educar.
  134 + */
78 135 function insereSubmitNomeArquivo(nome)
79 136 {
80   - if(document.getElementById(nome).value)
81   - {
82   - document.getElementById('tipoacao').value = "";
83   - //document.formcadastro.tipoacao.value = "";
84   - document.getElementById('formcadastro').submit();
85   - //document.formcadastro.submit();
86   - }else
87   - {
88   - alert("Por Favor Insira um nome para o Arquivo");
89   - }
  137 + if (document.getElementById(nome).value) {
  138 + document.getElementById('tipoacao').value = '';
  139 + document.getElementById('formcadastro').submit();
  140 + }
  141 + else {
  142 + alert('Por favor insira um nome para o arquivo');
  143 + }
90 144 }
91 145  
92   -
93   -function insereSubmitValor(valor, campo )
  146 +/**
  147 + * @TODO Remover função, sem chamadas no i-Educar.
  148 + */
  149 +function insereSubmitValor(valor, campo)
94 150 {
95   - document.getElementById(campo).value = valor;
96   - document.getElementById('tipoacao').value = "";
97   - //document.formcadastro.tipoacao.value = "";
98   - document.getElementById('formcadastro').submit();
99   - //document.formcadastro.submit();
  151 + document.getElementById(campo).value = valor;
  152 + document.getElementById('tipoacao').value = '';
100 153  
  154 + document.getElementById('formcadastro').submit();
101 155 }
102 156  
103   -function reload( operador )
  157 +/**
  158 + * @TODO Remover função, sem chamadas no i-Educar.
  159 + */
  160 +function reload(operador)
104 161 {
105   - if( document.getElementById('operador').value < 7 )
106   - {
107   - if( document.getElementById('valor').value != "" )
108   - {
109   - if( document.getElementById('logico').value != 0 )
110   - {
111   - document.getElementById('operador_logico').value = operador;
112   - document.formcadastro.submit();
113   - }
114   - }
115   - else
116   - {
117   - document.getElementById('logico_0').selected = true;
118   - alert("Insira o Valor");
119   - }
120   - }
121   - else
122   - {
123   - document.getElementById('operador_logico').value = operador;
124   - document.formcadastro.submit();
125   - }
  162 + if (document.getElementById('operador').value < 7) {
  163 + if (document.getElementById('valor').value != '') {
  164 + if (document.getElementById('logico').value != 0) {
  165 + document.getElementById('operador_logico').value = operador;
  166 + document.formcadastro.submit();
  167 + }
  168 + }
  169 + else {
  170 + document.getElementById('logico_0').selected = true;
  171 + alert('Insira o valor');
  172 + }
  173 + }
  174 + else {
  175 + document.getElementById('operador_logico').value = operador;
  176 + document.formcadastro.submit();
  177 + }
126 178 }
127 179  
128   -function meusdadosReload( tipo )
129   -{
130   - document.getElementById( 'reloading' ).value = 1;
131   - objSec = document.getElementById( 'f_ref_sec' );
132   - objDep = document.getElementById( 'f_ref_dept' );
133   - objSet = document.getElementById( 'f_ref_setor' );
134   - if( typeof objDep.selectedIndex == 'number' && tipo < 2 )
135   - {
136   - document.getElementById( 'f_ref_dept_0' ).selected = true;
137   - }
138   - if( typeof objSet.selectedIndex == 'number' && tipo < 3 )
139   - {
140   - document.getElementById( 'f_ref_setor_0' ).selected = true;
141   - }
142   - document.formcadastro.action='';
143   - document.formcadastro.submit();
144   -}
145   -function meusdadosReload2( tipo )
  180 +/**
  181 + * @TODO Remover função, sem chamadas no i-Educar.
  182 + */
  183 +function meusdadosReload(tipo)
146 184 {
147   - document.getElementById( 'reloading' ).value = 1;
148   - objSec = document.getElementById( 'f_ref_sec' );
149   - objDep = document.getElementById( 'f_ref_dept' );
150   - objSet = document.getElementById( 'f_ref_setor' );
151   - if( typeof objDep.selectedIndex == 'number' && tipo < 2 )
152   - {
153   - document.getElementById( 'f_ref_dept_0' ).selected = true;
154   - }
155   - if( typeof objSet.selectedIndex == 'number' && tipo < 3 )
156   - {
157   - document.getElementById( 'f_ref_setor_0' ).selected = true;
158   - }
159   - document.formcadastro.action='';
160   - document.getElementById('TipoAcao').value='';
161   - document.formcadastro.submit();
  185 + document.getElementById('reloading').value = 1;
  186 + objSec = document.getElementById('f_ref_sec');
  187 + objDep = document.getElementById('f_ref_dept');
  188 + objSet = document.getElementById('f_ref_setor');
  189 +
  190 + if (typeof objDep.selectedIndex == 'number' && tipo < 2) {
  191 + document.getElementById('f_ref_dept_0').selected = true;
  192 + }
  193 +
  194 + if (typeof objSet.selectedIndex == 'number' && tipo < 3) {
  195 + document.getElementById('f_ref_setor_0').selected = true;
  196 + }
  197 +
  198 + document.formcadastro.action = '';
  199 + document.formcadastro.submit();
162 200 }
163 201  
164   -function excluirSumit(id, nome_campo )
  202 +/**
  203 + * @TODO Remover função, sem chamadas no i-Educar.
  204 + */
  205 +function meusdadosReload2(tipo)
165 206 {
166   - if(id && nome_campo)
167   - {
168   - document.getElementById(nome_campo).value = id;
169   - }
170   - if( id == 0)
171   - {
172   - document.getElementById(nome_campo).value = "0";
173   - }
174   -
175   - document.getElementById('tipoacao').value = "";
176   - document.getElementById('formcadastro').submit();
  207 + document.getElementById('reloading').value = 1;
177 208  
178   -}
  209 + objSec = document.getElementById('f_ref_sec');
  210 + objDep = document.getElementById('f_ref_dept');
  211 + objSet = document.getElementById('f_ref_setor');
  212 +
  213 + if (typeof objDep.selectedIndex == 'number' && tipo < 2) {
  214 + document.getElementById('f_ref_dept_0').selected = true;
  215 + }
179 216  
  217 + if (typeof objSet.selectedIndex == 'number' && tipo < 3) {
  218 + document.getElementById('f_ref_setor_0').selected = true;
  219 + }
  220 +
  221 + document.formcadastro.action = '';
  222 + document.getElementById('TipoAcao').value = '';
  223 + document.formcadastro.submit();
  224 +}
180 225  
181   -function excluirSumitAcervo(id, nome_campo, descricao )
  226 +/**
  227 + * @TODO Remover função após remover todos os arquivos legados não utilizados
  228 + * presentes no i-Educar. Ver: $ egrep -rn 'excluirSumit[ ]{0,3}\(' intranet/
  229 + */
  230 +function excluirSumit(id, nome_campo)
182 231 {
183   - if(id && nome_campo)
184   - {
185   - document.getElementById(nome_campo).value = id;
186   - }
187   - if( id == 0)
188   - {
189   - document.getElementById(nome_campo).value = "0";
190   - }
191   - document.getElementById('descricao').value = descricao;
192   - document.getElementById('tipoacao').value = "";
193   - document.getElementById('formcadastro').submit();
  232 + if (id && nome_campo) {
  233 + document.getElementById(nome_campo).value = id;
  234 + }
  235 +
  236 + if (id == 0) {
  237 + document.getElementById(nome_campo).value = '0';
  238 + }
  239 +
  240 + document.getElementById('tipoacao').value = '';
  241 + document.getElementById('formcadastro').submit();
194 242 }
195 243  
  244 +/**
  245 + * @TODO Remover função, sem chamadas no i-Educar.
  246 + */
  247 +function excluirSumitAcervo(id, nome_campo, descricao)
  248 +{
  249 + if (id && nome_campo) {
  250 + document.getElementById(nome_campo).value = id;
  251 + }
196 252  
  253 + if (id == 0) {
  254 + document.getElementById(nome_campo).value = '0';
  255 + }
197 256  
  257 + document.getElementById('descricao').value = descricao;
  258 + document.getElementById('tipoacao').value = '';
  259 + document.getElementById('formcadastro').submit();
  260 +}
198 261  
  262 +/**
  263 + * @TODO Remover função, sem chamadas no i-Educar.
  264 + */
199 265 function exclui_idpes(idpes, campo)
200 266 {
201   - document.getElementById(campo).value = idpes;
202   -
203   - document.getElementById("numero2").value = document.getElementById("numero").value;
204   - document.getElementById("complemento2").value = document.getElementById("complemento").value;
205   - document.getElementById("letra2").value = document.getElementById("letra").value;
206   - document.getElementById("logradouro2").value = document.getElementById("logradouro").value;
207   - document.getElementById("bairro2").value = document.getElementById("bairro").value;
208   - document.getElementById("cidade2").value = document.getElementById("cidade").value;
209   - document.getElementById("sigla_uf2").value = document.getElementById("sigla_uf").value;
210   - document.getElementById("idtlog2").value = document.getElementById("idtlog").value;
211   - document.getElementById("apartamento2").value = document.getElementById("apartamento").value;
212   - document.getElementById("bloco2").value = document.getElementById("bloco").value;
213   - document.getElementById("andar2").value = document.getElementById("andar").value;
214   -
215   - document.getElementById("cep").value = document.getElementById("cep_").value;
216   - document.getElementById("tipoacao").value = "";
217   - document.getElementById("formcadastro").submit();
  267 + document.getElementById(campo).value = idpes;
  268 +
  269 + document.getElementById('numero2').value = document.getElementById('numero').value;
  270 + document.getElementById('complemento2').value = document.getElementById('complemento').value;
  271 + document.getElementById('letra2').value = document.getElementById('letra').value;
  272 + document.getElementById('logradouro2').value = document.getElementById('logradouro').value;
  273 + document.getElementById('bairro2').value = document.getElementById('bairro').value;
  274 + document.getElementById('cidade2').value = document.getElementById('cidade').value;
  275 + document.getElementById('sigla_uf2').value = document.getElementById('sigla_uf').value;
  276 + document.getElementById('idtlog2').value = document.getElementById('idtlog').value;
  277 + document.getElementById('apartamento2').value = document.getElementById('apartamento').value;
  278 + document.getElementById('bloco2').value = document.getElementById('bloco').value;
  279 + document.getElementById('andar2').value = document.getElementById('andar').value;
  280 + document.getElementById('cep').value = document.getElementById('cep_').value;
  281 + document.getElementById('tipoacao').value = '';
  282 +
  283 + document.getElementById('formcadastro').submit();
218 284 }
219 285  
220 286  
221   -// scripts tirados do clsCampos.inc.php
  287 +// Scripts originários de clsCampos.inc.php
222 288  
  289 +/**
  290 + * @TODO Remover função após remover trechos de código para campos 'latitude'
  291 + * e 'longitude' de clsCampos.inc.php.
  292 + * Ver: $ egrep -rn 'colocamenos[ ]{0,3}\(' intranet/
  293 + */
223 294 function colocaMenos(campo)
224 295 {
225   - if(campo.value.indexOf("0") != -1 || campo.value.indexOf("1") != -1 ||campo.value.indexOf("2") != -1 || campo.value.indexOf("3") != -1 ||campo.value.indexOf("4") != -1 || campo.value.indexOf("5") != -1 ||campo.value.indexOf("6") != -1 || campo.value.indexOf("7") != -1 ||campo.value.indexOf("8") != -1 || campo.value.indexOf("9") != -1 )
226   - {
227   - if(campo.value.indexOf("-") == -1)
228   - campo.value = '-' + campo.value;
229   - }
230   - return false;
  296 + if (campo.value.indexOf('0') != -1 || campo.value.indexOf('1') != -1 ||
  297 + campo.value.indexOf('2') != -1 || campo.value.indexOf('3') != -1 ||
  298 + campo.value.indexOf('4') != -1 || campo.value.indexOf('5') != -1 ||
  299 + campo.value.indexOf('6') != -1 || campo.value.indexOf('7') != -1 ||
  300 + campo.value.indexOf('8') != -1 || campo.value.indexOf('9') != -1
  301 + ) {
  302 + if (campo.value.indexOf('-') == -1) {
  303 + campo.value = '-' + campo.value;
  304 + }
  305 + }
  306 +
  307 + return false;
231 308 }
232 309  
233 310 function formataData(campo, e)
234 311 {
235   - if( typeof window.event != "undefined")
236   - {
237   - if (window.event.keyCode != 47)
238   - {
239   - if ((campo.value.length == 2) || (campo.value.length == 5))
240   - {
241   - campo.value += '/';
242   - }
243   - }
244   - }else
245   - {
246   - if (e.which != 47 && e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 && e.which != 13 && e.which != 0 )
247   - {
248   - if ((campo.value.length == 2) || (campo.value.length == 5))
249   - {
250   - campo.value += '/';
251   - }
252   - }
253   - }
  312 + if (typeof window.event != 'undefined') {
  313 + if (window.event.keyCode != 47) {
  314 + if ((campo.value.length == 2) || (campo.value.length == 5)) {
  315 + campo.value += '/';
  316 + }
  317 + }
  318 + }
  319 + else {
  320 + if (
  321 + e.which != 47 && e.which != 45 && e.which != 46 && e.which != 8 &&
  322 + e.which != 32 && e.which != 13 && e.which != 0
  323 + ) {
  324 + if ((campo.value.length == 2) || (campo.value.length == 5)) {
  325 + campo.value += '/';
  326 + }
  327 + }
  328 + }
254 329 }
255 330  
256 331 function formataHora(campo, e)
257 332 {
258   - if( typeof window.event != "undefined" )
259   - {
260   - if (window.event.keyCode != 58)
261   - {
262   - if ((campo.value.length == 2))
263   - {
264   - campo.value += ':';
265   - }
266   - }
267   -
268   - }else
269   - {
270   - if (e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 && e.which != 13 && e.which != 0 )
271   - {
272   - if ((campo.value.length == 2))
273   - {
274   - campo.value += ':';
275   - }
276   - }
277   - }
  333 + if (typeof window.event != 'undefined') {
  334 + if (window.event.keyCode != 58) {
  335 + if ((campo.value.length == 2)) {
  336 + campo.value += ':';
  337 + }
  338 + }
  339 + }
  340 + else {
  341 + if (
  342 + e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 &&
  343 + e.which != 13 && e.which != 0
  344 + ) {
  345 + if ((campo.value.length == 2)) {
  346 + campo.value += ':';
  347 + }
  348 + }
  349 + }
278 350 }
279 351  
280 352 function formataCEP(campo, e)
281 353 {
282   - if( typeof window.event != "undefined" )
283   - {
284   - if (window.event.keyCode != 45)
285   - if (campo.value.length == 5)
286   - campo.value += '-';
287   - }
288   - else
289   - {
290   - if (e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 && e.which != 13 && e.which != 0 )
291   - if (campo.value.length == 5)
292   - campo.value += '-';
293   - }
  354 + if (typeof window.event != 'undefined') {
  355 + if (window.event.keyCode != 45) {
  356 + if (campo.value.length == 5) {
  357 + campo.value += '-';
  358 + }
  359 + }
  360 + }
  361 + else {
  362 + if (
  363 + e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 &&
  364 + e.which != 13 && e.which != 0
  365 + ) {
  366 + if (campo.value.length == 5) {
  367 + campo.value += '-';
  368 + }
  369 + }
  370 + }
294 371 }
295 372  
296 373 function formataCPF(campo, e)
297 374 {
298   - if( typeof window.event != "undefined" )
299   - {
300   - if (window.event.keyCode != 46)
301   - if ((campo.value.length == 3) || (campo.value.length == 7))
302   - campo.value += '.';
303   - if (window.event.keyCode != 45)
304   - if (campo.value.length == 11)
305   - campo.value += '-';
306   - }
307   - else
308   - {
309   - if (e.which != 8)
310   - {
311   - if (e.which != 46)
312   - if ((campo.value.length == 3) || (campo.value.length == 7))
313   - campo.value += '.';
314   - if (e.which != 45)
315   - if (campo.value.length == 11)
316   - campo.value += '-';
317   - }
318   -
319   - }
  375 + if (typeof window.event != 'undefined') {
  376 + if (window.event.keyCode != 46) {
  377 + if ((campo.value.length == 3) || (campo.value.length == 7)) {
  378 + campo.value += '.';
  379 + }
  380 + }
  381 +
  382 + if (window.event.keyCode != 45) {
  383 + if (campo.value.length == 11) {
  384 + campo.value += '-';
  385 + }
  386 + }
  387 + }
  388 + else {
  389 + if (e.which != 8) {
  390 + if (e.which != 46) {
  391 + if ((campo.value.length == 3) || (campo.value.length == 7)) {
  392 + campo.value += '.';
  393 + }
  394 + }
  395 +
  396 + if (e.which != 45) {
  397 + if (campo.value.length == 11) {
  398 + campo.value += '-';
  399 + }
  400 + }
  401 + }
  402 + }
320 403 }
321 404  
322 405 function formataIdFederal(campo, e)
323 406 {
324   - if(campo.value.length > 13)
325   - {
326   - if( typeof window.event != "undefined" )
327   - {
328   - if (window.event.keyCode != 45 && window.event.keyCode != 46 && window.event.keyCode != 8 /*&& window.event.keyCode != 0*/ )
329   - {
330   - var str = campo.value;
331   - str = str.replace('.','');
332   - str = str.replace('.','');
333   - str = str.replace('-','');
334   - str = str.replace('/','');
335   - temp = str.substr(0,2);
336   - if(temp.length == 2)
337   - temp += '.';
338   - temp += str.substr(2,3);
339   - if(temp.length == 6)
340   - temp += '.';
341   - temp += str.substr(5,3);
342   - if(temp.length == 10)
343   - temp += '/';
344   - temp += str.substr(8,4);
345   - if(temp.length == 15)
346   - temp += '-';
347   - temp += str.substr(12,2);
348   - campo.value= temp;
349   - }
350   -
351   - }else
352   - {
353   - if (e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 && e.which != 13 /*&& e.which != 0*/ )
354   - {
355   - var str = campo.value;
356   - str = str.replace('.','');
357   - str = str.replace('.','');
358   - str = str.replace('-','');
359   - str = str.replace('/','');
360   -
361   - temp = str.substr(0,2);
362   - if(temp.length == 2)
363   - temp += '.';
364   - temp += str.substr(2,3);
365   - if(temp.length == 6)
366   - temp += '.';
367   - temp += str.substr(5,3);
368   - if(temp.length == 10)
369   - temp += '/';
370   - temp += str.substr(8,4);
371   - if(temp.length == 15)
372   - temp += '-';
373   - temp += str.substr(12,2);
374   - campo.value= temp;
375   - }
376   -
377   - }
378   - }else
379   - {
380   - if( typeof window.event != "undefined" )
381   - {
382   - if (window.event.keyCode != 45 && window.event.keyCode != 46 && window.event.keyCode != 8 /*&& window.event.keyCode != 0*/ )
383   - {
384   - var str = campo.value;
385   - str = str.replace('.','');
386   - str = str.replace('.','');
387   - str = str.replace('/','');
388   - str = str.replace('-','');
389   -
390   - temp = str.substr(0,3) ;
391   - if(temp.length == 3)
392   - temp += '.';
393   - temp += str.substr(3,3);
394   - if(temp.length == 7)
395   - temp += '.';
396   - temp += str.substr(6,3);
397   - if(temp.length == 11)
398   - temp += '-';
399   - temp += str.substr(9,2);
400   - campo.value= temp;
401   - }
402   - }else
403   - {
404   - if (e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 && e.which != 13 /*&& e.which != 0*/ )
405   - {
406   - var str = campo.value;
407   - str = str.replace('.','');
408   - str = str.replace('.','');
409   - str = str.replace('/','');
410   - str = str.replace('-','');
411   - temp = str.substr(0,3) ;
412   - if(temp.length == 3)
413   - temp += '.';
414   - temp += str.substr(3,3);
415   - if(temp.length == 7)
416   - temp += '.';
417   - temp += str.substr(6,3);
418   - if(temp.length == 11)
419   - temp += '-';
420   - temp += str.substr(9,2);
421   - campo.value= temp;
422   - }
423   - }
424   - }
  407 + if (campo.value.length > 13) {
  408 + if (typeof window.event != 'undefined') {
  409 + if (
  410 + window.event.keyCode != 45 && window.event.keyCode != 46 &&
  411 + window.event.keyCode != 8
  412 + ) {
  413 + var str = campo.value;
  414 + str = str.replace('.', '');
  415 + str = str.replace('.', '');
  416 + str = str.replace('-', '');
  417 + str = str.replace('/', '');
  418 +
  419 + temp = str.substr(0, 2);
  420 + if (temp.length == 2) {
  421 + temp += '.';
  422 + }
  423 +
  424 + temp += str.substr(2, 3);
  425 +
  426 + if (temp.length == 6) {
  427 + temp += '.';
  428 + }
  429 +
  430 + temp += str.substr(5, 3);
  431 +
  432 + if (temp.length == 10) {
  433 + temp += '/';
  434 + }
  435 +
  436 + temp += str.substr(8, 4);
  437 +
  438 + if (temp.length == 15) {
  439 + temp += '-';
  440 + }
  441 +
  442 + temp += str.substr(12, 2);
  443 + campo.value= temp;
  444 + }
  445 + }
  446 + else {
  447 + if (
  448 + e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 &&
  449 + e.which != 13
  450 + ) {
  451 + var str = campo.value;
  452 + str = str.replace('.', '');
  453 + str = str.replace('.', '');
  454 + str = str.replace('-', '');
  455 + str = str.replace('/', '');
  456 +
  457 + temp = str.substr(0, 2);
  458 +
  459 + if (temp.length == 2) {
  460 + temp += '.';
  461 + }
  462 +
  463 + temp += str.substr(2, 3);
  464 +
  465 + if (temp.length == 6) {
  466 + temp += '.';
  467 + }
  468 +
  469 + temp += str.substr(5, 3);
  470 +
  471 + if (temp.length == 10) {
  472 + temp += '/';
  473 + }
  474 +
  475 + temp += str.substr(8, 4);
  476 +
  477 + if (temp.length == 15) {
  478 + temp += '-';
  479 + }
  480 +
  481 + temp += str.substr(12, 2);
  482 + campo.value= temp;
  483 + }
  484 + }
  485 + }
  486 + else {
  487 + if (typeof window.event != 'undefined') {
  488 + if (
  489 + window.event.keyCode != 45 && window.event.keyCode != 46 &&
  490 + window.event.keyCode != 8
  491 + ) {
  492 + var str = campo.value;
  493 + str = str.replace('.', '');
  494 + str = str.replace('.', '');
  495 + str = str.replace('/', '');
  496 + str = str.replace('-', '');
  497 +
  498 + temp = str.substr(0, 3);
  499 +
  500 + if (temp.length == 3) {
  501 + temp += '.';
  502 + }
  503 +
  504 + temp += str.substr(3,3);
  505 +
  506 + if (temp.length == 7) {
  507 + temp += '.';
  508 + }
  509 +
  510 + temp += str.substr(6,3);
  511 +
  512 + if (temp.length == 11) {
  513 + temp += '-';
  514 + }
  515 +
  516 + temp += str.substr(9,2);
  517 + campo.value= temp;
  518 + }
  519 + }
  520 + else {
  521 + if (
  522 + e.which != 45 && e.which != 46 && e.which != 8 && e.which != 32 &&
  523 + e.which != 13
  524 + ) {
  525 + var str = campo.value;
  526 + str = str.replace('.', '');
  527 + str = str.replace('.', '');
  528 + str = str.replace('/', '');
  529 + str = str.replace('-', '');
  530 +
  531 + temp = str.substr(0, 3);
  532 +
  533 + if (temp.length == 3) {
  534 + temp += '.';
  535 + }
  536 +
  537 + temp += str.substr(3, 3);
  538 +
  539 + if (temp.length == 7) {
  540 + temp += '.';
  541 + }
  542 +
  543 + temp += str.substr(6, 3);
  544 +
  545 + if (temp.length == 11) {
  546 + temp += '-';
  547 + }
  548 +
  549 + temp += str.substr(9, 2);
  550 + campo.value= temp;
  551 + }
  552 + }
  553 + }
425 554 }
426 555  
427 556 function formataMonetario(campo, e)
428 557 {
429   - if( typeof window.event != "undefined" )
430   - {
431   - if (window.event.keyCode != 44 && window.event.keyCode != 46 )
432   - {
433   - var valor = campo.value;
434   -
435   - valor = valor.replace(",","");
436   - valor = valor.replace(" ","");
437   - valor = valor.split(".").join("");
438   - valor = valor.split(",").join("");
439   -
440   - for(var i=0; i<valor.length; i++)
441   - {
442   -
443   - if(valor.substr(i,1) != 0)
444   - {
445   - valor = valor.substr(i);
446   -
447   -
448   - break;
449   - }
450   - }
451   - if (valor.length < 3 )
452   - {
453   - if(valor.length == 2 && valor != 00)
454   - {
455   - campo.value = "0,"+valor;
456   - }else
457   - {
458   - campo.value = "";
459   - }
460   - if (valor.length == 1 )
461   - campo.value = "0,0"+valor;
462   - if(valor.length == 0)
463   - {
464   - campo.value = "";
465   - }
466   - }else
467   - {
468   - var centavos = valor.substr(valor.length-2,2);
469   - var resto = valor.substr(0,valor.length-2);
470   - valor = "";
471   - var count = 0;
472   - for( var i=resto.length; i>0; i--)
473   - {
474   - count++;
475   - if(count % 3 == 1 && count >1)
476   - {
477   - valor = resto.substr(i-1,1)+"."+valor;
478   - }else
479   - {
480   - valor = resto.substr(i-1,1)+valor;
481   - }
482   -
483   - }
484   - campo.value = valor+","+centavos;
485   - }
486   -
487   - }
488   - }
489   - else
490   - {
491   -
492   - if (e.which != 46 && e.which != 44 )
493   - {
494   - var valor = campo.value;
495   -
496   - valor = valor.replace(",","");
497   - valor = valor.replace(" ","");
498   - valor = valor.split(".").join("");
499   - valor = valor.split(",").join("");
500   -
501   - for(var i=0; i<valor.length; i++)
502   - {
503   -
504   - if(valor[i] != 0)
505   - {
506   - valor = valor.substr(i);
507   - break;
508   - }
509   - }
510   - if (valor.length < 3 )
511   - {
512   - if(valor.length == 2 && valor != 00)
513   - {
514   - campo.value = "0,"+valor;
515   - }else
516   - {
517   - campo.value = "";
518   - }
519   -
520   - if (valor.length == 1 )
521   - campo.value = "0,0"+valor;
522   - if(valor.length == 0)
523   - {
524   - campo.value ="";
525   - }
526   - }else
527   - {
528   - var centavos = valor.substr(valor.length-2,2);
529   - var resto = valor.substr(0,valor.length-2);
530   - valor = "";
531   - var count = 0;
532   - for( var i=resto.length; i>0; i--)
533   - {
534   - count++;
535   - if(count % 3 == 1 && count >1)
536   - {
537   - valor = resto.substr(i-1,1)+"."+valor;
538   - }else
539   - {
540   - valor = resto.substr(i-1,1)+valor;
541   - }
542   -
543   - }
544   - campo.value = valor+","+centavos;
545   - }
546   -
547   - }
548   - }
549   -
550   -
  558 + if (typeof window.event != 'undefined') {
  559 + if (window.event.keyCode != 44 && window.event.keyCode != 46) {
  560 + var valor = campo.value;
  561 +
  562 + valor = valor.replace(',', '');
  563 + valor = valor.replace(' ', '');
  564 + valor = valor.split('.').join('');
  565 + valor = valor.split(',').join('');
  566 +
  567 + for (var i=0; i<valor.length; i++) {
  568 + if (valor.substr(i,1) != 0) {
  569 + valor = valor.substr(i);
  570 + break;
  571 + }
  572 + }
  573 +
  574 + if (valor.length < 3) {
  575 + if (valor.length == 2 && valor != 00) {
  576 + campo.value = '0,' + valor;
  577 + }
  578 + else {
  579 + campo.value = '';
  580 + }
  581 +
  582 + if (valor.length == 1) {
  583 + campo.value = '0,0' + valor;
  584 + }
  585 +
  586 + if (valor.length == 0) {
  587 + campo.value = '';
  588 + }
  589 + }
  590 + else {
  591 + var centavos = valor.substr(valor.length - 2, 2);
  592 + var resto = valor.substr(0, valor.length - 2);
  593 +
  594 + valor = '';
  595 +
  596 + var count = 0;
  597 +
  598 + for (var i = resto.length; i > 0; i--) {
  599 + count++;
  600 +
  601 + if (count % 3 == 1 && count >1) {
  602 + valor = resto.substr(i - 1, 1) + '.' + valor;
  603 + }
  604 + else {
  605 + valor = resto.substr(i - 1, 1) + valor;
  606 + }
  607 + }
  608 +
  609 + campo.value = valor + ',' + centavos;
  610 + }
  611 + }
  612 + }
  613 + else {
  614 + if (e.which != 46 && e.which != 44 ) {
  615 + var valor = campo.value;
  616 +
  617 + valor = valor.replace(',', '');
  618 + valor = valor.replace(' ', '');
  619 + valor = valor.split('.').join('');
  620 + valor = valor.split(',').join('');
  621 +
  622 + for (var i = 0; i < valor.length; i++) {
  623 + if (valor[i] != 0) {
  624 + valor = valor.substr(i);
  625 + break;
  626 + }
  627 + }
  628 +
  629 + if (valor.length < 3) {
  630 + if (valor.length == 2 && valor != 00) {
  631 + campo.value = '0,' + valor;
  632 + }
  633 + else {
  634 + campo.value = '';
  635 + }
  636 +
  637 + if (valor.length == 1) {
  638 + campo.value = '0,0' + valor;
  639 + }
  640 +
  641 + if (valor.length == 0) {
  642 + campo.value = '';
  643 + }
  644 + }
  645 + else {
  646 + var centavos = valor.substr(valor.length - 2, 2);
  647 + var resto = valor.substr(0, valor.length - 2);
  648 +
  649 + valor = '';
  650 +
  651 + var count = 0;
  652 +
  653 + for (var i = resto.length; i > 0; i--) {
  654 + count++;
  655 +
  656 + if (count % 3 == 1 && count >1) {
  657 + valor = resto.substr(i - 1, 1) + '.' + valor;
  658 + }
  659 + else {
  660 + valor = resto.substr(i - 1, 1) + valor;
  661 + }
  662 + }
  663 +
  664 + campo.value = valor + ',' + centavos;
  665 + }
  666 + }
  667 + }
551 668 }
552 669  
553 670 function formataCNPJ(campo, e)
554 671 {
555   - if( typeof window.event != "undefined" )
556   - {
557   - if (window.event.keyCode != 46)
558   - if ((campo.value.length == 2) || (campo.value.length == 6))
559   - campo.value += '.';
560   - if (window.event.keyCode != 47)
561   - if (campo.value.length == 10)
562   - campo.value += '/';
563   - if (window.event.keyCode != 45)
564   - if (campo.value.length == 15)
565   - campo.value += '-';
566   - }
567   - else
568   - {
569   - if (e.which != 8)
570   - {
571   - if (e.which != 46)
572   - {
573   - if ((campo.value.length == 2) || (campo.value.length == 6))
574   - {
575   - campo.value += '.';
576   - }
577   - }
578   - if (e.which != 47)
579   - {
580   - if (campo.value.length == 10)
581   - {
582   - campo.value += '/';
583   - }
584   - }
585   - if (e.which != 45)
586   - {
587   - if (campo.value.length == 15)
588   - {
589   - campo.value += '-';
590   - }
591   - }
592   - }
593   - }
  672 + if (typeof window.event != 'undefined') {
  673 + if (window.event.keyCode != 46) {
  674 + if ((campo.value.length == 2) || (campo.value.length == 6)) {
  675 + campo.value += '.';
  676 + }
  677 + }
  678 +
  679 + if (window.event.keyCode != 47) {
  680 + if (campo.value.length == 10) {
  681 + campo.value += '/';
  682 + }
  683 + }
  684 +
  685 + if (window.event.keyCode != 45) {
  686 + if (campo.value.length == 15) {
  687 + campo.value += '-';
  688 + }
  689 + }
  690 + }
  691 + else {
  692 + if (e.which != 8) {
  693 + if (e.which != 46) {
  694 + if ((campo.value.length == 2) || (campo.value.length == 6)) {
  695 + campo.value += '.';
  696 + }
  697 + }
  698 +
  699 + if (e.which != 47) {
  700 + if (campo.value.length == 10) {
  701 + campo.value += '/';
  702 + }
  703 + }
  704 +
  705 + if (e.which != 45) {
  706 + if (campo.value.length == 15) {
  707 + campo.value += '-';
  708 + }
  709 + }
  710 + }
  711 + }
594 712 }
595 713  
  714 +/**
  715 + * @TODO Remover função após remover trechos de código para campos 'fone' de
  716 + * clsCampos.inc.php. Não existem chamadas para campoFone().
  717 + * Ver: $ egrep -rn 'formataFone[ ]{0,3}\(' intranet/
  718 + */
596 719 function formataFone(campo, e)
597 720 {
598   - if( typeof window.event != "undefined" )
599   - {
600   - if (window.event.keyCode != 40 && (campo.value.length == 0))
601   - campo.value += '(';
602   - if (window.event.keyCode != 41 && (campo.value.length == 3))
603   - campo.value += ')';
604   - if (window.event.keyCode != 45 && campo.value.length == 8 && campo.value.substr(7,1) != '-' )
605   - campo.value += '-';
606   - }else
607   - {
608   - if (e.which != 32 && e.which != 13 && e.which != 8 )
609   - {
610   - if(e.which != 40 && (campo.value.length == 1))
611   - campo.value = '(' + campo.value;
612   - if (e.which != 41 && (campo.value.length == 4))
613   - campo.value = campo.value.substr(0,3)+ ')' + campo.value.substr(3,1);
614   - if (e.which != 45 && campo.value.length == 8 && campo.value.substr(7,1) != '-' )
615   - campo.value += '-';
616   - }else
617   - {
618   - campo.value = campo.value.substr(0, campo.value.length-1);
619   - }
620   - }
621   -
  721 + if (typeof window.event != 'undefined') {
  722 + if (window.event.keyCode != 40 && (campo.value.length == 0)) {
  723 + campo.value += '(';
  724 + }
  725 +
  726 + if (window.event.keyCode != 41 && (campo.value.length == 3)) {
  727 + campo.value += ')';
  728 + }
  729 +
  730 + if (
  731 + window.event.keyCode != 45 && campo.value.length == 8 &&
  732 + campo.value.substr(7, 1) != '-'
  733 + ) {
  734 + campo.value += '-';
  735 + }
  736 + }
  737 + else {
  738 + if (e.which != 32 && e.which != 13 && e.which != 8) {
  739 + if (e.which != 40 && (campo.value.length == 1)) {
  740 + campo.value = '(' + campo.value;
  741 + }
  742 +
  743 + if (e.which != 41 && (campo.value.length == 4)) {
  744 + campo.value = campo.value.substr(0, 3) + ')' + campo.value.substr(3, 1);
  745 + }
  746 +
  747 + if (e.which != 45 && campo.value.length == 8 && campo.value.substr(7, 1) != '-') {
  748 + campo.value += '-';
  749 + }
  750 + }
  751 + else {
  752 + campo.value = campo.value.substr(0, campo.value.length - 1);
  753 + }
  754 + }
622 755 }
623 756  
  757 +/**
  758 + * @TODO Remover função. Aparentemente nunca é chamada, a única página que chama
  759 + * clsCampos::campoTextoPesquisa() (intranet/funcionario_cad.php) não entra
  760 + * no trecho de código que gera o output HTML para esta função.
  761 + */
624 762 function pesquisa_valores_f(caminho, campo, flag, pag_cadastro)
625 763 {
626   - jar = window.open(caminho+'?campo='+campo+'&flag='+flag+'&pag_cadastro='+pag_cadastro, 'JANELAPESQUISA', 'width=800, height=300, scrollbars=yes' );
627   - jar.focus();
  764 + jar = window.open(caminho + '?campo=' + campo + '&flag=' + flag + '&pag_cadastro=' +
  765 + pag_cadastro, 'JANELAPESQUISA', 'width=800, height=300, scrollbars=yes');
  766 +
  767 + jar.focus();
628 768 }
629 769  
630 770 function pesquisa_valores_popless(caminho, campo)
631 771 {
632   - new_id = DOM_divs.length;
633   - div = 'div_dinamico_' + new_id;
634   - if ( caminho.indexOf( '?' ) == -1 )
635   - showExpansivel( 500, 500, '<iframe src="' + caminho + '?campo=' + campo + '&div=' + div + '&popless=1" frameborder="0" height="100%" width="500" marginheight="0" marginwidth="0" name="temp_win_popless"></iframe>', 'Pesquisa de valores' );
636   - else
637   - showExpansivel( 500, 500, '<iframe src="' + caminho + '&campo=' + campo + '&div=' + div + '&popless=1" frameborder="0" height="100%" width="500" marginheight="0" marginwidth="0" name="temp_win_popless"></iframe>', 'Pesquisa de valores' );
  772 + new_id = DOM_divs.length;
  773 + div = 'div_dinamico_' + new_id;
  774 +
  775 + if (caminho.indexOf('?') == -1) {
  776 + showExpansivel(500, 500, '<iframe src="' + caminho + '?campo=' + campo + '&div=' + div + '&popless=1" frameborder="0" height="100%" width="500" marginheight="0" marginwidth="0" name="temp_win_popless"></iframe>', 'Pesquisa de valores');
  777 + }
  778 + else {
  779 + showExpansivel(500, 500, '<iframe src="' + caminho + '&campo=' + campo + '&div=' + div + '&popless=1" frameborder="0" height="100%" width="500" marginheight="0" marginwidth="0" name="temp_win_popless"></iframe>', 'Pesquisa de valores');
  780 + }
638 781 }
639 782  
  783 +/**
  784 + * @TODO Remover função após remover trechos de código para campos
  785 + * 'listaativarpeso<select>' de clsCampos.inc.php. Não existem chamadas para
  786 + * campoFoneListaAtivarPeso<Select>().
  787 + * Ver: $ egrep -rn 'formataFone[ ]{0,3}\(' intranet/
  788 + */
640 789 function ativaCampo(campo)
641 790 {
642   - campo2 = document.getElementById(campo+'_lst');
643   - campo3 = document.getElementById(campo+'_val');
644   - if (campo2.disabled)
645   - {
646   - campo2.disabled=false;
647   - campo3.disabled=false;
648   - }
649   - else
650   - {
651   - campo2.disabled=true;
652   - campo3.disabled=true;
653   - }
654   -
  791 + campo2 = document.getElementById(campo + '_lst');
  792 + campo3 = document.getElementById(campo + '_val');
  793 +
  794 + if (campo2.disabled) {
  795 + campo2.disabled = false;
  796 + campo3.disabled = false;
  797 + }
  798 + else {
  799 + campo2.disabled = true;
  800 + campo3.disabled = true;
  801 + }
655 802 }
656 803  
657   -function trocaConteudo( obj, conteudo )
  804 +/**
  805 + * @TODO Remover função, sem chamadas no i-Educar.
  806 + */
  807 +function trocaConteudo(obj, conteudo)
658 808 {
659   - if( typeof obj.HTMLContent == "string" )
660   - {
661   - obj.HTMLContent = conteudo;
662   - }
663   - else
664   - {
665   - obj.innerHTML = conteudo;
666   - }
  809 + if (typeof obj.HTMLContent == 'string') {
  810 + obj.HTMLContent = conteudo;
  811 + }
  812 + else {
  813 + obj.innerHTML = conteudo;
  814 + }
667 815 }
668 816  
669   -function LimpaSelect( campos )
  817 +/**
  818 + * @TODO Remover função, sem chamadas no i-Educar.
  819 + */
  820 +function LimpaSelect(campos)
670 821 {
671   - for( i = 0; i < campos.length; i++ )
672   - {
673   - ObjSelect = document.getElementById(campos[i]);
674   - ObjSelect.options.length = 0;
675   - ObjSelect.options[ObjSelect.options.length] = new Option ( 'Selecione','0', true, true);
676   - }
  822 + for (i = 0; i < campos.length; i++) {
  823 + ObjSelect = document.getElementById(campos[i]);
  824 + ObjSelect.options.length = 0;
  825 + ObjSelect.options[ObjSelect.options.length] = new Option (
  826 + 'Selecione', '0', true, true
  827 + );
  828 + }
677 829 }
678 830  
  831 +/**
  832 + * @TODO Remover função, sem chamadas no i-Educar.
  833 + */
679 834 function coletaLocation(status, iptu)
680 835 {
681   - if (status == 2)
682   - {
683   - if (confirm("Passar cadastro Nº"+iptu+" para \"Isento?\""))
684   - {
685   - document.location = 'coleta_adesao_status.php?cod_adesao='+iptu+'&status='+status;
686   - }
687   - else
688   - {
689   - return false;
690   - }
691   - }
692   - if (status == 1)
693   - {
694   - if (confirm("Passar cadastro Nº"+iptu+" para \"Não Assiante?\""))
695   - {
696   - document.location = 'coleta_adesao_status.php?cod_adesao='+iptu+'&status='+status;
697   - }
698   - else
699   - {
700   - return false;
701   - }
702   - }
703   - if (status == 0)
704   - {
705   - if (confirm("Passar cadastro Nº"+iptu+" para \"Assiante\"?"))
706   - {
707   - document.location = 'coleta_adesao_status.php?cod_adesao='+iptu+'&status='+status;
708   - }
709   - else
710   - {
711   - return false;
712   - }
713   - }
  836 + if (status == 2) {
  837 + if (confirm('Passar cadastro Nº' + iptu + ' para "Isento?"')) {
  838 + document.location = 'coleta_adesao_status.php?cod_adesao=' + iptu + '&status=' + status;
  839 + }
  840 + else {
  841 + return false;
  842 + }
  843 + }
  844 +
  845 + if (status == 1) {
  846 + if (confirm('Passar cadastro Nº' + iptu + ' para "Não Assinante?"')) {
  847 + document.location = 'coleta_adesao_status.php?cod_adesao=' + iptu + '&status=' + status;
  848 + }
  849 + else {
  850 + return false;
  851 + }
  852 + }
  853 +
  854 + if (status == 0) {
  855 + if (confirm('Passar cadastro Nº' + iptu + ' para "Assiante"?')) {
  856 + document.location = 'coleta_adesao_status.php?cod_adesao=' + iptu + '&status=' + status;
  857 + }
  858 + else {
  859 + return false;
  860 + }
  861 + }
714 862 }
715 863  
716   -function MenuCarregaDados(key, ordem, menu_pai, menu, submenu, titulo, ico_menu, alvo, suprime_menu )
  864 +function MenuCarregaDados(key, ordem, menu_pai, menu, submenu, titulo, ico_menu,
  865 + alvo, suprime_menu)
717 866 {
718   - texto = titulo;
719   - if(submenu==0)
720   - {
721   - texto = "Selecione";
722   - }
723   - document.getElementById("ref_cod_menu_submenu").options[document.getElementById("ref_cod_menu_submenu").options.length] = new Option (texto, submenu, true, true);
724   - document.getElementById("ord_menu").value = ordem;
725   - document.getElementById("ref_cod_menu_pai").value = menu_pai;
726   - document.getElementById("ref_cod_menu").value = menu;
727   - document.getElementById("ref_cod_menu_submenu").value = submenu;
728   - document.getElementById("tt_menu").value = titulo;
729   - document.getElementById("img_banco_").value = ico_menu;
730   - document.getElementById("img_banco").value = ico_menu;
731   - document.getElementById("alvo").value = alvo;
732   - document.getElementById("suprime_menu").value = suprime_menu;
733   - document.getElementById("editar").value = key;
734   - document.getElementById("editando").value = '1';
735   - document.getElementById("id_deletar").value = key;
736   - //var submenu=document.getElementById("ref_cod_menu_submenu")
737   - // mylist.options[mylist.selectedIndex].text = titulo;
  867 + texto = titulo;
  868 +
  869 + if (submenu==0) {
  870 + texto = 'Selecione';
  871 + }
  872 +
  873 + submenuLen = document.getElementById('ref_cod_menu_submenu').options.length;
  874 +
  875 + document.getElementById('ref_cod_menu_submenu').options[submenuLen] =
  876 + new Option (texto, submenu, true, true);
  877 +
  878 + document.getElementById('ord_menu').value = ordem;
  879 + document.getElementById('ref_cod_menu_pai').value = menu_pai;
  880 + document.getElementById('ref_cod_menu').value = menu;
  881 + document.getElementById('ref_cod_menu_submenu').value = submenu;
  882 + document.getElementById('tt_menu').value = titulo;
  883 + document.getElementById('img_banco_').value = ico_menu;
  884 + document.getElementById('img_banco').value = ico_menu;
  885 + document.getElementById('alvo').value = alvo;
  886 + document.getElementById('suprime_menu').value = suprime_menu;
  887 + document.getElementById('editar').value = key;
  888 + document.getElementById('editando').value = '1';
  889 + document.getElementById('id_deletar').value = key;
738 890 }
  891 +
739 892 function MenuExcluiDado()
740 893 {
741   - document.getElementById("editando").value = '2';
742   - document.getElementById('tipoacao').value = "";
743   - document.getElementById('formcadastro').submit();
  894 + document.getElementById('editando').value = '2';
  895 + document.getElementById('tipoacao').value = '';
  896 + document.getElementById('formcadastro').submit();
744 897 }
745 898  
746   -function insertAtCursor(myField, myValue) {
747   - var ini = 0, fim=0, tam=0;
748   - var pos = arguments[2];
749   -
750   - //IE support
751   - if (document.selection) {
752   - myField.focus();
753   - sel = document.selection.createRange();
754   - sel.text = myValue;
755   - }
756   - //MOZILLA/NETSCAPE support
757   - else if (myField.selectionStart || myField.selectionStart == '0') {
758   - var startPos = myField.selectionStart;
759   - var endPos = myField.selectionEnd;
760   -
761   - ini = startPos;
762   - fim = endPos;
763   - tam = myValue.length;
764   -
765   - myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length);
766   - myField.selectionStart = pos ? ini+pos : ini+tam;
767   - myField.selectionEnd = pos? ini+pos : ini+tam;
768   - myField.focus();
769   - } else {
770   - myField.value += myValue;
771   - }
  899 +/**
  900 + * @TODO Remover função, sem chamadas no i-Educar.
  901 + */
  902 +function insertAtCursor(myField, myValue)
  903 +{
  904 + var ini = 0, fim = 0, tam = 0;
  905 + var pos = arguments[2];
  906 +
  907 + // IE support
  908 + if (document.selection) {
  909 + myField.focus();
  910 + sel = document.selection.createRange();
  911 + sel.text = myValue;
  912 + }
  913 +
  914 + // Mozilla/Netscape support
  915 + else if (myField.selectionStart || myField.selectionStart == '0') {
  916 + var startPos = myField.selectionStart;
  917 + var endPos = myField.selectionEnd;
  918 +
  919 + ini = startPos;
  920 + fim = endPos;
  921 + tam = myValue.length;
  922 +
  923 + myField.value = myField.value.substring(0, startPos) + myValue +
  924 + myField.value.substring(endPos, myField.value.length);
  925 +
  926 + myField.selectionStart = pos ? ini + pos : ini + tam;
  927 + myField.selectionEnd = pos ? ini + pos : ini + tam;
  928 +
  929 + myField.focus();
  930 + }
  931 + else {
  932 + myField.value += myValue;
  933 + }
772 934 }
773 935  
  936 +/**
  937 + * @TODO Remover função, sem chamadas no i-Educar.
  938 + */
774 939 function ouvidoria_set_campo(campo, valor, texto)
775 940 {
776   - obj = parent.document.getElementById( campo );
777   - novoIndice = obj.options.length;
778   - obj.options[novoIndice] = new Option( texto );
779   - opcao = obj.options[novoIndice];
780   - opcao.value = valor;
781   - opcao.selected = true;
782   - window.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));
783   - obj.onchange();
  941 + obj = parent.document.getElementById(campo);
  942 + novoIndice = obj.options.length;
  943 +
  944 + obj.options[novoIndice] = new Option(texto);
  945 +
  946 + opcao = obj.options[novoIndice];
  947 + opcao.value = valor;
  948 + opcao.selected = true;
  949 +
  950 + window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
  951 + obj.onchange();
784 952 }
785 953  
  954 +/**
  955 + * @TODO Remover função, sem chamadas no i-Educar.
  956 + */
786 957 function vistoria_set_campo(campo1, valor1, campo2, valor2, campo3, valor3, campo4, valor4, campo5, valor5)
787 958 {
788   - obj1 = parent.document.getElementById( campo1 );
789   - obj1.value = valor1;
  959 + obj1 = parent.document.getElementById(campo1);
  960 + obj1.value = valor1;
790 961  
791   - obj2 = parent.document.getElementById( campo2 );
792   - obj2.value = valor2;
  962 + obj2 = parent.document.getElementById(campo2);
  963 + obj2.value = valor2;
793 964  
794   - obj3 = parent.document.getElementById( campo3 + "_" );
795   - obj3.value = valor3;
  965 + obj3 = parent.document.getElementById(campo3 + '_');
  966 + obj3.value = valor3;
796 967  
797   - var cep_oculto = parent.document.getElementById( campo3 );
798   - cep_oculto.value = valor3.replace("-","");
  968 + var cep_oculto = parent.document.getElementById(campo3);
  969 + cep_oculto.value = valor3.replace('-', '');
799 970  
800   - obj4 = parent.document.getElementById( campo4 );
801   - obj4.value = valor4;
  971 + obj4 = parent.document.getElementById(campo4);
  972 + obj4.value = valor4;
802 973  
803   - obj5 = parent.document.getElementById( campo5 );
804   - obj5.value = valor5;
  974 + obj5 = parent.document.getElementById(campo5);
  975 + obj5.value = valor5;
805 976  
806   - window.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));
807   - //obj.onchange();
  977 + window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
808 978 }
809 979  
810   -//exibe ou esconde um campo da tela
811   -function setVisibility(f,visible){
812   - var field = typeof(f) == 'object' ? f : document.getElementById(f);
813   -
814   - var browser = navigator.appName;
815   - if(browser.indexOf("Netscape") == 0){
816   - //Netscape and Mozilla
817   - if(field)
818   - field.style.visibility = (visible == true)?'visible':'collapse';
819   - else
820   - f.style.visibility = (visible == true)?'visible':'collapse';
821   - }else{
822   - //internet explorer
823   - if(field)
824   - field.style.display = (visible == true)?'inline':'none';
825   - else{
826   - //alert('how');
827   - f.style.display = (visible == true)?'inline':'none';
828   - //f.style.visibility = (visible == true)?'inline':'none';
829   -
830   - }
831   - }
  980 +// Exibe ou esconde um campo da tela
  981 +function setVisibility(f, visible)
  982 +{
  983 + var field = typeof(f) == 'object' ? f : document.getElementById(f);
  984 +
  985 + var browser = navigator.appName;
  986 +
  987 + if (browser.indexOf("Netscape") == 0){
  988 + // Netscape e Mozilla
  989 + if (field) {
  990 + field.style.visibility = (visible == true) ? 'visible' : 'collapse';
  991 + }
  992 + else {
  993 + f.style.visibility = (visible == true) ? 'visible' : 'collapse';
  994 + }
  995 + }
  996 + else {
  997 + // IE
  998 + if (field) {
  999 + field.style.display = (visible == true) ? 'inline' : 'none';
  1000 + }
  1001 + else {
  1002 + f.style.display = (visible == true) ? 'inline': 'none';
  1003 + }
  1004 + }
832 1005 }
833 1006  
834   -//retorna true se o campo estiver visivel ou falso caso contrario
835   -function getVisibility(f){
836   - var field = document.getElementById(f);
837   - var browser = navigator.appName;
838   - field = field ? field : f;
839   - if(browser.indexOf("Netscape") == 0){
840   - //Netscape and Mozilla
841   - if(field.style.visibility == 'visible' || field.style.visibility == '')
842   - return true;
843   - else if (field.style.visibility == 'collapse')
844   - return false;
845   - }else{
846   - //internet explorer
847   - if(field.style.display == 'inline' || field.style.display == 'block' || field.style.display == '')
848   - return true;
849   - else if (field.style.display == 'none')
850   - return false;
851   - }
  1007 +// Retorna true se o campo estiver visivel
  1008 +function getVisibility(f)
  1009 +{
  1010 + var field = document.getElementById(f);
  1011 + var browser = navigator.appName;
  1012 +
  1013 + field = field ? field : f;
  1014 +
  1015 + if (browser.indexOf('Netscape') == 0){
  1016 + // Netscape e Mozilla
  1017 + if (field.style.visibility == 'visible' || field.style.visibility == '') {
  1018 + return true;
  1019 + }
  1020 + else if (field.style.visibility == 'collapse') {
  1021 + return false;
  1022 + }
  1023 + }
  1024 + else{
  1025 + // IE
  1026 + if (field.style.display == 'inline' || field.style.display == 'block' || field.style.display == '') {
  1027 + return true;
  1028 + }
  1029 + else if (field.style.display == 'none') {
  1030 + return false;
  1031 + }
  1032 + }
852 1033 }
853 1034  
854   -
855   -function cv_set_campo(campo1, valor1, campo2, valor2, campo3, valor3, campo4, valor4, campo5, valor5, campo6, valor6, campo7, valor7, campo8, valor8, campo9, valor9, campo10, valor10, campo11, valor11, campo12,campo13,valor13)
  1035 +function cv_set_campo(campo1, valor1, campo2, valor2, campo3, valor3, campo4,
  1036 + valor4, campo5, valor5, campo6, valor6, campo7, valor7, campo8, valor8, campo9,
  1037 + valor9, campo10, valor10, campo11, valor11, campo12, campo13, valor13)
856 1038 {
  1039 + obj1 = parent.document.getElementById(campo1);
  1040 + obj1.value = valor1;
  1041 + obj1.disabled = true;
857 1042  
  1043 + obj2 = parent.document.getElementById(campo2);
  1044 + obj2.value = valor2;
858 1045  
  1046 + obj3 = parent.document.getElementById(campo3);
  1047 + obj3.value = valor3;
859 1048  
860   - obj1 = parent.document.getElementById( campo1 );
861   - obj1.value = valor1;
862   - obj1.disabled = true;
863   -
864   - obj2 = parent.document.getElementById( campo2 );
865   - obj2.value = valor2;
  1049 + obj4 = parent.document.getElementById(campo4);
  1050 + obj4.value = valor4;
  1051 + obj4.disabled = true;
866 1052  
867   - //obj3 = parent.document.getElementById( campo3 + "_" );
  1053 + obj5 = parent.document.getElementById(campo5);
  1054 + obj5.value = valor5;
868 1055  
869   - obj3 = parent.document.getElementById( campo3 );
870   - obj3.value = valor3;
  1056 + obj6 = parent.document.getElementById(campo6);
  1057 + obj6.value = valor6;
871 1058  
872   - //var cep_oculto = parent.document.getElementById( campo3 );
873   - //cep_oculto.value = valor3.replace("-","");
  1059 + obj7 = parent.document.getElementById(campo7);
  1060 + obj7.value = valor7;
  1061 + obj7.disabled = true;
874 1062  
875   - obj4 = parent.document.getElementById( campo4 );
876   - obj4.value = valor4;
877   - obj4.disabled = true;
  1063 + obj8 = parent.document.getElementById(campo8);
  1064 + obj8.value = valor8;
878 1065  
879   - obj5 = parent.document.getElementById( campo5 );
880   - obj5.value = valor5;
  1066 + obj9 = parent.document.getElementById(campo9);
881 1067  
882   - obj6 = parent.document.getElementById( campo6 );
883   - obj6.value = valor6;
  1068 + if (obj9) {
  1069 + obj9.value = valor9;
  1070 + }
884 1071  
885   - obj7 = parent.document.getElementById( campo7 );
886   - obj7.value = valor7;
887   - obj7.disabled = true;
  1072 + obj10 = parent.document.getElementById(campo10);
  1073 + obj10.value = valor10;
  1074 + obj10.disabled = true;
888 1075  
889   - obj8 = parent.document.getElementById( campo8 );
890   - obj8.value = valor8;
  1076 + obj11 = parent.document.getElementById(campo11);
  1077 + obj11.value = valor11;
  1078 + obj11.disabled = true;
891 1079  
892   - obj9 = parent.document.getElementById( campo9 );
893   - if(obj9)
894   - obj9.value = valor9;
  1080 + obj12 = parent.document.getElementById(campo12);
  1081 + obj12.value = valor8;
  1082 + obj12.disabled = true;
895 1083  
896   - obj10 = parent.document.getElementById( campo10 );
897   - obj10.value = valor10;
898   - obj10.disabled = true;
  1084 + if (parent.document.getElementById(campo13)) {
  1085 + obj13 = parent.document.getElementById( campo13 );
  1086 + obj13.value = valor13;
  1087 + }
899 1088  
900   - obj11 = parent.document.getElementById( campo11 );
901   - obj11.value = valor11;
902   - obj11.disabled = true;
903   -
904   - obj12 = parent.document.getElementById( campo12 );
905   - obj12.value = valor8;
906   - obj12.disabled = true;
907   -
908   - if(parent.document.getElementById( campo13 )){
909   - obj13 = parent.document.getElementById( campo13 );
910   - obj13.value = valor13;
911   - //alert('d');
912   - //obj13.disabled = true;
913   - }
914   -
915   - window.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));
916   - //obj.onchange();
  1089 + window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
917 1090 }
918 1091  
919 1092 function cv_libera_campos(campo1, campo2, campo3, campo4, campo5, campo6, campo7)
920 1093 {
921   - window.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));
922   - parent.document.getElementById( campo1 ).disabled = false;
923   - parent.document.getElementById( campo1 ).value = "";
924   - parent.document.getElementById( campo2 ).disabled = false;
925   - parent.document.getElementById( campo2 ).value = false;
926   - parent.document.getElementById( campo3 ).disabled = false;
927   - parent.document.getElementById( campo3 ).value = "";
928   - parent.document.getElementById( campo4 ).disabled = false;
929   - parent.document.getElementById( campo4 ).value = "";
930   - parent.document.getElementById( campo5 ).disabled = false;
931   - parent.document.getElementById( campo5 ).value = "";
932   - parent.document.getElementById( campo6 ).disabled = false;
933   - parent.document.getElementById( campo6 ).value = "";
934   - if(parent.document.getElementById( campo7 ))
935   - {
936   - parent.document.getElementById( campo7 ).disabled = false;
937   - parent.document.getElementById( campo7 ).value = "1";
938   - }
  1094 + window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
  1095 +
  1096 + parent.document.getElementById(campo1).disabled = false;
  1097 + parent.document.getElementById(campo1).value = '';
  1098 + parent.document.getElementById(campo2).disabled = false;
  1099 + parent.document.getElementById(campo2).value = false;
  1100 + parent.document.getElementById(campo3).disabled = false;
  1101 + parent.document.getElementById(campo3).value = '';
  1102 + parent.document.getElementById(campo4).disabled = false;
  1103 + parent.document.getElementById(campo4).value = '';
  1104 + parent.document.getElementById(campo5).disabled = false;
  1105 + parent.document.getElementById(campo5).value = '';
  1106 + parent.document.getElementById(campo6).disabled = false;
  1107 + parent.document.getElementById(campo6).value = '';
  1108 +
  1109 + if (parent.document.getElementById(campo7)) {
  1110 + parent.document.getElementById(campo7).disabled = false;
  1111 + parent.document.getElementById(campo7).value = '1';
  1112 + }
939 1113 }
940 1114  
941   -
942   -function setCampoFoco(campo){
943   -
944   - document.getElementById(campo).focus();
945   -
  1115 +/**
  1116 + * @TODO Remover função, sem chamadas no i-Educar.
  1117 + */
  1118 +function setCampoFoco(campo)
  1119 +{
  1120 + document.getElementById(campo).focus();
946 1121 }
947 1122  
948   -
949   -/**
950   - Os parametros para campos do tipo texto devem ser "nome do campo", "valor do campo";
951   - Os parametros para campos do tipo select devem ser "nome do campo", "indice da opcao", "valor da opcao";
952   - Os parametros devem sempre seguir a ordem citada acima;
953   - O ultimo parametro pode ser utilizado para definir se vai existir submit ou nao, caso tenha, o ultimo parametro deve ser passado como "submit", caso contrario, não precisa passar nada;
954   -*/
955   -
956   -/*
957   -**funcao a ser executada antes de fechar a janela
958   -*/
  1123 +// Função a ser executada antes de fechar a janela.
959 1124 var exec = null;
  1125 +
960 1126 function set_campo_pesquisa()
961 1127 {
962   - var i = 0;
963   - var submit = false;
964   - while ( i < arguments.length ) {
965   - if ( typeof arguments[i] != "undefined" && arguments[i] != "submit" ) {
966   - if ( parent.document.getElementById( arguments[i] ) )
967   - obj = parent.document.getElementById( arguments[i] );
968   - else if ( window.opener.document.getElementById( arguments[i] ) )
969   - obj = window.opener.document.getElementById( arguments[i] );
970   - if ( obj.type == "select-one" ) {
971   - novoIndice = obj.options.length;
972   - obj.options[novoIndice] = new Option( arguments[i + 2] );
973   - opcao = obj.options[novoIndice];
974   - opcao.value = arguments[i + 1];
975   - opcao.selected = true;
976   - obj.onchange();
977   - i += 3;
978   - }
979   - else {
980   - obj.value = arguments[i + 1];
981   - i += 2;
982   - /* if ( parent.document.createEvent ) {
983   -         var evt = parent.document.createEvent( "KeyEvents" );
984   - //var evt = parent.document.createEvent( "UIEvents" );
985   -         //evt.initKeyEvent( "keypress", true, true, null, false, false, false, false, evt.DOM_VK_ENTER, 0 );
986   - evt.initKeyEvent( "keypress", true, true, window, false, false, false, false, 100, 0 );
987   - //evt.initUIEvent( "keypress", false, false, window, 1);
988   -         obj.dispatchEvent( evt );
989   -     } 
990   - else if ( parent.document.createEventObject ) {
991   -         var evt = parent.document.createEventObject();
992   -         obj.fireEvent( 'onkeypress', evt );
993   -     }*/
994   - }
995   - }
996   - else if ( arguments[i] == "submit" ) {
997   - submit = true;
998   - i += 1;
999   - }
1000   - }
1001   - if ( submit ) {
1002   - if ( window == top ) {
1003   - tmpObj = window.opener.document.getElementById( 'tipoacao' )
1004   - if( hasProperties( tmpObj ) )
1005   - tmpObj.value = '';
1006   -
1007   - tmpObj = window.opener.document.getElementById( 'formcadastro' )
1008   - if( hasProperties( tmpObj ) )
1009   - tmpObj.submit();
1010   - }
1011   - else
1012   - {
1013   - tmpObj = window.parent.document.getElementById( 'tipoacao' )
1014   - if( hasProperties( tmpObj ) ){
1015   - tmpObj.value = '';
1016   - }
1017   -
1018   - tmpObj = window.parent.document.getElementById( 'formcadastro' )
1019   - if( hasProperties( tmpObj ) ) {
1020   - tmpObj.submit();
1021   - }
1022   - }
1023   - }
1024   -
1025   - if(exec)
1026   - {
1027   - exec();
1028   - }
1029   - if ( window == top )
1030   - window.close();
1031   - else
1032   - window.parent.fechaExpansivel( 'div_dinamico_' + ( parent.DOM_divs.length * 1 - 1 ) );
  1128 + var i = 0;
  1129 + var submit = false;
  1130 +
  1131 + while (i < arguments.length) {
  1132 + if (typeof arguments[i] != 'undefined' && arguments[i] != 'submit') {
  1133 + if (parent.document.getElementById(arguments[i])) {
  1134 + obj = parent.document.getElementById(arguments[i]);
  1135 + }
  1136 + else if (window.opener.document.getElementById(arguments[i])) {
  1137 + obj = window.opener.document.getElementById(arguments[i]);
  1138 + }
  1139 +
  1140 + if (obj.type == 'select-one') {
  1141 + novoIndice = obj.options.length;
  1142 + obj.options[novoIndice] = new Option(arguments[i + 2]);
  1143 + opcao = obj.options[novoIndice];
  1144 + opcao.value = arguments[i + 1];
  1145 + opcao.selected = true;
  1146 +
  1147 + obj.onchange();
  1148 +
  1149 + i += 3;
  1150 + }
  1151 + else {
  1152 + obj.value = arguments[i + 1];
  1153 + i += 2;
  1154 + }
  1155 + }
  1156 + else if (arguments[i] == 'submit') {
  1157 + submit = true;
  1158 + i += 1;
  1159 + }
  1160 + }
  1161 +
  1162 + if (submit) {
  1163 + if (window == top) {
  1164 + tmpObj = window.opener.document.getElementById('tipoacao')
  1165 +
  1166 + if (hasProperties(tmpObj)) {
  1167 + tmpObj.value = '';
  1168 + }
  1169 +
  1170 + tmpObj = window.opener.document.getElementById('formcadastro')
  1171 +
  1172 + if (hasProperties(tmpObj)) {
  1173 + tmpObj.submit();
  1174 + }
  1175 + }
  1176 + else {
  1177 + tmpObj = window.parent.document.getElementById('tipoacao')
  1178 +
  1179 + if (hasProperties(tmpObj)) {
  1180 + tmpObj.value = '';
  1181 + }
  1182 +
  1183 + tmpObj = window.parent.document.getElementById( 'formcadastro' )
  1184 + if (hasProperties(tmpObj)) {
  1185 + tmpObj.submit();
  1186 + }
  1187 + }
  1188 + }
  1189 +
  1190 + if (exec) {
  1191 + exec();
  1192 + }
  1193 +
  1194 + if (window == top) {
  1195 + window.close();
  1196 + }
  1197 + else {
  1198 + window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
  1199 + }
1033 1200 }
1034 1201  
1035   -// retorna 0 (zero) se nao tiver propriedades
1036   -function hasProperties( obj )
  1202 +// Retorna 0 caso não tenha propriedades
  1203 +function hasProperties(obj)
1037 1204 {
1038   - prop = '';
1039   - if( typeof obj == 'string' )
1040   - {
1041   - obj = document.getElementById( obj );
1042   - }
1043   -
1044   - if( typeof obj == 'object' )
1045   - {
1046   - for( i in obj )
1047   - {
1048   - prop += i;
1049   - }
1050   - }
1051   - return prop.length;
  1205 + prop = '';
  1206 + if (typeof obj == 'string') {
  1207 + obj = document.getElementById(obj);
  1208 + }
  1209 +
  1210 + if (typeof obj == 'object') {
  1211 + for (i in obj) {
  1212 + prop += i;
  1213 + }
  1214 + }
  1215 +
  1216 + return prop.length;
1052 1217 }
1053 1218  
1054   -function enviar() {
1055   - if( ( typeof arguments[0] != "undefined" ) && ( typeof arguments[1] != "undefined" ) )
1056   - window.opener.addVal( arguments[0], arguments[1] );
1057   - if( typeof arguments[2] != "undefined" )
1058   - window.opener.document.getElementById( 'formcadastro' ).submit();
1059   - window.close();
  1219 +function enviar()
  1220 +{
  1221 + if (
  1222 + (typeof arguments[0] != 'undefined') &&
  1223 + (typeof arguments[1] != 'undefined')
  1224 + ) {
  1225 + window.opener.addVal(arguments[0], arguments[1]);
  1226 + }
  1227 +
  1228 + if (typeof arguments[2] != 'undefined') {
  1229 + window.opener.document.getElementById('formcadastro').submit();
  1230 + }
  1231 +
  1232 + window.close();
1060 1233 }
1061 1234  
  1235 +/**
  1236 + * @TODO Remover função, sem chamadas no i-Educar.
  1237 + */
1062 1238 function enviar2() {
1063   - if( ( typeof arguments[0] != "undefined" ) && ( typeof arguments[1] != "undefined" ) )
1064   - window.parent.addVal( arguments[0], arguments[1] );
1065   - if( typeof arguments[2] != "undefined" )
1066   - window.parent.fechaExpansivel( 'div_dinamico_' + ( parent.DOM_divs.length * 1 - 1 ) );
1067   - window.parent.document.getElementById( 'formcadastro' ).submit();
  1239 + if (
  1240 + (typeof arguments[0] != 'undefined') &&
  1241 + (typeof arguments[1] != 'undefined')
  1242 + ) {
  1243 + window.parent.addVal(arguments[0], arguments[1]);
  1244 + }
  1245 +
  1246 + if (typeof arguments[2] != 'undefined') {
  1247 + window.parent.fechaExpansivel(
  1248 + 'div_dinamico_' + (parent.DOM_divs.length * 1 - 1)
  1249 + );
  1250 + }
  1251 +
  1252 + window.parent.document.getElementById( 'formcadastro' ).submit();
1068 1253 }
1069 1254  
1070 1255 function getElementsByClassName(oElm, strTagName, strClassName)
1071 1256 {
1072   - var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
1073   - var arrReturnElements = new Array();
1074   - strClassName = strClassName.replace(/\-/g, "\\-");
1075   - var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
1076   - var oElement;
1077   - for(var i=0; i<arrElements.length; i++)
1078   - {
1079   - oElement = arrElements[i];
1080   - if(oRegExp.test(oElement.className))
1081   - {
1082   - arrReturnElements.push(oElement);
1083   - }
1084   - }
1085   - return (arrReturnElements);
  1257 + var arrElements = (strTagName == '*' && document.all) ?
  1258 + document.all : oElm.getElementsByTagName(strTagName);
  1259 +
  1260 + var arrReturnElements = new Array();
  1261 + strClassName = strClassName.replace(/\-/g, '\\-');
  1262 +
  1263 + var oRegExp = new RegExp('(^|\\s)' + strClassName + '(\\s|$)');
  1264 + var oElement;
  1265 +
  1266 + for (var i=0; i<arrElements.length; i++) {
  1267 + oElement = arrElements[i];
  1268 +
  1269 + if (oRegExp.test(oElement.className)) {
  1270 + arrReturnElements.push(oElement);
  1271 + }
  1272 + }
  1273 +
  1274 + return (arrReturnElements);
1086 1275 }
1087 1276  
1088   -function mudaClassName( strClassTargetName, strNewClassName )
  1277 +function mudaClassName(strClassTargetName, strNewClassName)
1089 1278 {
1090   - tagName = ( arguments[2] ) ? arguments[2]: '*';
1091   - arrObjs = getElementsByClassName( document, tagName, strClassTargetName );
1092   - for( i in arrObjs )
1093   - {
1094   - arrObjs[i].className = strNewClassName;
1095   - }
  1279 + tagName = (arguments[2]) ? arguments[2]: '*';
  1280 + arrObjs = getElementsByClassName( document, tagName, strClassTargetName );
  1281 +
  1282 + for (i in arrObjs) {
  1283 + arrObjs[i].className = strNewClassName;
  1284 + }
1096 1285 }
1097 1286  
1098   -function addEvent_(evt,func,field)
  1287 +function addEvent_(evt, func, field)
1099 1288 {
1100   - if(!field)
1101   - field = window;
1102   - else
1103   - field = document.getElementById(field);
1104   -
1105   - if( field.addEventListener ) {
1106   - //mozilla
1107   - field.addEventListener(evt,func,false);
1108   - } else if ( field.attachEvent ) {
1109   - //ie
1110   - field.attachEvent('on' + evt,func);
1111   - }
  1289 + if (! field) {
  1290 + field = window;
  1291 + }
  1292 + else {
  1293 + field = document.getElementById(field);
  1294 + }
  1295 +
  1296 + if (field.addEventListener) {
  1297 + // Mozilla
  1298 + field.addEventListener(evt, func, false);
  1299 + }
  1300 + else if (field.attachEvent) {
  1301 + // IE
  1302 + field.attachEvent('on' + evt, func);
  1303 + }
1112 1304 }
1113 1305  
1114   -function removeEvent(evt,func,field)
  1306 +/**
  1307 + * @TODO Remover função, sem chamadas no i-Educar.
  1308 + */
  1309 +function removeEvent(evt, func, field)
1115 1310 {
1116   -
1117   - if(!field)
1118   - field = window;
1119   - else
1120   - field = document.getElementById(field);
1121   -
1122   - if( field.addEventListener ) {
1123   - //mozilla
1124   - field.removeEventListener(evt,null,false);
1125   - } else if ( field.detachEvent ) {
1126   - //ie
1127   - field.detachEvent('on' + evt,func);
1128   - }
  1311 + if (! field) {
  1312 + field = window;
  1313 + }
  1314 + else {
  1315 + field = document.getElementById(field);
  1316 + }
  1317 +
  1318 + if (field.addEventListener) {
  1319 + // Mozilla
  1320 + field.removeEventListener(evt, null, false);
  1321 + }
  1322 + else if (field.detachEvent) {
  1323 + // IE
  1324 + field.detachEvent('on' + evt, func);
  1325 + }
1129 1326 }
1130 1327 \ No newline at end of file
... ...