
function openWindow(url, name) {
popupWin =  window.open(url,name,"width=488,height=450,top=0,resizable=no,scrollbars=no");
 }
/* FIM DA FUNÇÃO DA PÁGINA DE CONTATO*/

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/* Funcões Globais da Ola Turismo */
//FUNCAO PARA VALIDACAO DE NÚMEROS INTEIROS, E ESPAÇOS EM BRANCO
function valida_inteiro(parametro)
{ // aberto
	if (parametro.length != 0)
	{ // aberto
		if (!verifica_branco(parametro))
		{ // aberto
			return true;
		} // fechado
		
		teste_ponto = "false";
		tamanho_parametro = parametro.length;
		
		if (isNaN(parametro)) //valor digitado não é numérico
		{ // aberto
			return false;
		} // fechado
		else //valor digitado é um numérico válido
		{// aberto	
			
			for (k = 0; k < tamanho_parametro; k++)
			{// aberto
				if ((parametro.charAt(k) == '.') || (parametro.charAt(k) == '-') || (parametro.charAt(k) == '+'))
				{  // aberto
					teste_ponto = "true"; /*existe caracter ponto*/
				} // fechado
			} // Fechado
			
			if (teste_ponto == "true") //encontrou caracter ponto(numero real)
			{ // aberto
				return false;
			} // fechado
			else
			{ // aberto
				return true;
			} // fechado
		} // fechado
	} // fehcado
	else
	{ // aberto
		return true;
    }// fechado
} // Fechado
// Fim da função Valida Inteiro 

/*******************************************************************************************************/

/* Validar o campo e-mail */
function validaEmail(email) 
{
	var pos, aux, pos2, dominio, carac, i;
	email = email.toLowerCase();

	if (email.indexOf("@",0) == -1 || email.length <= 10) return false
	
	pos = email.indexOf("@",0) //no ASP 8, JS 7
	aux = email.substring(pos+1) //pop.com.br

	if (aux.indexOf(".",0) < 2) return false

	pos2 = aux.indexOf(".",0)
	dominio = aux.substr(0,pos2)//pop

	if (dominio.length < 2) return false

	carac = new Array("!","#","$","%","&","*","(",")","+","=","/","\\","|","?","'","\"","{","}","[","]","ª","º",":",",",";","§","°","<",">")
	for(i=0; i<carac.length; i++) if (email.indexOf(carac[i],0) != -1) return false

	return true
}

/*******************************************************************************************************/

/* Mascara para campo telefone  e celular */
function fone(input)
{
	if ((event.keyCode<48)||(event.keyCode>57))
	event.returnValue = false;
	input.maxLength = 14;
	if (input.value.length==0)
	{
		input.value = input.value + '(';
	};
		
	if (input.value.length==3)
	{
		input.value = input.value + ') ';
	};
		
	if (input.value.length==9)
	{
		input.value = input.value + '-';
	};
}
/* Fim da mascaraca campo e telefone */


/* Função para Formatar o CPF */
function fcpf(input)
{
	if ((event.keyCode<48)||(event.keyCode>57))
	event.returnValue = false;
	
	input.maxLength=14;
	if (input.value.length==3)
	{
		input.value = input.value + '.';
	};
   	if (input.value.length==7)
	{
		input.value = input.value + '.';
	};		 
	if (input.value.length==11)
	{
		input.value = input.value + '-';		 			 	
	};
}
/* Fim da Função para Formatar o CPF */

/*******************************************************************************************************/

/* Função para formatar a data */
function vdate(input)
{
	if ((event.keyCode<48)||(event.keyCode>57))
	event.returnValue = false;
	
	if (input.value.length==2)
	{
		input.value = input.value + '/';
	};
   	if (input.value.length==5)
	{
		input.value = input.value + '/';
	};		 
}

/*******************************************************************************************************/

/* FIM DA FUNÇÃO FORMATADA DATA */
function EhIgual(campo)
{ // Verifica se todos os valores são iguais
	var i = 0
	var j = 1
	var igual = true;
	// Todos os caracteres devem ser diferentes
	while (i < campo.length-1 && igual == true)
	{
		while (j < campo.length && igual == true)
		{
			if (campo.charAt(i) != campo.charAt(j))
			{
				igual = false;
			}
			else j++;
		}
		i++;
	}
	return igual;
}
// Fim da função

/*******************************************************************************************************/

/* FUNCAO PARA VERIFICAÇÃO DE CAMPOS NÃO PREENCHIDOS */
function verifica_branco(parametro)   // OU PREENCHIDOS APENAS COM ESPAÇOS EM BRANCO
{
	
	teste_parametro = "false"; //variavel para teste de espacos em branco
	tamanho_parametro = parametro.length;
	if (tamanho_parametro != 0) // Se o tamanho do parametro for Diferente de 0
	{   
	// Verifica num loop os caracteres digitados
		for (i = 0; i < tamanho_parametro; i++)
			{
			// Se os caracteres for diferente de vazio então
			if (parametro.charAt(i) != " ")
				{
					teste_parametro = "true"; /*existe caracter diferente de branco*/
				}
			} // Fecha o paremetro FOR
			
		// Se os caracteres for diferente de vazio então
		if (teste_parametro == "false")  //todos os caracteres digitados são brancos
		{
			return false;
		} 
		// Se o paremetro for diferente de Zero e estiver tudo ok retorna true
		else
		{
			return true;
		}
	}
	// Se o paremetro for diferente de Zero e estiver algo errado retorna False
	else
	{
		return false;
	}
		
}
/* FIM DA FUNCAO PARA VERIFICAÇÃO DE CAMPOS NÃO PREENCHIDOS */

/*******************************************************************************************************/

/* FUNCAO PARA VALIDACAO DE NÚMEROS INTEIROS, E ESPAÇOS EM BRANCO */
function numeros(input)
{
	if ((event.keyCode<48)||(event.keyCode>57))
		event.returnValue = false;
		
	if (input.length != 0)
	{
		if (!verifica_branco(input))
		{
			return true;
		}
	}

}
/* FIM DA FUNCAO PARA VALIDACAO DE NÚMEROS INTEIROS, E ESPAÇOS EM BRANCO */

/*******************************************************************************************************/

/* Funcionalidade:	Valida a Data retornando True se for uma Data  */
function Valida_Data(dia,mes,ano)
	{	//Funcionalidade:	Valida a Data retornando True se for uma Data 
		//					válida e False se não for.
		//					Antes de se usar esta função deve-se garantir que os parâmetros
		//					passados sejam numéricos e inteiros.
		// PARÂMETROS: 
		//		Dia = Dia da Data(caracteres numericos), 
		//		Mes = Mes da Data(caracteres numericos), 
		//		Ano = Ano da Data(caracteres numericos)
		
		var v_dia;
		var v_mes;
		var v_ano;
		
		if (!valida_inteiro(dia))
		{
			return (false);		
		}
		if (!valida_inteiro(mes))
		{
			return (false);		
		}
		if (!valida_inteiro(ano))
		{
			return (false);		
		}
				
		v_dia = dia;
		v_mes = mes;
		v_ano = ano;
		
		if (v_dia.length < 2)
		{
			return(false);
		}
		
		if (v_mes.length < 2)
		{
			return(false);
		}
		
		if (v_ano.length < 4)
		{
			return(false);
		}
			
		if (((v_ano < 1900) || (v_ano > 2079)) && (v_ano.length != 0))
		{
			return(false);
		}

		if (v_dia > 31 || v_dia < 1)
		{
			return(false);
		}
		
		if (v_mes > 12 || v_mes < 1)
		{
			return(false);
		}
		
		if (v_dia == "31") 
		{
			if ((v_mes == "04") || (v_mes == "06") || (v_mes == "09") || (v_mes == "11"))
			{
				return(false);
			}
		}
	
		//Validação de Ano Bissexto
		if (v_mes == "02")
		{
			if (!(v_ano%4)) 
			{
				if (v_dia > 29)
				{
					return(false);
				}
			}
			else if (v_dia > 28)
			{
				return(false);
			}
		}
		
		//o -if- abaixo testa se algum campo foi preenchido e outro deixado em branco deixando a data incompleta

		if (((v_dia != "") || (v_mes != "") || (v_ano != "")) && ((v_dia == "") || (v_mes == "") || (v_ano == "")))
		{
			return(false);
		}
		
		return(true);
	}
/* Fim da função da validação da Tada */

function isCPF(st) {
	//st = document.frmCadastro.txt_cpf.value;
	st = st.replace(".","");
	st = st.replace(".","");
	st = st.replace(".","");
	st = st.replace("-","");
	
	if (st == "") return (false);
	l = st.length;

	//aleterado para se usuário não digitar os zeros na frente do CPF, completar sozinho
	if ((l == 9) || (l == 8)) {
		for (i = l ; i < 10; i++) {
			st = '0' + st
		}
	}

	l = st.length;
	st2 = "";
	for (i = 0; i < l; i++) {
		caracter = st.substring(i,i+1);
		if ((caracter >= '0') && (caracter <= '9'));
		st2 = st2 + caracter;
	}

	if ((st2.length > 11) || (st2.length < 10))
		return (false);

	if (st2.length==10)
		st2 = '0' + st2;

	digito1 = st2.substring(9,10);
	digito2 = st2.substring(10,11);
	digito1 = parseInt(digito1,10);
	digito2 = parseInt(digito2,10);
	sum = 0; mul = 10;
	for (i = 0; i < 9 ; i++) {
		digit = st2.substring(i,i+1);
		tproduct = parseInt(digit ,10) * mul;
		sum += tproduct;
		mul--;
	}

	dig1 = ( sum % 11 );
	if ( dig1==0 || dig1==1 )
		dig1=0;
	else
		dig1 = 11 - dig1;
	
	if (dig1!=digito1)
		return (false);

	sum = 0;
	mul = 11;
	for (i = 0; i < 10 ; i++) {
		digit = st2.substring(i,i+1);
		tproduct = parseInt(digit ,10)*mul;
		sum += tproduct;
		mul--;
	}

	dig2 = (sum % 11);
	if ( dig2==0 || dig2==1 )
		dig2=0;
	else
		dig2 = 11 - dig2;

	if (dig2 != digito2)
		return (false);
return (true);
}<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function ENVIA_COMBO(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=ENVIA_COMBO(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function URL_COMBO(selName,targ,restore){ //v3.0
  var selObj = ENVIA_COMBO(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}


function VER_MAIL(d)
	{
	if( !validaEmail( d.txt_email_news.value ) )
	{
		alert( "E-mail inválido." );
		d.txt_email_news.focus();
		return false;
	}
return true
	}
	
function MAIL(d,URL,ok) {

   var width = 300;
   var height = 100;

   var left = 99;
   var top = 99;
   
   if (ok=1)
   {
   window.open(URL,'EMAIL', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
   	if (VER_MAIL(d))
	{ 
		d.submit();
	}
   }
   
}