  function abrir (pag, alvo, altura, largura) {
    h=altura; w=largura;
	t=parseInt( (  (screen.height/2)+(h/2) ) /4)+100;
	l=parseInt( (  (screen.width/2)+(w/2)  ) /4);
	act=pag;
	trgt=alvo;
	feat ="border=no,menubar=no,toolbar=no,status=no,scrollbars=yes,title=no,height="+h+",width="+w;
    feat +=",top="+t+",left="+l;
	window.open (act, trgt, feat);
	return;
  }

  function abrir2 (pag, alvo, altura, largura) {
    h=altura; w=largura;
	t=parseInt( (  (screen.height/2)+(h/2) ) /4)+100;
	l=parseInt( (  (screen.width/2)+(w/2)  ) /4);
	act=pag;
	trgt=alvo;
	feat ="border=no,menubar=no,toolbar=no,status=yes,scrollbars=yes,title=no,height="+h+",width="+w;
    feat +=",top="+t+",left="+l;
	window.open (act, trgt, feat);
	return;
  }

  function abrir3 (pag, alvo, altura, largura) {
    h=altura; w=largura;
	t=parseInt( (  (screen.height/2)+(h/2) ) /4)+100;
	l=parseInt( (  (screen.width/2)+(w/2)  ) /4);
	act=pag;
	trgt=alvo;
	feat ="border=no,menubar=no,toolbar=yes,status=yes,scrollbars=yes,title=no,height="+h+",width="+w;
    feat +=",top="+t+",left="+l;
	window.open (act, trgt, feat);
	return;
  }

function chkCombo (obj, msg) {
  if (obj.selectedIndex <=0) {
    alert(msg);
	return false;
  }
  return true;
}

function isNumber(obj){ //obj -> Objeto do formulário.
   num="01213456789";
   v=obj.value;

   if (v == "")
     return false;

   for(i=0;i<=v.length-1;i++){
	f=i+1;
	s=v.substring(i,f);
	if(num.indexOf(s)<0){
	  return false;
	}
   }
   return true;
}

function isDecimal(obj, mrc){ //obj -> Objeto do formulário.
   num="01213456789"+mrc;
   v=obj.value;
   dot = false;

   if (v == "")
     return false;

   for(i=0;i<=v.length-1;i++){
	f=i+1;
	s=v.substring(i,f);
	if(num.indexOf(s)<0){
	  return false;
	}
    if ((s == mrc) && !dot) {
	   dot = true; }
	 else {
	  if ((s == mrc) && dot) {
       return false; }
     }

   }
   return true;
}

function isDate(d, m, a) {
  if ((isNaN(parseInt(d)) || isNaN(parseInt(m)) || 
      isNaN(parseInt(a))) ||
      ((a < 1500) || (a > 9999)) ||
      ((m < 1) || (m > 12)) ||
      ((d < 1) || (d > 31)) ||
      ((m == 2) && (d > 28) && (a % 4 != 0)) ||
      ((m == 2) && (d > 29) && (a % 4 == 0)) ||
      ((d > 30) && (m == 4) || (d > 30) && (m == 6) ||
       (d > 30) && (m == 9) || (d > 30) && (m == 11)))
    return false;

  return true;
}

function isDate2(data) {
if (data.length < 9)
  return false;

var adt = data.split("/");
var d = adt[0], m = adt[1], a = adt[2];

	return isDate(d, m, a);
}

function MascaraData(keypress, objeto){
	if(document.all) { // Internet Explorer
		var tecla = event.keyCode;
	}
	else {
	//    if(document.layers) { // Nestcape ou Mozilla
		var tecla = keypress.which;
	//    }
	}
	campo = eval (objeto);
	caracteres = '01234567890';
	separacoes = 2;
	separacao1 = '/';
	separacao2 = '/';
	conjuntos = 2;
	conjunto1 = 2;
	conjunto2 = 5;
	if ((caracteres.search(String.fromCharCode (tecla))!=-1) && campo.value.length < (conjunto1 + conjunto2 + 3))
	{
		if (campo.value.length == conjunto1) campo.value = campo.value + separacao1;
		if (campo.value.length == conjunto2) campo.value = campo.value + separacao2;
	}			
	else 
		event.returnValue = false;
}

function dataMenor (d1, m1, a1, d2, m2, a2) {
  var dtIni = a1  + "/" + ((m1.length<2)?"0":"") + m1 + "/" + ((d1.length<2)?"0":"") + d1;
  var dtFim = a2  + "/" + ((m2.length<2)?"0":"") + m2 + "/" + ((d2.length<2)?"0":"") + d2;

  return (dtIni > dtFim);
}

function isCPF(obj, mens) {
 obj.value=RetiraAspas(obj.value);
 if (!isNumber(obj)) {
   alert(mens);
   return false;
 } else {
   if (obj.value.length < 11) {
         alert(mens);
     return false;
   } // fim do if   
  } // fim do else
  if (!checkCPF(obj.value)) { 
     alert(mens);
     return false;
  }
  return true;
} // fim do function

function checkCPF(NumCPF) {
var Soma, Laco, Digito1, Digito2;
var invalidos = " 11111111111,22222222222,33333333333,44444444444,55555555555,66666666666,77777777777,88888888888,99999999999,00000000000";
var ind_ = invalidos.indexOf(NumCPF);
if (ind_ > 0)
  return false;

  // {primeiro digito}
  Soma = 0;
  for (Laco=0;Laco<9;Laco++) {
    Soma = Soma + (NumCPF.substring(Laco,Laco+1)*(Laco+1));
  } // fim for.

  Digito1 = Soma % 11;
  if (parseInt(Digito1) == 10) {Digito1 = 0;}

  //{segundo digito}
  Soma = 0;
  for (Laco=0;Laco<8;Laco++) {
    Soma = Soma + (NumCPF.substring(Laco+1,Laco+2)*(Laco+1));
  } // fim for.
  
  Soma = Soma + (Digito1 * 9);
  Digito2 = Soma % 11;
  
  if (parseInt(Digito2) == 10) { Digito2 = 0;}
  //{faz a chekagem}
   if (parseInt(Digito1) == parseInt(NumCPF.substring(9,10))) {
    if (parseInt(Digito2) == parseInt(NumCPF.substring(10,11))) {
      return true;
    } // fim if1
   } // fim if2
 return false; 
} // end function.

function RetiraAspas(Str) {
  if (Str == "")
    return Str;
  Str=replaceString("'","",Str);
  Str=replaceString('"','',Str);
  return (Str);
}

  function replaceString(oldS, newS, fullS) {
   var indice;
  
   indice = fullS.indexOf(oldS);
      
   if (indice < 0)
     return fullS;

   nfullS = "";
   oldindice = 0;
  
   while(indice < fullS.length && indice != -1) {
     if (indice >= 0)
	nfullS = nfullS + fullS.substring(oldindice, indice) + newS;
     oldindice = indice+1;
     indice = fullS.indexOf(oldS, indice + 1);
   }

 if (oldindice < fullS.length)
   nfullS = nfullS + fullS.substring(oldindice, fullS.length);

   return nfullS; 
}

function validarSTB(texto)
{             //A1234B
  mascara = /^[S][0-9]{12}$/ ;
  return mascara.test(texto);
}

//FUNÇÕES PARA MANIPULAR OS LAYERS DE ATRAÇÃO

function exibir(num,evnt){
  camada="atracao" + num;
  if(document.all){
    if(num!=16){
      esquerda=event.x+10;
      abaixo=(event.y+document.body.scrollTop)+10;
    }else{
      esquerda=600;
      abaixo=10;
    }
    if(num==15){
      esquerda+=5;
      abaixo+=5;
    }
    document.all[camada].style.visibility='visible';
    document.all[camada].style.left=esquerda;
    document.all[camada].style.top=abaixo;
  }else{
    document.layers[camada].visibility='show';
    document.layers[camada].left=evnt.x;
    document.layers[camada].top=evnt.y;
  }
}

function ocultar(num){
  camada="atracao" + num;
  if(document.all){
    document.all[camada].style.visibility='hidden';
  }else{
    document.layers[camada].visibility='hide';
  }
}

function acomp(num,evnt){
  camada="atracao" + num;
  if(document.all){
    esquerda=event.x+10;
    abaixo=(event.y+document.body.scrollTop)+10;
    if(num==15){
      esquerda+=5;
      abaixo+=5;
    }
    document.all[camada].style.left=esquerda;
    document.all[camada].style.top=abaixo;
  }
}

function SaltaCampoNum (f, campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	var msk = new RegExp("[0-9]{"+tammax+"}");
	var vr = f.elements[campo].value;

	tam = vr.length;	
    if (tecla != 0 && tecla != 9 && tecla != 16 ) {
       if ( tam == tammax ) {
        if( !msk.test(vr)){
          alert ("Campo numérico!");
          f.elements[campo].focus();
          f.elements[campo].select();
		  return;
        }
		f.elements[prox].focus();
	   }
    }
}

function SaltaCampo (f, campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	var vr = f.elements[campo].value;

	tam = vr.length;	
    if (tecla != 0 && tecla != 9 && tecla != 16 ) {
       if ( tam == tammax ) {
		f.elements[prox].focus();
	   }
    }
}

function validarCarnet(texto) {
//01234B9
//  mascara = /^[A-Za-z][0-9]{4}[A-Za-z]{4}$/ ;
  mascara = /^[0-9]{5}[A-Za-z@#][0-9]$/ ;
  return mascara.test(texto);
}

function formataDoisDig (obj) {
   if (obj.length < 2)
     obj.value = "0" + obj.value;
   return;
}