function popup(ende,wi,he){ window.open (ende,'popups','toolbar=yes,location=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes,width='+wi+',height='+he+'');}

function help(ende){ window.open (getContexto()+ende,'ajuda','toolbar=no,location=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes,width=650,height=450');}

function prt(ende){ window.open (ende,'','toolbar=no,location=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes,width=660,height=480');}

function lista(ende){ window.open (ende,'Lista','toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width=360,height=280');}
function listaMd(wi,he,ende){ window.open (ende,'Lista','toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width='+wi+',height='+he+'');}

function calendario(ende){ window.open (ende,'Calendario','toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width=290,height=270');}

function imagem(ende){ window.open (ende,'Imagem','toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width=670,height=500');}

function galFotos(ende){ window.open (ende,'','resizable=no,scrollbars=no,status=yes,width=680,height=500');}



//----------------------------

function focusPrimeiroCampo(){
    var form = document.forms[0];
    if (form != null ) {
      for (var i = 0; i < form.elements.length; i++){
          if ((form.elements[i].tagName == "TEXTAREA") ||
              (form.elements[i].tagName == "SELECT") ||
                                        (form.elements[i].tagName == "INPUT" && (form.elements[i].type == "text" ||
                                        form.elements[i].type == "password")) ) {
              form.elements[i].focus();
              return;
          }
      }
    }
}
	

function teste(){
    var form = document.forms[0];
    for (var i = 0; i < form.elements.length; i++){
        if (form.elements[i].tagName == "TEXTAREA"){
            form.elements[i].value='0';
        }else if(form.elements[i].type == "text"){
            form.elements[i].value='0';
        }else if(document.forms[0].elements[i].type == "radio"){
            form.elements[i].checked=true;
        }
   }
}
function passaProx(atual,prox){
    if (atual.value.length>=atual.maxLength)
       prox.focus();
}

//-----------------------------

function isNum(key){if((key<48)||(key>57)||(key==32)) if(key!=13) return false } 

//-----------------------------
//javascript das relações
function sbtRelacao(iframeDe){
     if ( window.frames[iframeDe] )
        if (gerenciadorCheckbox(window.frames[iframeDe].document.forms[0].codigos,true,false))
           window.frames[iframeDe].document.forms[0].submit();
}

function rfRelacao(iframe){
    if (window.top.frames[iframe]){
       gerenciadorCheckbox(window.top.frames[iframe].document.forms[0].codigos,false,false)
       window.top.frames[iframe].document.forms[0].submit();
    }
}

function marcar(iframe,tipo){
     if ( window.frames[iframe] )
        gerenciadorCheckbox(window.frames[iframe].document.forms[0].codigos,false,tipo);
}

function gerenciadorCheckbox(c,verificador,marcador){
    if (c!=null)
       if (!verificador){
           if(c.length !=null){
               for (var i=0; i<c.length;i++)
                   c[i].checked = marcador;
           }else c.checked = marcador;
       }else{
           var tem = false;
           if(c.length !=null){
               for (var i=0; i<c.length;i++) {
                   if (c[i].checked ){
                      tem = true;
                      break;
                   }
               }
           }else if (c.checked) tem = true;
           return tem;
       }
    return false;
}




//----------------------------

function mostrar(LayerID)
  {
//	  if (document.all)
//	  {
		  if (document.getElementById(LayerID).style.display == '')
		  {
			  document.getElementById(LayerID).style.display = 'none';
			}
		  else
		  {
			  document.getElementById(LayerID).style.display = '';
			}
//		}
	}



function IsData(dia, mes, ano) { // usar Janeiro=1
    hoje=new Date();
    entrada=new Date(ano,mes-1,dia);
    if (entrada>hoje) return false;
    timeA = new Date(ano, mes, 1);
    timeB = new Date(timeA - 86400000);
    if (dia>timeB.getDate()) return false;
    return true;
}


function round(x,n) {
   if(n==null) n=0;
   return Math.round(x*Math.pow(10,n))/Math.pow(10,n);
}



 //---------------------------

function maismenos(btn,frm,tipo,qtde){
    btn.disabled = true;
    frm.qtde.value = qtde + tipo;
    frm.action += '?anula='+ tipo;
    frm.submit();
}

function mostraBtn(){
    document.getElementById('aguarde').style.display = 'none';
    document.getElementById('btns').style.display = '';
}

 //---------------------------

function mOco(id,qstr){
    mostrar('o'+id);
    var o = document.getElementById('ft'+id);
    if (o!=null)
       if (o.src!=(qstr))
          o.src = qstr;
}


function getValorCampo( campo ){
    if (campo!=null){
        if( campo.tagName == "SELECT" ){
            return campo.options[campo.selectedIndex].value;
        }else if(campo.length!=null){
            for (var i=0; i<campo.length;i++) {
               if (campo[i].checked ){
                   return campo[i].value;
               }
            }
        }else{
            return campo.value;
        }
    }
    return "";
}


function loadCidade(estadouf){
	ajaxHTML('dv_cidade','ajax/dv_cidade.jsp?uf='+estadouf);
}

function mudaBotao(){
	document.getElementById('original').style.display='none';
	document.getElementById('enviando').style.display='';
}


