//*******************************//
// janelas dependentes
//*******************************//
var wDep = new Array,wTip = new Array,wUrl = new Array;
var parente,objPai;
var obj_obj;
//*******************************//
//controle de eventos
var acoesEvento = new Array(); 

function detach() {
 var ob=browse.getId('menuDad');
 var w = new winDep(window,'javascript:opener.detachC();');
 w.tipo = 3;
 w.w = browse.getTX(ob);
 w.h = Math.min(browse.getTY(ob),700);
 w.abre();
 //return;
}
function detachC() {
 //alert(leftAt(document.documentElement.innerHTML,'<body'));
 var bs = leftAt(window.location+'?','?');
 alert(bs);
 return (
  //'<html><head><title>Katalogos - 3WS Sistemas</title></head>'
  //+'<BASE href=https://signey.dyndns.org/>'
  //+'<script language="JavaScript" src="/js/jan.js"></script>'
  //+'<LINK REL="StyleSheet" HREF="/estilos/kat.css">'
  '<html><BASE href='+bs+'>'
   +leftAt(document.documentElement.innerHTML,'<body')
  +"<body  onClickas=jsCSSEditor(this,event); onload=evento('load') onfocus=evento('focus') onresize=evento('resize'); onblur=evento('focusOut'); onunload=evento('close');>"
  +browse.getId('menuDad').innerHTML
  +'</body>'
  +'</html>\r\n\r\n'
 );
 //objNav(w);
}

//setTimeout('menuSub()',1500);
regAcaoEvento('load','menuSub')
function menuSub() {
 var ob = browse.getId('menuSub');
 if (vazio(ob)) {
  //alert('nao encontrei menuSub');
  return;
 }
 return;
 ob.innerHTML = '<div style="position: absolute;">' 
  +'<img src=/imagens/subM.gif align=right>'
  +'<img src=/imagens/subM.gif align=right>'
  +'<img onclick=detach(); src=/imagens/subM.gif align=right>'
  +'</div>'
 ; 
}



/*
,objNavAlvo;
function objNavR(a) {
 return objNavAlvo[a];
}
*/

//alert('janjs');
//desliga editor
//alert('ini');
//document.designMode = 'off';

//if (confirm('ver estilos')) {
// setTimeout('objNav(getAllSheets())',1000);
//}

function getAllSheets() {
 if( !window.ScriptEngine && navigator.__ice_version ) {
  return document.styleSheets; 
 }
 if( document.getElementsByTagName ) {
  var Lt = document.getElementsByTagName('link');
  var St = document.getElementsByTagName('style');
 } else if( document.styleSheets && document.all ) {
  var Lt = document.all.tags('LINK');
  var St = document.all.tags('STYLE');
 } else {
  return [];
 }
 for( var x = 0, os = []; Lt[x]; x++ ) {
  var rel = Lt[x].rel 
   ? Lt[x].rel 
   : Lt[x].getAttribute 
    ? Lt[x].getAttribute('rel') 
    : ''
  ;
  if( typeof( rel ) == 'string' 
   && rel.toLowerCase().indexOf('style') + 1 ) {
   os[os.length] = Lt[x];
  }
 }
 for( var x = 0; St[x]; x++ ) {
  os[os.length] = St[x];
 }
 return os;
}




//armazeda dados do cliente
var cli=new Array;
cli['centra'] = true;

 //********************************
 function clone(o) {
  var r = new Array();
  var z;
  for(var prop in o) {
   try {
    z = o[prop];
   } catch (e) {
    z = '?erro:'+e;
   }
   r[prop] = z;
  }
  return r;
 }

 //********************************
 function menuSis2(o) {
  window.location = '/'+o.value+'.class';
 }
 //********************************
 function menuSis1(s) {
  var v=palavraA(trimm(s,','),',');
  //,pdf,cli,kat,base,wwws,fd,adv,quilos,cs,agenda,Log,csu,cgs,lab,usu,
  v.sort();
  var r='<scr'+'ipt>var menuS_v = new Array();';
  for (var i=0;i<v.length;i++) {
   if (',pdf,base,agenda,'.indexOf(','+v[i]+',')==-1) {
    r += 'menuS_v[menuS_v.length]="'+v[i]+'~~'+v[i]+'.class'+'";';
   }
  }
  r += "var menuS = new menuPopUp('menuS','',menuS_v,'','menSPop');"
   +"menuS.evento = false;menuS.posEsq=1;"
   +'</scr'+'ipt>';
  //alert(r);
  return r;
 }
 //********************************
 function menuSis1a(s) {
  var v=palavraA(trimm(s,','),',');
  //,pdf,cli,kat,base,wwws,fd,adv,quilos,cs,agenda,Log,csu,cgs,lab,usu,
  var r='<td class=ctrlSis><select class=ctrlSis onchange=menuSis2(this);>'
   +'<option>'
  ;
  for (var i=0;i<v.length;i++) {
   if (',pdf,base,agenda,'.indexOf(','+v[i]+',')==-1) {
    r +='<option value='+v[i]+'>'+v[i];
   }
  }
  return '</select>'+r;
 }
 //********************************
 function menuSis(s) {
  document.write(menuSis1(s)+"<div class=ctrlSis1><table class=ctrlSis><tr>"
   +"<td class=ctrlSis><a onclick=javascript:menuS.abre(this,'',event);>A</a>"
   +"<td class=ctrlSis><a title=Chat href='javascript:chatAbre();'>"
    +"<img valign=center class=ctrlSis border=0 src=/imagens/chat.gif></a>"
   +"<td class=ctrlSis><a title=Calendário href='javascript:caleAbre();'>"
    +"<img valign=center class=ctrlSis border=0 src=/imagens/cale.gif></a>"
   +"<td class=ctrlSis><a title=Calculadora href='javascript:calcAbre();'>"
    +"<img valign=center class=ctrlSis border=0 src=/imagens/calc.gif></a>"
   +"<td class=ctrlSis><a title='Preferências do Usuários' href='javascript:prefsAbre();'>"
    +"<img valign=center class=ctrlSis border=0 src=/imagens/prefs.gif></a>"
   +"<td class=ctrlSis><a title='Sair (logoff)' href='javascript:sair();'>"
    +"<img class=ctrlSis border=0 src=/imagens/sair.gif></a>"
   //+menuSis1(s)
   +"</table></div>"
  );
 }


 //********************************
 function prefsAbre() {
  var e = ''+window.location;
  e = '/'+leftAt(substrAt(substrAt(e,'//'),'/')+'?','?');
  var ww=new winDep(window,e+'?op=prefs&menu=0');
  ww.w=200;ww.h=250;ww.centrada=false;ww.scr='no';
  ww.tipo=3;ww.abre();
 }
 //********************************
 function caleAbre() {
  var ww=new winDep(window,'/js/cale.html');
  ww.w=200;ww.h=250;ww.centrada=false;ww.scr='no';
  ww.tipo=3;ww.abre();
 }
 //********************************
 function sair() {
  var e = ''+window.location;
  e = '/'+leftAt(substrAt(substrAt(e,'//'),'/')+'?','?');
  window.location = '/valusuario.class?op=sair&ender='+e
   +'&segs='+ms();
  ;
 }
 //********************************
 function calcAbre() {
  var ww=new winDep(window,'/js/calc.html');
  ww.w=250;ww.h=100;ww.centrada=false;ww.scr='no';
  ww.tipo=3;ww.abre();
 }
 //********************************
 function chatAbre(sl) {
  var ww=new winDep(window,'/chat.class'+(vazio(sl)?"":"?s="+sl));
  ww.w=400;ww.centrada=false;ww.h=500;
  ww.tipo=3;ww.abre();
 }
 //*********************************
 function janRaiz() {
  if (vazio(top.opener)) {
   return top;
  }
  return top.opener.janRaiz();
 }

 //*********************************
 function janLocObj(nome) {
  var x;
  try {
   x = eval(nome);
  } catch (e) {
  }
  if (typeof(x)!='undefined') {
   return x;
  }
  if (vazio(top.opener)) {
   return null;
  }
  return top.opener.janLocObj(nome);
 }

 //*********************************
 function campoArqAt(nome) {
  if (false && browse.IE4) {
   window.location = 'pprs://'+nome;
  } else {
   window.location = '/dww.class?arq='+nome;
  }
 }



 //*********************************
 //*********************************
 // entrada de dados popUP
 //*********************************
 function entraPopUp(url) {
  this.url = url+'&menu=0&popUp=1';
  win=new winDep(window,this.url);
  win.tipo = 0;
  win.frame = true;
  win.w=400;
  win.h=100;
  win.abre();
 }

/*******************************
function imgJanL() {
 return;
 var i = browse.getId('imagem');
 if (i.width/window.innerWidth>i.height/window.innerHeight) {
  i.width=window.innerWidth-45;
 } else {
  i.height=window.innerHeight-60;
 }
 //i.height=window.innerHeight-60;
 //objNav(i);
}
//*******************************
function imgJanR(url) {
 imgJanL();
}
//*******************************
function imgJan(url,w,h,ev) {
 if (ev.ctrlKey) return;
 alert('u='+url+' w='+w+' h='+h);
 var wi = new winDep(this,'?img='+url);
 wi.w='';
 wi.h='';
 wi.scr = 'yes';
 wi.centrada = false;
 wi.abre();
}
*/
 
//******************************
//para entrada de data
//******************************
function browseData(nomeDiv,nomeTex,nomeH) {
 this.nomeTex = nomeTex;
 this.div = browse.getId(nomeDiv);
 this.cal = new calendMes(nomeDiv,nomeTex,nomeH);
 for(var prop in this.cal) {
  this[prop] = this.cal[prop];
 }
 this.aberto = false;
 this.modo = 0;
 
 this.abre = browseData_Abre;
 this.abre1 = browseData_Abre1;
 this.abre2 = browseData_Abre2;
 this.fecha = browseData_Fecha;
 this.clickP = browseData_clickP;
 //******************************
 function browseData_clickP(d) {
  var v = palavraA(d,"-");
  this.dest.value = v[2]+"/"+v[1]+"/"+v[0];
  this.fecha();
 }
 //******************************
 function browseData_Fecha() {
  if (this.modo==0) {
   browse.esconde(this.div);
  } else {
   this.obj.innerHTML = '';
  }
  this.aberto=false;
  try {
   fD.selects(true);
  } catch (e) {
  }
 }
 //******************************
 function browseData_Abre1(ob) {
  this.dest = document.__formul[ob];
  var o = new winDep(top,'');
  o.centrada = false;
  o.w=100;o.h=100;
  o.debug = true;
  o.scr = 'no';
  if (!o.abre()) {
   return;
  }
  var ob = browse.getId("browseDataO");
  //obj(ob);
  o.on('<html><body TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>'
  +''+ob.innerHTML+''
  +'</body></html>'
  );
  var ob = browse.getId('cld',o.obj.document);
  //obj(this.cal.obj);
  this.obj = browse.getId(this.nomeTex,o.obj.document);
  //obj(this.cal.obj);
  o.obj.browseDataO = this;
  //obj(ob,'number');
  //alert('w='+ob.offsetWidth+' h='+ob.offsetHeight);
  //o.obj.resizeTo(ob.offsetWidth+50,ob.offsetHeight+40);
  o.obj.resizeTo(ob.offsetWidth+20,
  ob.offsetHeight+10+(browse.ie?50:0));
  //ob.width = '100%';
  o.obj.focus();
 }
 //******************************
 function browseData_Abre(obj) {
  if (this.aberto) {
   this.fecha();
   return;
  }
  this.aberto = true;
  this.dest = document.__formul[obj]; //browse.getId(obj);
  //alert(obj+' '+this.dest);
  if (this.dest.value.length>0) {
   this.cal.set(this.dest.value);
  }
  //debug(this.dest);
  //alert(this.dest.controllers.getControllerAt(0));
  //alert(obj(this.dest));
  browse.mostra(this.div);
  try {
   fD.selects(false);
  } catch (e) {
   //alert(''+e);
   //obj(e);
  }
  var x = browse.getAbsX(this.dest)+browse.getTX(this.dest);
  var y = browse.getAbsY(this.dest)-browse.getTY(this.div);
  //testa se vai ficar fora
  y = y<0?0:y;
  var tj = browse.tamWinX();
  if (x+browse.getTX(this.div)>tj) {
   x =  tj-browse.getTX(this.div);
  }
  browse.setX(this.div,x);
  browse.setY(this.div,y);
  //alert('x='+x+'y='+y+' '+obj+' '+this.dest);
 }
 //******************************
 function browseData_Abre2(sOb) {
  if (this.aberto) {
   this.fecha();
   if (this.abertoN==sOb) {
    return;
   }
  }
  this.aberto = true;
  this.abertoN = sOb;
  
  this.dest = document.__formul[sOb];
  var ob = browse.getId('browseDataO');
  var dd = browse.getId(sOb+'_');
  //dd.innerHTML = browse.getId('browseDataT').innerHTML;
  //browse.esconde(dd);
  //var ob = browse.getId('cld',o.obj.document);
  this.obj = dd;
  this.monta();
  this.modo = 1;
 }
}

//**************************//
// objeto calendMes
//**************************//
function calendMes(nome,nomeLocTex,nomeLocHoje) {
 this.fSize1 = 1;
 this.fSize2 = 2;
 //nome da var que armazena este objeto
 //objeto para atribuir innerHTML
 this.nome = nome;
 this.obj = browse.getId(nomeLocTex);
 this.objH = browse.getId(nomeLocHoje);
 this.mDia = 1000*60*60*24;
 
 this.monta = calendMes_Monta;
 this.iMes = calendMes_iMes;
 this.iAno = calendMes_iAno;
 this.iDia = calendMes_iDia;
 this.clickP = calendMes_Click;
 this.dataF = calendMes_dataF;
 this.feriado = calendMes_Feriado;
 this.set = calendMes_Set;
 this.cha = calendMes_Char;
 this.horas = calendMes_horas;
 
 this.corH = '"#07FFFF"';
 
 this.hVerao = new Array();
 
 this.fer = Array();
 this.fer[1.0] = 'Ano Novo';
 this.fer[21.03] = 'Tiradentes';
 this.fer[1.04] = 'Trabalho';
 this.fer[7.08] = 'Independência';
 this.fer[12.09] = 'Criança';
 this.fer[2.10] = 'Finados';
 this.fer[15.10] = 'República';
 this.fer[25.11] = 'Natal';
 
 this.set(this.dataF(new Date()));
 //**************************//
 function calendMes_Char(d) {
  var r='';
  for (var i=0;i<d.length;i++) {
   r += '<br>'+d.substring(i,i+1);
  }
  return r.substring(4);
 }
 //**************************//
 function calendMes_Set(d) {
  var v;
  d = trimm(d);
  if (d.indexOf(' ')!=-1) {
   d = leftAt(d,' ');
  }
  if (d.indexOf("/")!=-1) {
   v = palavraA(d,"/");
   this.ano = v[2]*1;
   this.mes = v[1]-1;
   this.dia = v[0]*1;
  } else {
   v = palavraA(d,"-");
   this.ano = v[0]*1;
   this.mes = v[1]-1;
   this.dia = v[2]*1;
  }
  if (this.ano==0) {
   //this.monta();
   return;
  }
  this.data = new Date(this.ano,this.mes,this.dia);
  //alert('data='+this.data+' par='+d);
  
  //seta data na aba
  if (objLen(this.objH)!=0) {
   var x = this.cha(tb_diaSemana[this.data.getDay()].toUpperCase())
   +'<br><br>&nbsp;&nbsp;'+this.data.getDate()
   +'<br><br>'+this.cha(tb_nomeMes[this.data.getMonth()]
   .toUpperCase().substring(0,3));
   this.objH.innerHTML = '<p align=right><font size=1><b>'+x+'</font></p>';
  }
  this.monta();
 }
 //**************************//
 function calendMes_Feriado(d) {
  var a = this.fer[d.getDate()+d.getMonth()/100];
  if (typeof(a)!='undefined') {
   return a;
  }
  return false;
 }
 //**************************//
 function calendMes_dataF(d,del) {
  if (typeof(del)=='undefined') del='-';
  if (del=='-') {
   return takeYear(d)+'-'+strZero(d.getMonth()+1,2)
   +'-'+strZero(d.getDate(),2);
  } else {
   return strZero(d.getDate(),2)+'/'
   strZero(d.getMonth()+1,2)+'/'+takeYear(d);
  }
 }
 //**************************//
 function calendMes_Click(d) {
  if (typeof(this.click)=='undefined') {
   alert('Sete '+this.nome+'.click com a função que '
   +'recebera a data clicada neste formato '+d);
   return;
  }
  //eval(this.click+'(\''+d+'\')');
  this.click(d);
 }
 //**************************//
 function calendMes_horas(d0,d1) {
  return (
  new Date(takeYear(d1),d1.getMonth(),d1.getDate()).getTime()-
  new Date(takeYear(d0),d0.getMonth(),d0.getDate()).getTime()
  )/1000/60/60;
 }
 //**************************//
 function calendMes_iDia(d) {
  var h = d.getHours();
  if (h!=0 && h<12) {
   d = new Date(d.getTime()+(h>12?24-h:-h)*60*60*1000);
  }
  d = new Date(d.getTime()+this.mDia);
  h = d.getHours();
  if (h>12) {
   d = new Date(d.getTime()+(h>12?24-h:-h)*60*60*1000);
  }
  if (h!=0) {
   this.hVerao[this.dataF(d)]=h<12?'Inicio':'Fim';
  }
  return d;
 }
 //**************************//
 function calendMes_iAno(n) {
  this.ano += n;
  this.monta();
 }
 //**************************//
 function calendMes_iMes(n) {
  if (n>0) {
   this.mes++;
   if (this.mes>11) {
    this.ano++;
    this.mes=0;
   }
  } else {
   this.mes--;
   if (this.mes<0) {
    this.ano--;
    this.mes=11;
   }
  }
  this.monta();
 }
 //**************************//
 function calendMes_Monta() {
  var d = new Date(this.ano,this.mes,1);
  //mes ant
  var m1 = new Date(d.getTime()-1000*60*60*24);
  m1 = takeYear(m1)+strZero(m1.getMonth()+1,2);
  //mes prox
  var m2 = new Date(d.getTime()+45000*60*60*24);
  m2 = takeYear(m2)+strZero(m2.getMonth()+1,2);
  
  //var x = new Array('Dom','Seg','Ter','Qua','Qui','Sex','Sab');
  //var ma=' style="cursor: pointer;"><font color=blue>---\></font>';
  //var me=' style="cursor: pointer;"><font color=blue>\<---</font>';
  var me=' style="cursor: pointer;"><img src=/imagens/tr.gif>';
  var ma=' style="cursor: pointer;"><img src=/imagens/av.gif>';
  var r= '<table CELLSPACING=0 CELLPADDING=0 align=center border=1>'
  +'<tr><td colspan=7 align=center><font size='+this.fSize1+'>'
  +'<a onClick="'+this.nome+'.iMes(-1);" '+m1+me+'</a> '
  +tb_nomeMes[this.mes]
  +' <a onClick="'+this.nome+'.iMes(01);" '+m2+ma+'</a>'
  +'&nbsp;&nbsp;'
  //+'<td colspan=3>'
  +'<a onClick="'+this.nome+'.iAno(-1);" '+me+'</a> '
  +'<b>'+this.ano+'</b> '
  +'<a onClick="'+this.nome+'.iAno(01);" '+ma+'</a>'
  +'<tr>';
  for (var i=0;i<7;i++) {
   r += '<th align=center><font size='+this.fSize1+'>'+tb_diaSemana[i];
  }
  var dy=0;
  r += '<tr>';
  while (d.getDay()!=dy) {
   r += '<td>&nbsp;';
   dy++;
  }
  var fer='',hoje=new Date();
  //alert(hoje.getYear());
  hoje=(new Date(hoje.getYear()+1900,
  hoje.getMonth(),hoje.getDate())).getTime();
  //alert(hoje);
  while (this.mes==d.getMonth()) {
   dy = this.feriado(d);
   if (dy) {
    fer += '<b>'+d.getDate()+'</b> '+dy+'<br>';
   }
   r += '<td onClick='+this.nome+'.clickP(\''+this.dataF(d)+'\'); '
   +(this.dataF(this.data)==this.dataF(d)?' bgcolor='+this.corH:'')
   +' align=right style="cursor: pointer;"><b><font '
   +(d.getDay()==0 || dy?' color=red ':'')
   +(d.getTime()==hoje?' color=blue ':'')
   +' size='+this.fSize1+'>'
   +(d.getDay()==0 && dy?'<u>':'')+d.getDate();
   da = d;
   d = this.iDia(d);
   if (this.horas(da,d)!=24) {
    fer += '<b>'+d.getDate()
    +'</b> Dia com '+this.horas(da,d)+' horas<br>';
   }
   if (d.getDay()==0) {
    r += '<tr>';
   }
  }
  while (d.getDay()!=0) {
   r += '<td>&nbsp;';
   d = this.iDia(d);
  }
  if (fer.length>0) r += '<tr><td colspan=7><font size='+this.fSize1+'>'+fer;
  this.obj.innerHTML = r+'</table>';
 }
}

//**************************//
// o b j e t o divLado
//**************************//
function divF(nome) {
 this.aberto=false;
 this.nome = nome;
 this.ca = browse.getId(nome);
 if (!objLen(this.ca)) {
  alert('Não encontrei id='+nome);
 }
 
 this.fecha = divF_Fecha;
 this.abre = divF_Abre;
 //**************************//
 function divF_Abre() {
  browse.mostra(this.ca,false);
  this.aberto = true;
 }
 //**************************//
 function divF_Fecha() {
  browse.esconde(this.ca,false);
  this.aberto = false;
 }
}


//**************************//
// o b j e t o divLado
//**************************//
function divLado(nome,nomeAba) {
 this.aberto=true;
 this.nome = nome;
 this.ca = browse.getId(nome);
 if (!objLen(this.ca)) {
  alert('Não encontrei id='+nome);
 }
 this.ca1 = browse.getId(nomeAba);
 browse.setX(this.ca,0);
 browse.mostra(this.ca,false);
 
 this.autoFechaD = false; //autofecha ativado
 this.autoFecha = 7000; //ms autofecha
 
 this.fecha = divLado_Fecha;
 this.abre = divLado_Abre;
 this.ativo = divLado_Ativo;
 this.aFecha = divLado_aFecha;
 
 //this.fecha();
 //**************************//
 function divLado_aFecha() {
  if (!this.aberto) {
   this.autoFechaD = false;
   return;
  }
  var t = (new Date()).getTime();
  if (this.aFechaProx<t) {
   this.fecha();
   this.autoFechaD = false;
  } else {
   setTimeout(this.nome+'.aFecha()',t-this.aFechaProx)
   this.autoFechaD = true;
  }
 }
 //**************************//
 function divLado_Ativo() {
  if (!this.aberto) return;
  if (this.autoFecha<1) return;
  this.aFechaProx = (new Date()).getTime()+this.autoFecha;
  if (this.autoFechaD) return;
  this.aFecha();
 }
 //**************************//
 function divLado_Abre() {
  if (this.aberto) return;
  browse.setX(this.ca,0);
  this.aberto = true;
  //-(browse.getTX(this.ca)-browse.getTX(this.ca1)));
  //browse.mostra(this.ca,false);
 }
 //**************************//
 function divLado_Fecha() {
  if (!this.aberto) return;
  browse.setX(this.ca,
  -(browse.getTX(this.ca)-browse.getTX(this.ca1)));
  this.aberto = false;
 }
}
//fim DIVLADO


//******************************
// objeto Pedido
// retorna parametros conforme 
// location e permite reatribuir
// com fins de montar novo location
//******************************
function pedido(doc) {
 this.atalho = pedido_Atalho;
 this.get = pedido_Get;
 this.put = pedido_Put;
 this.set = pedido_Put;
 
 //alert(typeof(doc));
 if (typeof(doc)=='undefined') {
  doc = window;
 }
 //alert(doc.location);
 this.doc = doc;
 var url=''+doc.location;
 this.param = new Array();
 this.url = url; 
 var p = url.indexOf('?');
 if (p==-1) {
  return;
 }
 this.url = url.substring(0,p);
 url = url.substring(p+1);
 var v = palavraA(url,'&');
 var c;
 for (var i=0;i<v.length;i++) {
  c = palavraA(v[i]+'=','=');
  this.param[c[0]] = c[1];
 }
 
 //******************************
 function pedido_Atalho() {
  var r = '';
  for(var prop in this.param) {
   if (this.param[prop]!=null) {
    r += '&'+prop+'='+this.param[prop];
   }
  }
  return this.url+(r.length==0?'':'?'+r.substring(1));
 }
 //******************************
 function pedido_Get(a,b) {
  var r = this.param[a];
  if (vazio(r) && !vazio(b)) {
   return b;
  }
  return r;
 }
 //******************************
 function pedido_Put(a,b) {
  this.param[a] = b;
 }
}




//*******************************//
//*******************************//
//*******************************//
// CONTROLE DE JANELAS POPUP..
// TIPOS DE JANELA: 
// 0 - FECHA SÓ SE FECHAR A PRINCIPAL
// 1 - FECHA SE O FOCO VOLTAR A PRINCIPAL
// 2 - OBRIGA O FOCO NA SECUNDARIA (DIÁLOGO);
// 3 - TOTALMENTE INDEPENDENTE
//*******************************//
//*******************************//
//*******************************//
 function objParente() {
  return obj_obj;
 }
 
 //*******************************//
 function regAcaoEvento(acao,funct) {
  if (vazio(acoesEvento[acao])) {
   acoesEvento[acao] = new Array();
  }
  acoesEvento[acao][acoesEvento[acao].length] = funct;
 }
 //*******************************//
 function evento(s,ev) {
  //opção em js
  //if (window.addEventListener) window.addEventListener("load",func,false);
  //else if (window.attachEvent) window.attachEvent("onload",func);   
  //for (var f = 0; (formnode = document.getElementsByTagName('form').item(f)); f++) {
  //executa acoes registradas
  //alert(s+' '+ev);
  if (!vazio(acoesEvento[s])) {
   for (prop in acoesEvento[s]) {
    //alert(prop);
    eval(acoesEvento[s][prop]+'()');
   }
  }
  
  if (s=='resize') {
  }
  if (s=='load') {
   //alert('l='+opener);
   if (objLen(opener)!=0) {
    parente = opener;
    objPai = opener.objParente();
   }
   //objLen(opener);
   if (!vazio(objPai) && !vazio(objPai.onLoad)) {
    eval(objPai.onLoad);
   }
  }
  if (s=='close') {
   if (!vazio(objPai) && objPai.pulaClose) {
    objPai.pulaClose = false;
    return;
   }
   //fecha todas as janelas dependentes
   for (i=0;i<wDep.length;i++) {
    if (wDep[i]!=0) {
     wDep[i].close();
     wDep[i] = 0;
    }
   }
   //informa a superior
   if (parente && !vazio(objPai)) {
    //alert('informa sup');
    parente.dRegistraWin(objPai.janPos);
   }
  }
  if (s=='focus') {
   //fecha janelas tipo 1 
   for (i=0;i<wDep.length;i++) {
    if (wDep[i]!=0 && wTip[i]==1) {
     wDep[i].close();
     wDep[i] = 0;
    } else if (wDep[i]!=0 && wTip[i]==2) {
     try {
      wDep[i].focus();
     } catch(e) {
      //alert('Erro: '+e);
     }
    }
   }
  }
  if (s=='focusOut') {
   if (!vazio(objPai) && objPai.tipo==2) {
    //window.focus();
    //alert("tipo janela=1");
    //fecha somente se o foco volta para a mãe...
    //parente.dRegistraWin(janPos);
    //window.close();
   }
  }
 }
 //*******************************//
 function dRegistraWin(i) {
  if (typeof(i)=='string') {
   i = substrAt(i,'//');
   i = '/'+substrAt(i,'/');
   for (var i1=0;i1<wDep.length;i1++) {
    if (wDep[i1]!=0 && wUrl[i1]==i) {
     //alert('achei: '+wUrl[i1]);
     dRegistraWin(i1);
     return;
    }
   }
   alert('não achei: '+i+'\nem\n'+wUrl);
  } else if (wDep[i]!=0) {
   wDep[i].close();
   wDep[i] = 0;
  }
 }
 //*******************************//
 function existeWin(url) {
  for (var i=0;i<wDep.length;i++) {
   if (wDep[i]!=0 && wUrl[i]==url) {
    try {
     wDep[i].document.write('');
     wDep[i].focus();
    } catch(e) {
     //alert('e='+e);
     wDep[i]=0;
     return false;
    }
    return true;
   }
  }
 }
 
 //*******************************//
 function registraWin(obj) {
  for (i=0;i<wDep.length;i++) {
   if (wDep[i]==0) {
    break;
   }
  }
  obj.janPos = i;
  wDep[i] = obj.obj;
  wTip[i] = obj.tipo;
  wUrl[i] = obj.url;
  obj_obj = obj;
 }
 //*******************************//
 function alertErro(e) {
  objA(e);
 }
 //*******************************//
 function erroDeb() {
  try {
   var x;
   x.teste();
  } catch (e) {
   alert('erro='+troca(''+e.stack,'@','\n'));
  }
 }
 //*******************************//
 function resize(sObj,percX,percY) {
  var ob = browse.getId(sObj);
  if (vazio(ob)) {
   alert('erro no resize obj não localizado id='+sObj);
   return;
  }
  var tX=ob.offsetWidth+25; //+50;
  var tY=ob.offsetHeight+15; //+40;
  //limita ao tam janela MAE
  if (typeof(percX)=='undefined') percX=90;
  var mX = browse.tamWinX(janRaiz());
  tX = tX>mX?mX:tX;
  if (typeof(percY)=='undefined') percY=90;
  var mY = browse.tamWinY(janRaiz());
  tY = tY>mY?mY:tY;
  try {
   top.resizeTo(tX,tY);
  } catch (e) {
   //alert('ERRO: resize win='+e);
  }
 }
 //*******************************//
 function centra(ob,noOb) {
  var xy = centraCoo(ob,noOb);
  if (xy.length>1) {
   //alert(xy);
   ob.moveTo(xy[0],xy[1]);
  }
 }
 //*******************************//
 function centraCoo(ob,noOb) {
  if (!cli.centra) return;
  if (typeof(noOb)=='undefined') {
   noOb = ob;
   ob = top;
  }
  if (browse.ie) {
   try {
    var pX = noOb.screenLeft+noOb.document.body.offsetWidth/2
    -ob.document.body.offsetWidth/2;
    var pY = noOb.screenTop+noOb.document.body.offsetHeight/2
    -ob.document.body.offsetHeight/2;
    return new Array(pX,pY);
   } catch (e) {
    alert('erro='+e);
   }
  } else {
   var pX = noOb.screenX+noOb.outerWidth/2-ob.outerWidth/2;
   var pY = noOb.screenY+noOb.outerHeight/2-ob.outerHeight/2;
   return new Array(pX,pY);
  }
  return new Array();
 }
 
 //*******************************
 function centraDiv(dv,win) {
  if (vazio(win)) {
   win = window;
  }
  var pX,pY;
  if (browse.ie) {
   pX = win.screenLeft+win.document.body.offsetWidth/2
    -browse.getTX(dv)/2;
   pY = win.screenTop+win.document.body.offsetHeight/2
    -browse.getTY(dv)/2;
  } else {
   //pX = win.screenX+win.outerWidth/2-browse.getTX(dv)/2;
   pX = win.outerWidth/2-browse.getTX(dv)/2;
   //pY = win.screenY+win.outerHeight/2-browse.getTY(dv)/2;
   pY = win.outerHeight/2-browse.getTY(dv)/2;
  }
  dv.style.position = 'fixed';
  dv.style.top = pY+'px';
  dv.style.left = pX+'px';
  //browse.setX(dv,pX);
  //browse.setY(dv,pY);
  //dv.offsetTop = pY;
  //dv.offsetLeft = pX;
  //objNav(dv);
  //alert(pX+'-'+pY+' pa='+dv.style.left+','+dv.style.top);
 }
 
 //********************************
 //********************************
 function winDep(jan,url) {
  this.debug=false;
  this.jan = jan;
  this.url = url;
  this.tipo = 0;
  this.cascata = false;
  this.nome = '_blank';
  this.obj = null;
  this.pulaClose = false;
  this.janPos = -1;
  this.frame=false;
  this.centrada = true;
  this.scr = 'yes'; //scroll
  
  this.w = 400;
  this.h = 400;
  
  this.abre = winDep_abre;
  this.centra = winDep_centra;
  this.on = winDep_on;
  this.fCascata = fCascata;
  this.html = html;
  //********************************
  function html(txH) {
   this.obj.innerHTML = txH;
  }
  //********************************
  function winDep_on(s) {
   if (this.frame) {
    //alert('não sei gravar em frame...');
    var d = browse.getId('frm',this.obj.document);
    //objNav(d);
    d.contentWindow.document.write(s);
   } else {
    this.obj.document.write(s);
   }
  }
  //********************************
  function winDep_centra() {
   if (browse.ie) {
    this.pX = this.jan.screenLeft+this.jan.document.body.offsetWidth/2
    -this.w/2;
    this.pY = this.jan.screenTop+this.jan.document.body.offsetHeight/2
    -this.h/2;
   } else {
    this.pX = this.jan.screenX+this.jan.outerWidth/2-this.w/2;
    this.pY = this.jan.screenY+this.jan.outerHeight/2-this.h/2;
   }
  }
  //********************************
  function fCascata() {
   if (browse.ie) {
    this.pX = this.jan.screenLeft+20;
    this.pY = this.jan.screenTop+30;
   } else {
    this.pX = this.jan.screenX+20;
    this.pY = this.jan.screenY+30;
   }
  }
  //********************************
  function winDep_abre() {
   if (existeWin(this.url)) {
    //alert('url existe='+url);
    return false;
   }
   if (this.centrada) {
    this.centra();
   }
   if (this.cascata) {
    this.fCascata();
   }
   //alert('x='+this.pX+' y='+this.pY);
   var d=this.debug?"yes":"no";
   var t='width='+this.w+',height='+this.h
   +(this.pX?',screenX='+this.pX+',screenY='+this.pY:'')
   +',resizable=yes,scrollbars='+this.scr+','
   +'toolbar='+d+',menubar='+d+',status='+d;
   //alert(t);
   if (this.frame) {
    this.obj = window.open('',this.nome,t);
   } else {
    this.obj = window.open(this.url,this.nome,t);
   }
   //alert('ab');
   try {
    this.obj.focus();
    if (this.tipo!=3) {
     registraWin(this);
    }
    if (this.frame) {
     this.obj.document.write(
     '<html><frameset rows=100% border=1 framespacing=1 frameborder=0>'
     +'<frame id=frm src="'+this.url+'"></frameset></html>'
     );
    }
   } catch(e) {
   }
   return true;
  }
 }
//fim CTRLE JAN DEPENDENTES


//funcoes DEBUG
 //**************************//
 function objNav(ob,jan) {
  if (typeof(jan)!='undefined') {
   //this.filtro = o;
   this.o = ob;
   this.jan = jan;
   //metodos
   this.mostra = mostra;
   this.filtrar = filtrar;
   this.pula = pula;
   this.mItem = mItem;
   this.item = item;
   //this.mostra();
  } else {
   init(ob);
  }
  //**************************//
  function mItem(prop,z) {
   var r='';
   var t = typeof(z);
   if (t=='function' && (''+z).length>40) {
    z = ''+z;
    z = z.substring(0,40)+'...(+'+z.length+')';
   }
   if (!this.tp[t]) {
    this.tp[t] = 0;
   }
   this.tp[t]++;
   if (!this.filtro || t==this.filtro) {
    r += '<tr><td><font size=2 color=darkgreen><b>'+t+'</b></font> '
    +'<a href=javascript:este.pula("'+prop+'");>'+prop+'</a>: '
    +'<font size=2>'+(t=='string' || t=='function'?html(''+z):z)
    ;
   }
   if (t=='function' && ''+prop=='item') {
    //alert('item...');
    r += this.item();
   }
   return r;
  }
  //**************************//
  function item() {
   //alert('item');
   var r = '';
   for (var i=0;i<this.o.length;i++) {
    r += this.mItem('item_'+i+'',this.o.item(i));
   }
   return r;
  }
  //**************************//
  function pula(o) {
   var ds;
   if (o.substring(0,5)=='item_') {
    ds = this.o.item(1*o.substring(6));
   } else {
    ds = this.o[o];
   }
   objNav(ds);
  }
  //**************************//
  function init(o) {
   var r = '<html><head><title>'
    +(typeof(o.name)=='undefined'?'':o.name+' ')+o+' - objNav </title></head>'
   +'<script language="JavaScript" '
   +'src="/js/jan.js"></script>'
   +'<body><table border=1><tr><td>'
   +'<font size=3>Objeto: <font color=red>'+o
   +'<tr><td id=dad>'
   +'</table>'
   +'<scr'+''+'ipt>var este1;'
   +' function objNavInit() {'
   //+'  alert("teste o"+este);'
   +'  este.mostra();'
   //+'  este=new objNav();'
   //+'  //alert(objNav);'
   +' }'
   +' setTimeout("objNavInit();",1000);'
   +'</scr'+''+'ipt>'
   +'</body>'
   +'</html>'
   ;
   //alert('objnav: ');
   //alert(objNav);
   //objA(window.document.objNav);
   var w = window.open('about:blank','_blank',
   'width=600,height=700,resizable=yes,scrollbars=yes,status=1'
   );
   try {
    w.document.write(r);
    //w.objNav = objNav;
    //objNavAlvo = o;
    //var zzz;
    w.este = new objNav(o,w);
   } catch (e) {
    objA(e);
   }
  }
  //**************************//
  function filtrar(f) {
   if (typeof(f)!='string') {
    alert('filtro por chave');
    return;
   }
   this.filtro = f;
   this.mostra();
  }
  //**************************//
  function mostra() {
   this.tp = new Array;
   var o = this.o;
   var filtro = this.filtro;
   var i=0,z;
   var r = '';
   for(var prop in o) {
    try {
     z = o[prop];
     //z = objNavR(prop);
     //z = eval('este.o.'+prop);
    } catch (e) {
     z = '?erro:'+e;
     //objA(o);
     //alertErro(e);
     //break;
    }
    r += this.mItem(prop,z);
    i++;
    if (i>200) break;
   }
   //mostra totais por tipo
   var r1 = '<tr><td colspan=2><b>'+i
   +' (limite 200) </b>';
   r1 += '(<b><a href=javascript:este.filtrar("");>'
   +'Todos</a></b>='+i+') ';
   for(var prop in this.tp) {
    var z = this.tp[prop];
    r1 += '(<b><a href=javascript:este.filtrar("'+prop+'");>'
    +prop+'</a></b>='+z+') ';
   }
   r1 += '<br><b>Chave</b>: '
   +'<input size=10 onChange=este.filtrar(this)>';
   r = '<table border=1>'+r1+r+'</table>FIM...';
   //var w = window.open('about:blank','_blank',
   // 'width=400,height=700,resizable=yes,scrollbars=yes,status=0'
   //);
   //w.document.write(r);
   var ds=browse.getId('dad',this.jan.document);
   ds.innerHTML = r;
   
   return r;
  }
 }
 //**************************//
 function objA(o,filtro) {
  var r = '';
  var i=0,tp=new Array(),z;
  for(var prop in o) {
   try {
    z = o[prop];
   } catch (e) {
    z = '?erro:'+e;
   }
   var t = typeof(z);
   if (!tp[t]) tp[t] = 0;
   tp[t]++;
   if (!filtro || t==filtro) {
    r += ''+t.substring(0,2)+': '
    +prop+' = '+z+'\n';
   }
   i++;
   if (i>200) break;
  }
  alert(r);
 }
 //**************************//
 function obj(o,filtro) {
  var r = '<html><body><table border=1>';
  var i=0,tp=new Array(),z;
  
  for(var prop in o) {
   try {
    z = o[prop];
   } catch (e) {
    z = '?erro:'+e;
   }
   var t = typeof(z);
   if (!tp[t]) tp[t] = 0;
   tp[t]++;
   if (!filtro || t==filtro) {
    r += '<tr><td>'+t.substring(0,2)+': '
    +prop+'<td>'+(t=='string'?html(''+z):z);
   }
   i++;
   if (i>200) break;
  }
  r += "<tr><td>Total (limite 200)<td>"+i
  +'<tr><td><b>Tipos:</b><td>';
  for(var prop in tp) {
   var z = tp[prop];
   r += '(<b>'+prop+'</b>='+z+') ';
  }
  r += '</table>';
  var w = window.open('about:blank','_blank',
  'width=400,height=700,resizable=yes,scrollbars=yes,status=0'
  );
  w.document.write(r+'</body></html>');
  
  return r;
 }
//fim func DEBUG

//**************************//
// menu POPUP
//**************************//
var menuPopUpAberto = false;
//**************************//
function menuPopUp(nome,tit,vOp,ops,est) {
 this.aberto = false;
 if (''+ops=='undefined') {
  ops = '';
 }
 this.evento = true;
 this.posEsq = 0;
 this.incX = 0;
 this.incY = 0;
 this.ops = ops;
 this.nome = nome;
 this.tit = tit;
 this.fecha = menuPopUp_fecha;
 this.abre = menuPopUp_abre;
 this.click = menuPopUp_click;
 this.click1 = menuPopUp_click1;
 this.vat = new Array;
 if (typeof(est)=='undefined') {
  est = 'menPop';
 }
 if (""+vOp=="undefined") {
  return;
 }
 //cria divisão conforme array
 document.write(
 '<DIV ID="'+this.nome+'" class='+est
 +' STYLE="POSITION: absolute; VISIBILITY: hidden; TOP: 0px; LEFT: 0px;">'
 +'<table class='+est+'>');
 var i = 'onclick='+this.nome+'.fecha(event);>';
 if (ops.indexOf('/nnova')==-1) {
  document.write('<tr><td class='+est+'Tit '+i+this.tit
  +'<td class='+est+'Fecha '+i
  +'x');
 } else {
  document.write('<tr><td class='+est+'Tit '+i+this.tit);
 }
 for (var i=0;i<vOp.length;i++) {
  var op = vOp[i];
  var ps;
  if ((ps=op.indexOf("~~"))!=-1) {
   this.vat[i] = op.substring(ps+2);
   op = op.substring(0,ps);
  } else {
   this.vat[i] = op;
  }
  if (op=='-') {
   document.write('<tr><td class='+est+'Sp>');
  } else {
   var oc = ' onClick=javascript:'+this.nome+'.click('+i;
   document.write('<tr><td class='+est+oc+',false,event)>'
    +'&nbsp;<a class='+est+'>'+op+'</a>'
    +(ops.indexOf('/nnova')==-1?
    '<td class='+est+'N '+oc+',true,event)>'
    +'<a class='+est+'N>+</a>'
    :'')
   );
  }
 }
 document.write('</table></DIV>');
 //**************************//
 function menuPopUp_click(pos,nova,ev) {
  if (ev.ctrlKey) {
   return;
  }
  this.fecha();
  //alert('pos='+pos+' param='+this.param+" nova="+nova);
  var a = this.vat[pos],i;
  //alert('1='+a);
  if ((i=a.indexOf("{cod}"))!=-1) {
   a = a.substring(a,i)+this.param+a.substring(i+5);
  } else {
   a += this.param;
  }
  this.click1(a,nova);
 }
 //**************************//
 function menuPopUp_click1(a,nova) {
  if (nova) {
   window.open(a,"_blank");
  } else {
   window.location = a;
  }
 }
 //**************************//
 function menuPopUp_fecha(ev) {
  if (typeof(ev)!='undefined' && ev.ctrlKey) {
   return;
  }
  menuPopUpAberto = false;
  this.aberto = false;
  browse.esconde(browse.getId(this.nome),false);
 }
 //**************************//
 function menuPopUp_abre(ob,pr,ev) {
  if (this.aberto) {
   this.fecha();
   return;
  }
  menuPopUpAberto = true;
  this.aberto = true;
  this.param = pr;
  var o = browse.getId(this.nome);
  var tx = browse.getTX(ob);
  var x,y;
  x = browse.getAbsX(ob)+((tx==-1)?30:tx);
  if (this.posEsq!=0) {
   x -= browse.getTX(o)+tx-30;
  }
  y = browse.getAbsY(ob)+browse.getTY(ob);
  if (!vazio(ev) && this.evento) {
   var xx = browse.eventoX(ev);
   if (xx!=-1) x = xx;
   xx = browse.eventoY(ev);
   if (xx!=-1) y = xx;
  }
  if (this.centrado) {
   //alert(browse.getTX(ob));
   x -= browse.getTX(o)/2+browse.getTX(ob)/2;
  }
  if (this.acima) {
   y -= browse.getTY(o);
  }
  browse.setX(o,x+this.incX);
  browse.setY(o,y+this.incY);
  browse.mostra(o,false);
 }
}

 
//**************************//
//**************************//
var browse = new mznsie();
//**************************//
//**************************//
function mznsie() {
 this.NS6 = false;
 this.NS4 = false;
 this.IE4 = false;
 //alert(navigator.appName+'\n'+navigator.appVersion);
 if (document.getElementById && !document.all) {
  this.NS6 = true;
  this.nav = "NS6";
 } else {
  if (document.layers) {
   this.NS4 = true;
   this.nav = "NS4";
  } else {
   if (document.all) {
    this.IE4 = true;
    this.nav = "IE4";
    this.IE6 = navigator.appVersion.indexOf('MSIE 6')!=-1;
   }
  }
 }
 this.ie = this.IE4;
 this.ie6 = document.documentElement &&
  ( document.documentElement.clientWidth 
  || document.documentElement.clientHeight)
 ;
 this.moz = this.IE6;	
 
 var x = new Array("getId","mostra","esconde","getAbsX","getAbsY"
 ,"setX","setY","getX","getY","getTX","getTY","getDocFrame"
 ,"visivel","eventoX","eventoY","tamWinX","tamWinY","cssRules");
 for (var i=0;i<x.length;i++) {
  this[x[i]] = eval('obj_'+x[i]+this.nav);
 }
 //alert("obj criado"+this);
 //alert("obj criado"+this.getId);
 
 //**************************//
 //campos uso geral
 //**************************//
 this.MostraEsconde = obj_MostraEsconde;
 
 function obj_MostraEsconde(id) {
  var o = this.getId(id);
  if (this.visivel(o)) {
   this.esconde(o);
  } else {
   this.mostra(o);
  }
 }
 //**************************//
 function obj_cssRulesNS6(o) {
  return o.cssRules;
 }
 function obj_cssRulesIE4(o) {
  return o.rules;
 }
 //**************************//
 function obj_tamWinXNS6(o) {
  if (vazio(o)) {
   o = window;
  }
  return o.outerWidth;
 }
 function obj_tamWinXIE4(o) {
  if (vazio(o)) {
   o = window;
  }
  if (this.ie6) {
   return document.documentElement.clientWidth;
  } else {
   return o.screen.availWidth;
  }
  //return o.document.body.offsetWidth;
 }
 //**************************//
 function obj_tamWinYNS6(o) {
  if (vazio(o)) {
   o = window;
  }
  return o.outerHeight;
 }
 function obj_tamWinYIE4(o) {
  if (vazio(o)) {
   o = window;
  }
  if (this.ie6) {
   return document.documentElement.clientHeight;
  } else {
   return o.screen.availHeight;
  }
 }
 //**************************//
 function obj_eventoYNS6(o) {
  //alert(o.offsetWidth);
  return o.layerY;
 }
 function obj_eventoYNS4(o) {
  return o.y;
 }
 function obj_eventoYIE4(o) {
  //alert(o.offsetWidth);
  //return o.clientY+o.offsetY;
  //return o.screenY+o.offsetY;
  return -1;
 }
 //**************************//
 function obj_eventoXNS6(o) {
  //alert(o.offsetWidth);
  return o.layerX;
 }
 function obj_eventoXNS4(o) {
  return o.x;
 }
 function obj_eventoXIE4(o) {
  //alert(o.offsetWidth);
  //return o.clientX+o.offsetX;
  //return o.screenX+o.offsetX;
  return o.clientX;
  return -1;
 }
 //**************************//
 function obj_getTXNS6(o) {
  //alert(o.offsetWidth);
  return o.offsetWidth;
 }
 function obj_getTXNS4(o) {
  return -1;
 }
 function obj_getTXIE4(o) {
  //alert(o.offsetWidth);
  return o.offsetWidth;
 }
 //**************************//
 function obj_getTYNS6(o) {
  return o.offsetHeight;
 }
 function obj_getTYNS4(o) {
  return -1;
 }
 function obj_getTYIE4(o) {
  return o.offsetHeight;
 }
 //**************************//
 function obj_getIdNS6(id,ob) {
  if (typeof(ob)=='undefined') ob = document;
  return ob.getElementById(id);
 }
 function obj_getIdNS4(id) {
  var r = document.layers[id];
  return r;
 }
 function obj_getIdIE4(id,ob) {
  if (typeof(ob)=='undefined') ob = document;
  return ob.all[id];
 }
 
 //**************************//
 function obj_getXNS6(o) {
  return o.style.left;
 }
 function obj_getXNS4(o) {
  return o.x;
 }
 function obj_getXIE4(o) {
  return o.style.pixelLeft;
 }
 //**************************//
 function obj_getYNS6(o) {
  return o.style.top;
 }
 function obj_getYNS4(o) {
  return o.y;
 }
 function obj_getYIE4(o) {
  return o.style.pixelTop;
 }
 //**************************//
 function obj_setXNS6(o,p) {
  o.style.left = p+'px';
 }
 function obj_setXNS4(o,p) {
  o.x = p;
 }
 function obj_setXIE4(o,p) {
  o.style.pixelLeft = p;//+'px';
 }
 //**************************//
 function obj_setYNS6(o,p) {
  o.style.top = p+'px';
 }
 function obj_setYNS4(o,p) {
  o.y = p;
 }
 function obj_setYIE4(o,p) {
  o.style.pixelTop = p; //+'px';
 }
 //**************************//
 function obj_visivelNS6(o) {
  return o.style.visibility == "visible";
 }
 function obj_visivelNS4(o) {
  return o.visibility == "show";
 }
 function obj_visivelIE4(o) {
  return o.style.visibility == "visible";
 }
 //**************************//
 function obj_mostraNS6(o,b) {
  o.style.visibility = "visible";
  if (''+b=='undefined') o.style.display = '';
 }
 function obj_mostraNS4(o) {
  o.visibility = "show";
 }
 function obj_mostraIE4(o,b) {
  o.style.visibility = "visible";
  if (''+b=='undefined') o.style.display = '';
 }
 //**************************//
 function obj_escondeNS6(o,b) {
  o.style.visibility = "hidden";
  if (''+b=='undefined') o.style.display = 'none';
 }
 function obj_escondeNS4(o,b) {
  o.visibility = "hide";
 }
 function obj_escondeIE4(o,b) {
  o.style.visibility = "hidden";
  
  if (''+b=='undefined') o.style.display = 'none';
 }
 //**************************//
 function obj_getAbsXNS6(o) {
  var a=o.offsetParent;
  if ((""+a).substring(0,4)=="[obj") {
   // & (""+a).indexOf("HTMLBodyElement")==-1) 
   //rr += "* "+a;
   return o.offsetLeft + obj_getAbsXNS6(a);
  } else {
   return o.offsetLeft;
  }
 }
 function obj_getAbsXNS4(o) {
  return o.x;
 }
 function obj_getAbsXIE4(o) {
  var a=o.offsetParent;
  if ((""+a).substring(0,4)=="[obj") {
   return o.offsetLeft + obj_getAbsXIE4(a);
  } else {
   return o.offsetLeft;
  }
 }
 //**************************//
 function obj_getDocFrameNS6(o) {
  return o.contentDocument;
 }
 //**************************//
 function obj_getDocFrameNS4(o) {
  alert("nao sei getDocFrameNS4");
  return o.contentDocument;
 }
 //**************************//
 function obj_getDocFrameIE4(o) {
  //alert("nao sei getDocFrameIE4"+obj(o.ownerDocument));
  return o.ownerDocument;
 }
 //**************************//
 function obj_getAbsYNS6(o) {
  var a=o.offsetParent;
  if ((""+a).substring(0,4)=="[obj") {
   return o.offsetTop + obj_getAbsYNS6(a);
  } else {
   return o.offsetTop;
  }
 }
 function obj_getAbsYNS4(o) {
  return o.y;
 }
 function obj_getAbsYIE4(o) {
  return obj_getAbsYNS6(o);
 }
}

//*******************************//
// BIBLIOTECA
//*******************************//
//*******************************//
 //*******************************//
 function desviaSeTag(url,tag,ev) {
  if (ev.ctrlKey) {
   return;
  }
  var e = targetEvent(ev);
  //objNav(ev);
  if (e.tagName.toLowerCase()==tag.toLowerCase()) {
   window.location = url;
  } else {
   //alert(tag+' <> '+e.tagName);
  }
 }
 //*********************************
 function targetEvent(ev) {
  var v = Array('target','srcElement','originalTarget','currentTarget',
  'explicitOriginalTarget','relatedTarget');
  //localiza obj destino
  for (var i=0;i<v.length;i++) {
   var o = ev[v[i]];
   if (o!=null) {
    try {
     //var r = o.tagName;
     return o;
    } catch (e) {
    }
   }
  }
  return null;
 }
 //*************************************
 //não é necessário, javascript tem função embutida
 function sort(m,p,inv,lo0,hi0) {
  var lo = typeof(lo0)=='undefined'?0:lo0;
  var hi = typeof(hi0)=='undefined'?m.length-1:hi0;
  /*if (typeof(lo0)=='undefined') {
   alert('lo='+lo+' hi='+hi);
   sortNT=-1;
  }
  */
  lo0=lo;hi0=hi;
  var v;
  if ( hi0 > lo0) {
   v = m[ inteiro(( lo0 + hi0 ) / 2) ][p];
   while( lo <= hi ) {
    if (inv) {
     while( lo<hi0 && v > m[lo][p] ) ++lo;
     while( hi>lo0 && v < m[hi][p] ) --hi;
    } else {
     while( lo<hi0 && v < m[lo][p] ) ++lo;
     while( hi>lo0 && v > m[hi][p] ) --hi;
    }
    if( lo <= hi ) {
     //sortNT++;
     v = m[lo];
     m[lo] = m[hi];
     m[hi] = v;
     ++lo;
     --hi;
    }
   }
   if( lo0 < hi )
    sort(m,p,inv,lo0,hi);
    if( lo < hi0 )
     sort(m,p,inv,lo,hi0);
  }
 }
 //**************************//
 function horarioVerao() {
  var di = new Date(1950,0,1);
  var df = new Date(2030,11,31);
  var mDia = 1000*60*60*24;
  var h;
  document.write('<hr><b>Horário de Verão</b><hr>');
  while (di<df) {
   di = new Date(di.getTime()+mDia);
   h = di.getHours();
   if (h!=0) {
    document.write(di+' horas: '
    +(24+(h>12?24-h:-h))+'<br>');
    di = new Date(di.getTime()+(h>12?24-h:-h)*60*60*1000);
   }
  }
  document.write("<hr>fim<hr>");
 }
 //**************************//
 function arrayToTab(a) {
  var r = '<table border=1>';
  for (var i=0;i<a.length;i++) {
   r += '<tr><td>'+i+'<td>'+html(a[i]);
  }
  r += '</table>';
  return r;
 }
 //**************************//
 function html(a) {
  return troca(troca(a,'<','&lt;'),'>','&gt;');
 }
 //**************************//
 function objLen(o){
  var i=0;
  for(var prop in o) {
   i++;
  }
  return i;
 }
 //*******************************//
 function vazio(a) {
  if (typeof(a)=='object') {
   return objLen(a)==0;
  } else {
   return nulo(a) || a=='' || (typeof(a)=='string' && trimm(a)=='');
  }
 }
 //*******************************//
 function nulo(a) {
  return (a==null || typeof(a)=='undefined');
 }
 //**************************//
 //funções data
 //**************************//
 var tb_diaSemana = palavraA('Dom,Seg,Ter,Qua,Qui,Sex,Sab',',');
 var tb_nomeMes = palavraA('Janeiro,Fevereiro,Março,Abril,Maio,Junho,'+
 'Julho,Agosto,Setembro,Outubro,Novembro,Dezembro',',');
 //**************************//
 function duracao(d) {
  var v = palavraA(d,':');
  if (v.length==2) {
   //hh:mm
   return 1000*60*60*v[0]+1000*60*v[1];
  } else {
   //dias:hh:mm
   return 1000*60*60*24*v[0]+1000*60*60*v[1]+1000*60*v[2];
  }
 }
 //**************************//
 function ms() {
  return (new Date()).getTime();
 }
 //**************************//
 function dataHHMM(d) {
  if (typeof(d)=='number') {
   d = new Date(d);
  }
  var h = ''+d;
  var p = h.indexOf(':');
  return h.substring(p-2,p+3);
 }
 //**************************//
 var dataDia = 1000*60*60*24;
 //**************************//
 function iDia(d) {
  var h = d.getHours();
  if (h!=0 && h<12) {
   d = new Date(d.getTime()+(h>12?24-h:-h)*60*60*1000);
  }
  d = new Date(d.getTime()+24*60*60*1000);
  h = d.getHours();
  if (h>12) {
   d = new Date(d.getTime()+(h>12?24-h:-h)*60*60*1000);
  }
  return d;
 }
 //**************************//
 function dataLocal(o) {
  var a,m,d;
  if (typeof(o)=='number') {
   o = new Date(o);
  }
  if (typeof(o)=='object') {
   a = takeYear(o);
   m = strZero(o.getMonth()+1,2);
   d = strZero(o.getDate(),2);
  } else if (o.indexOf('-')!=-1) {
   var v = palavraA(leftAt(o,' '),'-');
   a = v[0];
   m = v[1];
   d = v[2];
  } else {
   alert('dataLocal(o): não reconheci a data: '+o);
  }
  return d+'/'+m+'/'+a;
 }
 //**************************//
 function dataTempo(msegs) {
  return ((new Date()).getTime()) - msegs;	
 }
 //**************************//
 function dataNomeMes(dat) {
  return tb_nomeMes[dat.getMonth()];
 }
 //**************************//
 function dataDiaSemana(dat) {
  return tb_diaSemana[dat.getDay()];
 }
 //**************************//
 function dataSqlData(str) {
  //2001-01-03 00:00:00
  //0123456789012345678
  var d = new Date(str.substring(0,4),
  str.substring(5,7)-1,
  str.substring(8,10)
  );
  if (str.length>10) {
   d.setHours(str.substring(11,13));
   d.setMinutes(str.substring(14,16));
   d.setSeconds(str.substring(17,19));
  }
  return d;
 }
 //**************************//
 function dataSql(a) {
  //getDay = dia semana.
  var d = new Date(a);
  return takeYear(d)+'-'+strZero(d.getMonth()+1,2)
  +'-'+strZero(d.getDate(),2)+' '
  +strZero(d.getHours(),2)+':'
  +strZero(d.getMinutes(),2)+':'+strZero(d.getSeconds(),2);
 }
 //**************************//
 function takeYear(theDate) {
  x = theDate.getYear();
  var y = x % 100;
  y += (y < 38) ? 2000 : 1900;
  return y;
 }
 //**************************//
 function strZero(nr,t) {
  return right('0000000000'+nr,t);
 }
 
 //**************************//
 //funções string
 //**************************//
 //*****************************************//
 function charAlfaNum(a) {
  return charNum(a) || charAlfa(a);
 }
 //*****************************************//
 function charNum(a) {
  return (a>='0' && a<='9');
 }
 //*****************************************//
 function charAlfa(a) {
  return (a>='a' && a<='z') || (a>='A' && a<='Z');
 }
 //*****************************************//
 function charEmail(a) {
  return charNum(a) ||
  charAlfa(a) || 
  ".@-_".indexOf(a)!=-1;
 }
 //*****************************************//
 function emailValido(a) {
  var p = a.indexOf('@');
  if (p<1 || p>a.length-3) return false;
  for (var i=0;i<a.length;i++) {
   if (!charEmail(a.substring(i,i+1))) {
    return false;
   }
  }
  if (a.indexOf('.@')!=-1 || a.indexOf('@.')!=-1 || a.indexOf('..')!=-1) return false;
  //alert(a.substring(p-1,p)+'==='+a.substring(p+1,p+2));
  if (!charAlfaNum(a.substring(p-1,p)) || !charAlfaNum(a.substring(p+1,p+2)) ||
   a.substring(p).indexOf('.')==-1) return false;
   return true;
 }
 //**************************//
 function leftAt(s,s1) {
  var p = s.indexOf(s1);
  if (p==-1) {
   return s;
  }
  return s.substring(0,p);
 }
 //*****************************************
 function substrRat(g,a) {
  var i = g.lastIndexOf(a);
  if (i<0) return g;
  return g.substring(i);
 }
 //*****************************************
 function leftRat(g,a) {
  var i = g.lastIndexOf(a);
  if (i<0) return g;
  return g.substring(0,i);
 }
 //*****************************************
 function substrAtAt(g,a,b) {
  return leftAt(substrAt(g,a),b);
 }
 //*****************************************
 function substrAt(g,a) {
  var i = g.indexOf(a);
  if (i<0) return g;
  return g.substring(i+a.length);
 }
 //**************************************
 function indexMin(a,b) {
  var r=a.length+99,t;
  for (var i=0;i<b.length;i++) {
   if ((t=a.indexOf(b.substring(i,i+1)))!=-1) {
    r = min(r,t);
   }
  }
  if (r>a.length) r = -1;
  return r;
 }
 //**************************************
 function trimm(a,b) {
  var i,t;
  if (typeof(a)=='undefined') {
   return '';
  }
  if (typeof(b)=='undefined') {
   b = ' \n\r\t';
  }
  //retira do inicio
  t = a.length-1;
  if (t<0) return a;
  i = 0;
  while (i<t & b.indexOf(a.substring(i,i+1))>-1) i++;
  if (i!=0) a = a.substring(i,t+1);
  //retira do fim
  t = a.length;
  if (t<1) return a;
  i = t-1;
  while (i>-1 && b.indexOf(a.substring(i,i+1))>-1) i--;
  if (i!=t-1) a = a.substring(0,i+1);
  return a;
 }
 //**************************//
 function right(s,t) {
  return s.substring(s.length-t,s.length);
 }
 //**************************//
 function enderecoTempo(url) {
  return url + (url.indexOf('?')==-1?'?':'&')+'_tm_='+(new Date()).getTime();
 }
 //**************************//
 function palavraA(tx,a,b) {
  var r = new Array,p;
  while ((p=tx.indexOf(a))!=-1) {
   r[r.length] = tx.substring(0,p);
   tx = tx.substring(p+a.length);
  }
  r[r.length] = tx;
  if (nulo(b)) {
   return r;
  }
  for (var i=0;i<r.length;i++) {
   r[i] = palavraA(r[i],b);
  }
  return r;
 }
 //**************************//
 function paramGet(doc) {
  var url=''+doc.location;
  //alert(url);
  var p = url.indexOf('?');
  if (p==-1) {
   //alert('vet vazio='+p);
   return new Array;
  }
  url = url.substring(p+1);
  //alert(url);
  var v = palavraA(url,'&');
  var r = new Array,c;
  for (var i=0;i<v.length;i++) {
   c = palavraA(v[i]+'=','=');
   r[c[0]] = c[1];
  }
  return r;
 }
 //**********************
 function trocaTudo(g,a,b) {
  while (g.indexOf(a)!=-1) {
   g = troca(g,a,b);
  }
  return g;
 }
 //**********************
 function troca(g,a,b) {
  var i=0,p,ta,tb;
  
  ta = a.length;
  tb = b.length;
  
  while ( (p = g.indexOf(a,i)) > -1 )  {
   g = g.substring(0,p)+b+g.substring(p+ta);
   //,g.length
   i = p - ta + tb + 1;
  }
  
  return g;
 }
 //**************************
 //funções num
 //**************************
 function toNum(a) {
  //converte numero formato brasil para interno
  if (a.indexOf('.')!=-1) {
   a = troca(a,'.','');
  }
  if (a.indexOf(',')!=-1) {
   a = troca(a,',','.');
  }
  return a;
 }
 //**************************
 function numMilhar(nro) {
  var n = ''+nro;
  var t = n.length;
  var r = '';
  for (var i=t;i>0;i -= 3) {
   r = n.substring(i-3,i)+(r==''?'':'.'+r);
  }
  return r;
 }
 //**************************//
 function inteiroBase16(nro) {
  var tb='0123456789ABCDEF';
  var r = '"\\'+(tb.indexOf(nro.substring(0,1))*16+tb.indexOf(nro.substring(1,2)))+'"';
  return eval(r);
 }
 //**************************//
 function rand(nro) {
  return inteiro(Math.random()*nro);
 }
 //*******************************//
 function format(v,d) {
  var v1='',v2='',i,vr='';
  
  v = ''+v;
  i = v.indexOf('.');
  if (i<0) {
   v1 = v;
  } else {
   v1 = v.substring(0,i);
   v2 = v.substring(i+1,999);
  }
  
  v1 = '000000000000000000'.substring(0,18-v1.length)+v1;
  vr = v1.substring(0,3);
  for (i=3;i<18;i+=3) {
   vr += '.'+v1.substring(i,i+3);
  }
  
  while (vr.length>1 && '0.'.indexOf(vr.substring(0,1))>-1) 
   vr = vr.substring(1,vr.length);
   
   return vr+((d==0)?'':','+(v2+'0000000').substring(0,d))
 }
 //**************************//
 function inteiro(nm) {
  if ((''+nm).indexOf('.')==-1) return nm;
  //nm += 0.5;
  nm = ''+nm;
  return 1*(nm.substring(0,nm.indexOf('.')));
 }
 //**************************//
 function segs() {
  return (new Date()).getTime();
 }
 //**************************//
 function min(a,b) {
  return (a>b?b:a);
 }
 //**************************//
 function max(a,b) {
  return (a<b?b:a);
 }
 //**************************//
 function fixDec(vlr,dec) {
  vlr = ''+vlr;
  var i;
  if ((i=vlr.indexOf('.'))==-1) {
   return vlr;
  } else {
   return (vlr+'0000').substring(0,i+dec+1);
  }
 }
 //**************************//
 function hexRgb(r,g,b) {
  return ''+hex1(r)+''+hex1(g)+''+hex1(b);
 }
 //**************************//
 function hex1(c) {
  if (c==256) return 'FF';
  while (c<0) c += 256;
  while (c>256) c -= 256;
  return ''+hex0(Math.floor(c / 16))+''+hex0(c % 16);
 }
 //**************************//
 function hex0(n) {
  return "0123456789ABCDEF".substring(n,n+1);
 }
//FIM BIBLIOTECA

