	function ValidaNumero(objeto)
		{
			campo = eval(objeto)
			if(((event.keyCode > 47) && (event.keyCode < 58)) || (event.keyCode == 13))event.returnValue = true;
			else
				{
					alert ('O campo só aceita valores numéricos!');
					eval(campo).focus();
					event.returnValue = false;
				}
		}
		
	function ValidaMoeda(objeto)
		{
			input = eval(objeto)
			if(((event.keyCode > 47) && (event.keyCode < 58)) ||
			((event.keyCode == 13) || (event.keyCode == 44) || (event.keyCode == 46)))event.returnValue = true;
			else
				{
					alert ('O campo só aceita valores numéricos!');
					eval(input).focus();
					event.returnValue = false;
				}
		}
		
	function Mascaradata(formato, objeto)
		{
			input = eval(objeto)
			if(formato == 'data')
				{
					if(((event.keyCode > 47) && (event.keyCode < 58)) || (event.keyCode == 13))
						{
							if (input.value.length == 2)input.value += '/';
							else if (input.value.length == 5)input.value += '/';
						}
					else
						{
							alert ('O campo só aceita valores numéricos!');
							eval(input).focus();
							event.returnValue = false;
						}
	        	}
		}
	
	function validadatanumero(S)
		{
			var temp = '';
			for(var i = 0; i < S.length; i++)
				{
					if(S.charAt(i) != '/')temp += S.charAt(i);
				}
			return temp
		}
	
	function validadata(objeto, anoatual)
		{
			input = eval(objeto)
			if(isNaN(validadatanumero(input.value)))
				{
					alert('O campo só aceita valores numéricos!')
					eval(input).select()
					return (false)
				}
			else
				{
					var dia = input.value.slice(0, 2)
					var mes = input.value.slice(3, 5)
					var ano = input.value.slice(6, 10)
					
					var bissexto = ((ano % 4 == 0) && ((ano % 100 != 0) || (ano % 400 == 0)));
					if(input.value.length < 10)
						{
							alert('Data inválida. A data deve estar no formato: dd/mm/yyyy!')
							eval(input).select()
							return false
						}
					else if(ano < 1900)
						{
							alert('Ano inválido. O ano deve ser maior 1900!')
							eval(input).select()
							return false
						}
					else if(ano > anoatual)
						{
							alert('Ano inválido. O ano deve ser menor ou igual a '+ anoatual +'!')
							eval(input).select()
							return false
						}
					else if((mes <= 0) || (mes > 12))
						{
							alert('Mês inválido.!')
							eval(input).select()
							return false
						}
					else if((mes == 2) && ((dia > 29) || ((dia == 29) && (!bissexto))))
						{
							alert('Dia inválido.!')
							eval(input).select()
							return false
						}
					else if(((mes == 1) || (mes == 3) || (mes == 5) || (mes == 7) || (mes == 8) || 
					(mes == 10) || (mes == 12)) && ((dia <= 0) || (dia > 31)))
						{
							alert('Dia inválido.!')
							eval(input).select()
							return false
						}
					else if(((mes == 4) || (mes == 6) || (mes == 9) || (mes == 11)) && 
					((dia <= 0) || (dia > 30)))
						{
							alert('Dia inválido.!')
							eval(input).select()
							return false
						}
					else return true;
				}
		}
	
	function createNewDate(d)
		{
			var dia = d.slice(0, 2)
			var mes = d.slice(3, 5)
			ano = d.slice(6, 10)
			data = new Date(ano +'/'+ mes +'/'+ dia)
			return (data)
		}
	
	function SomenteNumeros()
			{
			if ((event.keyCode >= 48) && (event.keyCode <= 57))
			    {
			      return true;
			    }
		    else
			    {
			      if (event.keyCode != 8)
				      {
				        event.keyCode = 0
				        return false;
				      }
			    }
		  }
	function MascaraCNPJ(formato, objeto)
		{
			input = eval(objeto);
			if(formato == 'cnpj')
				{
					if(((event.keyCode > 47) && (event.keyCode < 58)) || (event.keyCode == 13))
						{
							if(input.value.length == 2)input.value += '.';
							else if(input.value.length == 6)input.value += '.';
							else if (input.value.length == 10)input.value += '/';
							else if (input.value.length == 15)input.value += '-';
						}
					else
						{
							alert ('O campo só aceita valores numéricos!');
							eval(input).focus();
							event.returnValue = false;
						}
				}
		}

	function Mascaracpf (formato, objeto)
		{
			input = eval(objeto);
			if(formato == 'cpf')
				{
					if(((event.keyCode > 47) && (event.keyCode < 58)) || (event.keyCode == 13))
						{
							if (input.value.length == 3)input.value += '.';
							else if (input.value.length == 7)input.value += '.';
							else if (input.value.length == 11)input.value += '-';
						}
					else
						{
							alert ('O campo só aceita valores numéricos!');
							eval(input).focus();
							event.returnValue = false;
						}
				}
		}
	
	function Mascaracep (formato, objeto)
		{
			input = eval (objeto);
			if(formato == 'cep')
				{
					if(((event.keyCode > 47) && (event.keyCode < 58)) || (event.keyCode == 13))
						{
							if (input.value.length == 5)input.value += '-';
						}
					else 
						{
							alert ('O campo só aceita valores numéricos!');
							eval(input).focus();
							event.returnValue = false;
						}
				}
		}
	
	function validacpf(objeto)
		{
			input = eval(objeto)
			var invalidos = new Array('000.000.000-00', '111.111.111-11', '222.222.222-22', '333.333.333-33', '444.444.444-44', '555.555.555-55', '666.666.666-66', '777.777.777-77', '888.888.888-88', '999.999.999-99');
			var valida = false;
			for(i = 0; i < invalidos.length; i++)
				{
					if(input.value == invalidos[i])
						{
							valida = true;
							break;
						}
				}
			if(valida)
				{
					alert ('CPF inválido. Favor verificar!');
					eval(input).focus();
					return false;
				}
			else
				{
					var s = limpa_string(input.value)
					var dv1 = dv2 = cpf = soma = p1 = 0;
					var d1 = '098765432';
					var d2 = '1098765432';
					var c1 = parseInt(s.slice(9, 10))
					var c2 = parseInt(s.slice(10, 11))
					var pri1 = s.slice(0, 9)
					var pri2 = s.slice(0, 10)
					
					for(i = 0; i < 9; i++)
						{
							if(d1.slice(i, (i + 1)) == '0')cpf = (10 * parseInt(pri1.slice(i, (i + 1))));
							else cpf = (parseInt(d1.slice(i, (i + 1))) * parseInt(pri1.slice(i, (i + 1))));
							soma += cpf;
						}
					
					dv1 = parseInt((soma % 11));
					if((dv1 == 0) || (dv1 == 1))dv1 = 0;
					else dv1 = (11 - dv1);
					
					if(c1 != dv1)
						{
							alert ('O primeiro dígito verificador do seu CPF não é válido. Favor verificar!');
							eval(input).focus();
							return false;
						}
					
					cpf = soma = 0;
					for(i = 0; i < 10; i++)
						{
							if(d2.slice(i, (i + 1)) == '1')cpf = (11 * parseInt(pri2.slice(i, (i + 1))));
							else if(d2.slice(i, (i + 1)) == '0')cpf = (10 * parseInt(pri2.slice(i, (i + 1))));
							else cpf = (parseInt(d2.slice(i, (i + 1))) * parseInt(pri2.slice(i, (i + 1))));
							soma += cpf;
						}
					
					dv2 = parseInt((soma % 11));
					if ((dv2 == 0) || (dv2 == 1))dv2 = 0;
					else dv2 = (11 - dv2);
					
					if (c2 != dv2)
						{
							alert ('O segundo dígito verificador do seu CPF não é válido. Favor verificar!');
							eval(input).focus();
							return false;
						}
				}
		}
	
	function limpa_string(S)
		{
			var Digitos = '0123456789';
			var temp = '';
			var digitos = '';
		
			for(var i = 0; i < S.length; i++)
				{
					digitos = S.charAt(i);
					if(Digitos.indexOf(digitos) >= 0)
						{
							temp = temp + digitos
						}
				}
			return temp
		}
	
	function valida_CNPJ(s)
		{
			var i;
			input = eval(s);
			s = limpa_string(input.value);
			var c = s.substr(0, 12);
			var dv = s.substr(12, 2);
			var d1 = 0;
			
			for (i = 0; i < 12; i++)
				{
					d1 += c.charAt(11 - i) * (2 + (i % 8));	
				}
			if(d1 == 0) return false;
			d1 = 11 - (d1 % 11);
			if(d1 > 9) d1 = 0;
			if(dv.charAt(0) != d1)
				{
					alert ('Primeiro dígito verificador inválido!');
					eval(input).value = '';
					return false;
				}
			d1 *= 2;
		
			for(i = 0; i < 12; i++)
				{
					d1 += c.charAt(11-i) * (2 + ((i + 1) % 8));
				}
			d1 = 11 - (d1 % 11);
			if(d1 > 9) d1 = 0;
			if(dv.charAt(1) != d1)
				{
					alert ('Segundo dígito verificador inválido!');
					eval(input).value = '';
					return false;
				}
		}
	
	function PG(n)
		{
			var form = window.document.nav;
			form.CurrentPage.value = n;
			form.submit();
		}
	
	function validamail(obj)
		{
			input = eval(obj)
			if(input.value != '')
				{
					if((input.value.indexOf('@') < 0) || (input.value.indexOf('@') == 0) ||
					(input.value.substring((input.value.indexOf('@') + 1), input.value.length).indexOf('.') < 0) ||
					(input.value.charAt(input.value.indexOf('@') + 1) == '.'))
						{
							alert('E-mail inválido. Exemplo de um e-mail válido: info@apbuzios.com.br!')
							eval(input).focus()
							return false
						}
					else return true;
				}
		}
	
	function insereQuebraLinha(f)
		{
			var entrada = eval(f);
			var fe = entrada.elements;
			for(i = 0; i < fe.length; i++)
				{
					if(fe[i].type == 'textarea') fe[i].value = fe[i].value.replace(/\n/g, '<br />');
				}
		}
	
	function insereContraBarran(f)
		{
			var entrada = eval(f);
			var fe = entrada.elements;
			for(i = 0; i < fe.length; i++)
				{
					if(fe[i].type == 'textarea')
						{
							do
								fe[i].value = fe[i].value.replace('<br />', '\n');
							while(fe[i].value.indexOf('<br />') > -1);
							
							do
								fe[i].value = fe[i].value.replace('<br>', '\n');
							while(fe[i].value.indexOf('<br>') > -1);
							
							do
								fe[i].value = fe[i].value.replace('<BR>', '\n');
							while(fe[i].value.indexOf('<BR>') > -1);
							
							do
								fe[i].value = fe[i].value.replace('<Br>', '\n');
							while(fe[i].value.indexOf('<Br>') > -1);
						}
				}
		}
	
	function TrimReplace(f)
		{
			var entrada = eval(f);
			var fe = entrada.elements;
			for(i = 0; i < fe.length; i++)
				{
					if((fe[i].type == 'text') || (fe[i].type == 'textarea'))
						fe[i].value = fe[i].value.Trim();
				}
		}
	function JanelaPop(pagina, nome, w, h, scroll)
		{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		propriedades = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
		win = window.open(pagina, nome, propriedades)
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus();}
		}
		
	function MostraPousada(id)
		{
		var h = 560;
		var w = 600;
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		propriedades = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable=no, status=yes'
		hotel = window.open('/pousadas/?id='+id, 'pousada', propriedades)
		if (parseInt(navigator.appVersion) >= 4) { hotel.window.focus();}
		}
		
	function ExibeParceiro(id)
		{
		JanelaPop('/exibir_parceiro.asp?id='+id,'parceiro','400','130','no')
		}
	function Politica()
		{
		JanelaPop('/politica.asp','politica','500','350','no')
		}
	function Exibir(foto)
		{
		JanelaPop('/exibe_foto.asp?foto='+foto,'foto','500','500','no')
		}
	function Mapa(foto)
		{
		JanelaPop('/exibe_foto.asp?foto='+foto,'foto','400','400','no')
		}
	function Enviar(id, caminho)
		{
		JanelaPop('/email.asp?id='+id+'&link='+caminho,'email','350','320','no')
		}
	function SendEmail(id)
		{
		JanelaPop('/enviarEmail.asp?email='+id,'email','350','280','no')
		}
	function MapaBuzios()
		{
		JanelaPop('/mapa_buzios.html','mapa','780','510','no')
		}
	function Imprimir(id, secao)
		{
		JanelaPop('/impressao.asp?id='+id+"&idsecao="+secao+'&list=1','imprimir','600','500','yes')
		}
	function Preenche(texto, valor, campo)
		{
		posicao=document.getElementById(campo).length++
		document.getElementById(campo).options[posicao] = new Option(texto,valor)
		document.getElementById(campo).selectedIndex = posicao
		}
	function PegaTecla()
		{
		return (document.all ? event.keyCode : -1);
		}
	function Deleta(campo, destino)
		{
		if (document.getElementById(campo).selectedIndex >= 0)
			{
			valor = document.getElementById(campo).options[document.getElementById(campo).selectedIndex].value
			window.location = destino+".asp?id=" + valor;
			document.getElementById(campo).options[document.geElementById(campo).selectedIndex]=null;
			document.getElementById(campo).selectedIndex=0;
			}
		}
	function Insere(campo, destino)
		{
		if (document.getElementById(campo).selectedIndex >= 0)
			{
			valor = document.getElementById(campo).options[document.getElementById(campo).selectedIndex].value
			window.location = destino+".asp?id=" + valor;
			document.getElementById(campo).options[document.geElementById(campo).selectedIndex]=null;
			document.getElementById(campo).selectedIndex=0;
			}
		}
		function validarLogin()
			{
			if (document.getElementById('txtlogin').value == '')
				{
				alert('Por favor Informe seu login');
				document.getElementById('txtlogin').focus();
				return false;
				}
			if (document.getElementById('txtsenha').value == '')
				{
				alert('Por favor Informe sua senha');
				document.getElementById('txtsenha').focus();
				return false;
				}	
				return true;
			}
		function ValidarSocio()
			{
			var Exp = /^[a-z0-9](\.?\w)*(\-?\w)*@[a-z0-9\-\_]+(\.[a-z0-9]+)*(\.[a-z0-9]{2,4})$/;
			
			if (document.getElementById('razao_social').value == '')
				{
				alert('Por favor Informe a Razão Social');
				document.getElementById('razao_social').focus();
				return false;
				}
			if (document.getElementById('nome_fantasia').value == '')
				{
				alert('Por favor Informe o Nome Fantasia');
				document.getElementById('nome_fantasia').focus();
				return false;
				}
			if (document.getElementById('cnpj').value == '')
				{
				alert('Por favor Informe o CNPJ');
				document.getElementById('cnpj').focus();
				return false;
				}
			if (document.getElementById('insc_mun').value == '')
				{
				alert('Por favor Informe a Inscrição Municipal');
				document.getElementById('insc_mun').focus();
				return false;
				}
			if (document.getElementById('embratur').value == '')
				{
				alert('Por favor Informe o número de inscrição na Embratur');
				document.getElementById('embratur').focus();
				return false;
				}
			if (document.getElementById('endereco').value == '')
				{
				alert('Por favor Informe o endereço completo');
				document.getElementById('endereco').focus();
				return false;
				}
			if (document.getElementById('bairros').options[document.getElementById('bairros').selectedIndex].value == '')
				{
				alert('Por favor selecione o seu bairro');
				document.getElementById('bairros').focus();
				return false;
				}
			if (document.getElementById('responsavel').value == '')
				{
				alert('Por favor Informe o nome do responsável');
				document.getElementById('responsavel').focus();
				return false;
				}
			if (document.getElementById('telefone').value == '')
				{
				alert('Por favor Informe o telefone');
				document.getElementById('telefone').focus();
				return false;
				}
			if (document.getElementById('fax').value == '')
				{
				alert('Por favor Informe o fax');
				document.getElementById('fax').focus();
				return false;
				}
			if (!Exp.test(document.getElementById('email').value))
  				{
				alert("E-mail inválido.");
				document.getElementById('email').focus();
				return false;
				}
			if (document.getElementById('apts').options[document.getElementById('apts').selectedIndex].value == '')
				{
				alert('Por favor informe a quantidade de apartamentos em sua pousada');
				document.getElementById('apts').focus();
				return false;
				}
		
				return true;
			}
		function ValidarParceiro()
			{
			var Exp = /^[a-z0-9](\.?\w)*(\-?\w)*@[a-z0-9\-\_]+(\.[a-z0-9]+)*(\.[a-z0-9]{2,4})$/;
			
			
			if (document.getElementById('nome_fantasia').value == '')
				{
				alert('Por favor Informe o Nome Fantasia');
				document.getElementById('nome_fantasia').focus();
				return false;
				}
			
			if (document.getElementById('endereco').value == '')
				{
				alert('Por favor Informe o endereço completo');
				document.getElementById('endereco').focus();
				return false;
				}
			if (document.getElementById('atuacao').options[document.getElementById('atuacao').selectedIndex].value == '')
				{
				alert('Por favor informe a area de atuação de sua empresa');
				document.getElementById('atuacao').focus();
				return false;
				}
			if (document.getElementById('bairro').value == '')
				{
				alert('Por favor Informe o bairro');
				document.getElementById('bairro').focus();
				return false;
				}
			if (document.getElementById('ddd').value == '')
				{
				alert('Por favor Informe o DDD');
				document.getElementById('ddd').focus();
				return false;
				}
			if (document.getElementById('telefone').value == '')
				{
				alert('Por favor Informe o telefone');
				document.getElementById('telefone').focus();
				return false;
				}
			if (document.getElementById('contato').value == '')
				{
				alert('Por favor Informe uma nome para contato');
				document.getElementById('contato').focus();
				return false;
				}
			if (document.getElementById('fax').value == '')
				{
				alert('Por favor Informe o fax');
				document.getElementById('fax').focus();
				return false;
				}
			if (!Exp.test(document.getElementById('email').value))
  				{
				alert("E-mail inválido.");
				document.getElementById('email').focus();
				return false;
				}
		
				return true;
			}