//Piau 1.6 // Funcoes Para Tratamento de Janelas Abertas pelo JavaScript var J_F = undefined; //Janela Filha var tid; // Contador de Tempo da Janela function Fecha_JF() { //Fecha as Janelas Abertas Nesta Sessão em Cascata var Proxima = J_F; while (Proxima != undefined) { Atual = Proxima; Proxima = Proxima.window.J_F; if (Atual != undefined) { Atual.window.close(); //J_F = undefined; } } J_F = undefined; window.onfocus = function() { }; } function Prepara_Fecha_JF() { setTimeout("window.onfocus = function() { Fecha_JF() }", 500); } function Atualiza_Janela_Mae() { J_F_Aux = window.opener.J_F; if (window.opener.document.pagina1 != undefined) { window.opener.document.pagina1.submit(); setTimeout("window.opener.J_F = J_F_Aux;", 2000); setTimeout("window.opener.Prepara_Fecha_JF();", 2100); } else { if (window.opener.document.form != undefined) { window.opener.document.form.CONFIRMA.value=9; window.opener.document.form.submit(); setTimeout("window.opener.J_F = J_F_Aux;", 2000); setTimeout("window.opener.Prepara_Fecha_JF();", 2100); } } } function Atualiza_Fecha_Janela_Mae(janela) { J_F_Aux = undefined; if (janela!=undefined) J_F_Aux = janela if (J_F_Aux != window.opener.J_F) { J_F_Aux = window.opener.J_F; setTimeout("window.opener.J_F = J_F_Aux;", 400); setTimeout("window.opener.Prepara_Fecha_JF();", 400); setTimeout("Atualiza_Fecha_Janela_Mae(J_F_Aux)", 400); } } function janela_filha(end,nome,parametros){ //Tal Janela se fechará quando perder o foco //starttimeoutcheck(); //Zera Contagem para Mensagem de Expiração de Sessao clearTimeout(tid); window.defaultStatus=""; window.onfocus = function() { }; J_F = window.open(end,nome,parametros); J_F.window.focus(); Prepara_Fecha_JF(); //if (window.showModalDialog) { //Internet Explorer // J_F = window.showModalDialog(end,nome,parametros);//+"dialogWidth:255px;dialogHeight:250px"); //} else { //Demais broswers // J_F = window.open(end,nome,parametros+'toolbar=no,directories=no,continued from previous linemenubar=no,modal=yes'); //} //J_F.window.focus(); } function janela_filha2(end,nome,parametros){ //Tal Janela NÃO se fechará quando perder o foco //starttimeoutcheck(); clearTimeout(tid); // Zera Contagem para Mensagem de Expiração de Sessao window.defaultStatus=""; J_F2 = window.open(end,nome,parametros); J_F2.window.focus(); } function showmsg (charset, title, msg, button, name, width, height, seconds) { var hWnd = window.open("", name,"width="+width+",height="+height+",resizable=no,scrollbars=no"); hWnd.document.write('\n'); hWnd.document.write(''+title+'\n'); hWnd.document.write('
\n'); hWnd.document.write(msg); hWnd.document.write('

\n'); hWnd.document.write('
\n'); hWnd.document.write('\n'); hWnd.document.write('\n'); hWnd.window.focus(); } function abre_janela(pag,arg,id) { pagina = pag; argumentos = '?'+arg+'='+id; topo = posicao_janela_atual('X'); esquerdo = posicao_janela_atual('Y'); janela_filha(pagina+argumentos,'Janela_Nova','left='+(esquerdo+50)+',top='+(topo+50)+',height=550,width=710,scrollbars=yes,resizable=yes'); } function abre_janela_fixa(pag,arg,id) { pagina = pag; argumentos = '?'+arg+'='+id; topo = posicao_janela_atual('X'); esquerdo = posicao_janela_atual('Y'); janela_filha2(pagina+argumentos,'Janela_Nova','left='+(esquerdo+50)+',top='+(topo+50)+',height=550,width=710,scrollbars=yes,resizable=yes'); } function abre_janela_tamanho(pag,arg,id,alt,lar) { pagina = pag; argumentos = '?'+arg+'='+id; topo = posicao_janela_atual('X'); esquerdo = posicao_janela_atual('Y'); janela_filha(pagina+argumentos,'Janela_Nova','left='+(esquerdo+50)+',top='+(topo+50)+',height='+alt+',width='+lar+',scrollbars=yes,resizable=yes'); } function abre_janela_localizar(coord_x,coord_y,combo,campo) { coord_x=coord_x+30; coord_y=coord_y+30; if ((coord_x+250)>screen.width) { coord_x=screen.width-250; coord_y=coord_y+30; } pagina='loc_combo.php'; argumentos = '?combo='+combo+'&campo='+campo; comboobj = eval(combo); if (comboobj.disabled) alert('Campo: '+campo+' não habilitado!'); else janela_filha(pagina+argumentos,'Janela_Localizar','top='+coord_y+',left='+coord_x+',height=40,width=250,scrollbars=no,resizable=yes'); } function abre_janela_calendario(coord_x,coord_y,input,campo) { coord_x=coord_x+30; coord_y=coord_y+30; if ((coord_x+250)>screen.width) { coord_x=screen.width-200; coord_y=coord_y+30; } pagina='script.php?tp=cal'; argumentos = '&input='+input+'&campo='+campo; inputobj = eval(input); if (inputobj.disabled) alert('Campo: '+campo+' não habilitado!'); else janela_filha(pagina+argumentos,'Janela_Localizar','top='+coord_y+',left='+coord_x+',height=40,width=200,scrollbars=no,resizable=yes'); } function posicao_janela_atual(coord) { //Retorna a Posição(Canto Superior Esquerdo) da Janela Atual if (coord.toUpperCase()=="X") { if (navigator.appName=="Netscape") return(window.screenX); else return(window.screenTop); } else { if (coord.toUpperCase()=="Y") { if (navigator.appName=="Netscape") return(window.screenY); else return(window.screenLeft); } else return(0); } } function alerta_erro(f,erro,campo) { //alerta erros em formularios if (erro!='') alert(erro) if (campo!='') { obj = eval('f.'+campo); if (obj!=undefined) { class_old = obj.className; obj.className='inputerro'; fct = obj.onblur; obj.onblur = function(){this.className=class_old;retorna_onblur(obj,fct)}; //posY = findPosY(obj); //tamY = (window.outerHeight!=undefined)?window.outerHeight:screen.availHeight; //if (posY>tamY*0.8) // window.scrollTo(0,posY-70); obj.focus(); } else alert('Campo não encontrado: \n'+campo); } return(false); } function retorna_onblur(obj,fct) { if (fct!=undefined) fct(); obj.onblur = fct; } function piau_bwcheck(){ this.ver=navigator.appVersion this.agent=navigator.userAgent.toLowerCase() this.dom=document.getElementById?1:0 this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1) && window.opera this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1) && window.opera this.ie5 = (this.agent.indexOf("msie 5")>-1 && !this.op5 && !this.op6) this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1) this.ie6 = (this.agent.indexOf("msie 6")>-1 && !this.op5 && !this.op6) this.ie4=(this.agent.indexOf("msie")>-1 && document.all &&!this.op5 &&!this.op6 &&!this.ie5&&!this.ie6) this.ie = (this.ie4 || this.ie5 || this.ie6) this.mac=(this.agent.indexOf("mac")>-1) this.ns6=(this.agent.indexOf("gecko")>-1 || window.sidebar) this.ns4=(!this.dom && document.layers)?1:0; this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6) this.usedom= this.ns6//Use dom creation this.reuse = this.ie||this.usedom //Reuse layers this.px=this.dom&&!this.op5?"px":"" return this } var piau_bw=new piau_bwcheck(); function muda_foco(linha,cor) { //Muda a cor de fundo do objeto elemento = piau_bw.dom?document.getElementById('row'+linha).style:piau_bw.ie4?document.all['row'+linha].style:piau_bw.ns4?eval('document.layers.'+'row'+linha):0; if (piau_bw.dom || piau_bw.ie4) elemento.backgroundColor=cor; else if(piau_bw.ns4) elemento.bgColor=cor; } function altera_visibilidade(objeto) { if (objeto.style.visibility=="hidden") objeto.style.visibility="visible"; else objeto.style.visibility="hidden"; } function altera_exibicao(objeto) { if (objeto.style.display=="none") objeto.style.display=""; else objeto.style.display="none"; }