function Ajusta(altura,ifmeio) {
	parent.document.getElementById('ifmeio').height = altura;
	//parent.document.getElementById('ifbemvindo').style.display = iframe_bemvindo;
}

//-------------------------------
function isDigit (c){  
   return ((c >= "0") && (c <= "9"))
}  

//-------------------------------
function isInteger (s) {
    var i;
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return false;
     
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }
    return true;
}

//-------------------------------
function isEmpty(s){
    return ((s == null) || (s.length == 0))
}

//-------------------------------
// isIntegerInRange (STRING s, INTEGER a, INTEGER b [, BOOLEAN emptyOK])
// 
// isIntegerInRange = true se s &eacute; inteiro dentro dos limites, inclusive
// 
// emptyOK se for opcional deve ser true
function isIntegerInRange (s, a, b){
   if (isEmpty(s)) return false;
    if (!isInteger(s)) return false;
    var num = (s);
    
    return ((num >= a) && (num <= b));
}
//-------------------------------
function isMes (s){
   if (isEmpty(s)) return false;
   return isIntegerInRange (s, 1, 12);
}
//-------------------------------
function isDia (s) {
    if (isEmpty(s)) return false;
    return isIntegerInRange (s, 1, 31);
}
//-------------------------------
function isAno (s) {
    if (isEmpty(s)) return false;
    if (!isInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}
//-------------------------------
function diasInFevereiro (ano){
    return (  ((ano % 4 == 0) && ( (!(ano % 100 == 0)) || (ano % 400 == 0) ) ) ? 29 : 28 );
}

//-------------------------------
function ValidaData (dia, mes, ano, nome, vazia ) {
	
  if (isEmpty(ano.value) && isEmpty(mes.value) && isEmpty(dia.value)){
     if ( vazia ) return true;
     alert("O campo '" + nome + "' deve ser informado.");
     dia.focus();
     return false;
  }
  if (!isDia(dia.value)) 
  { alert("Dia inválido no campo '" + nome + "'."); dia.focus(); return false; }
  if (!isMes(mes.value)) 
  { alert("Mês inválido no campo '" + nome + "'."); mes.focus(); return false; }
  if (!isAno(ano.value)) 
  { alert("Ano inválido no campo '" + nome + "'."); ano.focus(); return false; }
  
  var intAno = parseInt(ano.value);
  var intMes = parseInt(mes.value);
  var intDia = parseInt(dia.value);
  dias = new Array(13);
  dias[1] = 31;
  dias[2] = 29;   // deve ser verificado o caso de anos bissextos
  dias[3] = 31;
  dias[4] = 30;
  dias[5] = 31;
  dias[6] = 30;
  dias[7] = 31;
  dias[8] = 31;
  dias[9] = 30;
  dias[10] = 31;
  dias[11] = 30;
  dias[12] = 31;
  if (intDia > dias[intMes]){ 
     alert("Dia inválido no campo '" + nome + "'"); 
	 dia.focus(); 
	 return false; 
  }
  if ((intMes == 2) && (intDia > diasInFevereiro(intAno))){ 
     alert("Dia inválido no campo '" + nome + "'"); 
	 dia.focus(); 
	 return false; 
  }
  if (intAno < 1000)
  {
     alert("O Ano deve ter 4 digitos: '" + nome + "'"); 
	 ano.focus(); 
	 return false; 
  }	 
  return true;
}

function TrataTecla( vetor )
{
	Tam = vetor.length;
	for (i = 0; i <= Tam; i++)
	{
		if (  window.event.keyCode == vetor[i] )
		{
			window.event.keyCode = 0;
			return(false);
		}
	}
	return(true);
}

function ForcaTecla( vetor )
{
	Tam = vetor.length;
	MesmaTecla=false;
	for (i = 0; i < Tam; i++)
	{
		if (  window.event.keyCode == vetor[i] )
		{
		    MesmaTecla=true;
		}
	}
	if ( MesmaTecla==false ) {
    	window.event.keyCode = 0;
		return(false);
	}
	return(true);
}



function SaltaCampo(tammax, campo, prox)
{
var tam = campo.value.length;
if (tam == tammax){
	prox.focus();
	prox.select();
	}
}

// Limpa campo data
function LimpaCampo(campo)
{
campo.value = "";
}

function verificaEmail(email) {

	var arroba = false;
	var ponto = false;

	for (var i = 0; i < email.length; i++) {
		if (email.substring(i-1,i) == "@") { 
			arroba = true;
		}
 
		if (email.substring(i-1,i) == ".") { 
			ponto = true;
		}
	}

	if ((arroba == false) || (ponto == false)) {
		return false;
	 }
	else {
		return true;
	 }
}

function verificaEmailDuplicidade(email) {

	var arroba = false;
	var ponto = false;
	vemail = frm.email.value;
	vemail = vemail.indexOf("@") + 2;
	
	for (var i = vemail; i < email.length; i++) {
		if ((email.substring(i-1,i) == "@") || (email.substring(i-1,i) == ";") || (email.substring(i-1,i) == ",") || (email.substring(i-1,i) == " ") || (email.substring(i-1,i) == "/")){ 
			arroba = true;
		}
 
	}

	if ((arroba == false)) {
		return false;
	 }
	else {
		return true;
	 }
	 
}
