


function PopUp(url){
  window.open(url,'','width=720,height=480,resizable=no,maximized=no,scrollbars=yes,status=yes,left=20,top=20');
  return false;
}

function PopUpProcura(url){
  window.open(url,'','width=480,height=300,resizable=no,maximized=no,scrollbars=yes,status=yes,left=20,top=20');
  return false;
}

function PopUpSmall(url){
 window.open(url,'','width=120,height=300,resizable=no,maximized=no,scrollbars=yes,status=no,left=20,top=20');
  return false;
}

function PopUpUpload(url){
  window.open(url,'','width=380,height=200,resizable=no,maximized=no,scrollbars=yes,status=yes,left=20,top=20');
  return false;
}

function FormataData(evento,Campo){
  if(((evento.keyCode<35)||(evento.keyCode>40))&&(evento.keyCode!=46)&&(evento.keyCode!=8)&&(evento.keyCode!=9)){
    tam=Campo.value.length;
    str='';
    for(x=0;x<=tam;x++){
      if(Campo.value.substring(x,x+1) != "/"){
        str+=Campo.value.substring(x,x+1);
      }
    }
    aux=str.substring(0,2);
    if(str.length>1)aux=aux+"/";
    aux=aux+str.substring(2,4);
    if(str.length>3)aux=aux+"/";
    Campo.value=aux+str.substring(4,8);
  }
}

function FormataHora(evento,Campo){
  if(((evento.keyCode<35)||(evento.keyCode>40))&&(evento.keyCode!=46)&&(evento.keyCode!=8)&&(evento.keyCode!=9)){
    tam=Campo.value.length;
    str='';
    for(x=0;x<=tam;x++){
      if(Campo.value.substring(x,x+1) != ":"){
        str+=Campo.value.substring(x,x+1);
      }
    }
    aux=str.substring(0,2);
    if(str.length>1)aux=aux+":";
    Campo.value=aux+str.substring(2,4);
  }
}

function FormataFloat(evento,Campo){
  if(((evento.keyCode<35)||(evento.keyCode>40))&&(evento.keyCode!=46)&&(evento.keyCode!=8)&&(evento.keyCode!=9)){
    str=Campo.value.replace(',','');
    tam=str.length;
    if(tam>1 && tam<Campo.maxLength){
      if(tam==2){
        Campo.value = str.substring(0,1)+','+str.substring(1,2);
        tam = 0;
      }else if(tam==3 && tam!=0){
        Campo.value = str.substring(0,1)+','+str.substring(1,3);
        tam = 0;
      }else if(tam>3 && tam!=0){
        Campo.value = str.substring(0,tam - 2)+','+str.substring(tam - 2,tam);
        tam = 0;
      }
    }
  }
}

function Numero(evento){
  if((evento.keyCode < 48) || (evento.keyCode > 57)){
    evento.cancelBubble=false;
//    return false;
  }
}

// busca por um elemento passado por parametro.
function BackLink(id,nome,cod_nome){
  var campo;
  var div;
  
  div=opener.document.getElementById("carrega_"+id);
  campo=opener.document.getElementById(id);

  if(campo!=null){
    campo.value=cod_nome;
  }
  if(div!=null){
    div.innerHTML=nome;
  }
} 

