// JavaScript Document

$(function() {
	$.post('hash_no_spam.php',function(data) {
		$('input#cadastrar').after('<input type="hidden" value="' + data + '" name="hash_solar_da_praca_no_spam" />');
		$.cookie('hash_solar_da_praca_no_spam','' + data + '');
   });
});

function OpenRadio(url) {
	window.open(url,'RadioSolar','width=595,height=240');
}
function OpenFotoCartao(url) {
	window.open(url,'CartoesPostais','width=400,height=320');
}
function OpenFotoDicas(url) {
	window.open(url,'FotosDicas','width=400,height=320');
}
function OpenConversorMoedas() {
	window.open('http://www.financeone.com.br/parceiro.php?code=leandro','Conversor','toolbar=yes,width=600,height=490,top=0,left=0');
}
function OpenMapaLocalizacao() {
	window.open('mapa_localizacao.htm','Mapa','scrollbars=auto,width=828,height=410');
}
function ExibirEmailHospede() {
	document.getElementById("exibir_email").innerHTML="Seu e-mail será exibido"
}
function ShowHideReservas(campo_check,object,campo_focus) {
	if(document.getElementById(campo_check).checked==true) {
		document.getElementById(object).style.visibility="visible";
		document.getElementById(campo_focus).focus();
	} else {
		document.getElementById(object).style.visibility="hidden";
	}
}
function ddd() {
	if (document.getElementById('res_ddd').value.length == 2) {
		document.getElementById('res_telefone').focus();
	}
}
function ValidaReservasIndex() {
	for(i=0; i<document.forms[0].elements.length; i++)
	if ( (document.forms[0].elements[i].type=="text") && (document.forms[0].elements[i].value=="") ) {
		alert("Por favor, preencha os dados necessários.");
		document.forms[0].elements[i].focus();
		return false;
	}
}

function ValidaEnvioCartao(frm) {
	if(frm.nome_remetente.value.replace(/\s/gi,"")=="") {
		frm.nome_remetente.focus();
		alert("Por favor, informe seu nome.");
		return false;
	 }
	 if(frm.email_remetente.value.replace(/\s/gi,"")=="") {
		frm.email_remetente.focus();
		alert("Por favor, informe o seu e-mail.");
		return false;
	 }
	 if(frm.email_remetente.value.indexOf("@")==-1 || frm.email_remetente.value.lastIndexOf(".")==-1) {
		 frm.email_remetente.focus();
		 var email_erro_envio = frm.email_remetente.value;
		 alert("Por favor, informe um e-mail válido. Confira: "+email_erro_envio+"");
		 return false;
	 }
	 if(frm.nome_destinatario.value.replace(/\s/gi,"")=="") {
		 frm.nome_destinatario.focus();
		 alert("Por favor, informe o nome do destinatário do Cartão Postal.");
		 return false;
	 }
	 if(frm.email_destinatario.value.replace(/\s/gi,"")=="") {
		frm.email_destinatario.focus();
		var nome_destinatario = frm.nome_destinatario.value;
		alert("Por favor, informe o email do(a) "+nome_destinatario+".");
		return false;
	 }
	 if(frm.email_destinatario.value.indexOf("@")==-1 || frm.email_destinatario.value.lastIndexOf(".")==-1) {
		 frm.email_destinatario.focus();
		 var email_erro_envio2 = frm.email_destinatario.value;
		 alert("Por favor, informe um e-mail válido. Confira: "+email_erro_envio2+"");
		 return false;
	 }
	if(frm.cartao_assunto.value.replace(/\s/gi,"")=="") {
		frm.cartao_assunto.focus();
		alert("Por favor, informe o assunto da mensagem.");
		return false;
	}
	if(frm.cartao_msg.value.replace(/\s/gi,"")=="") {
		frm.cartao_msg.focus();
		alert("Por favor, digite a mensagem do cartão.");
		return false;
	}
	return true;
}
function ValidaReservasOnLine(frm) {
	if(frm.res_nome.value.replace(/\s/gi,"")=="") {
		frm.res_nome.focus();
		alert("Por favor, informe-nos o seu nome.");
		return false;
	}
	if(frm.res_sobrenome.value.replace(/\s/gi,"")=="") {
		frm.res_sobrenome.focus();
		alert("Por favor, informe-nos o seu sobrenome.");
		return false;
	}
	if(frm.res_pais.value.replace(/\s/gi,"")=="") {
		frm.res_pais.focus();
		alert("Por favor, informe-nos seu país de origem.");
		return false;
	}
	if(frm.res_cidade.value.replace(/\s/gi,"")=="") {
		frm.res_cidade.focus();
		alert("Por favor, infome-nos sua cidade de origem.");
		return false;
	}
	if(frm.res_email.value.replace(/\s/gi,"")=="") {
		frm.res_email.focus();
		alert("Por favor, informe-nos o seu e-mail.");
		return false;
	}
	if(frm.res_email.value.indexOf("@") ==1 || frm.res_email.value.lastIndexOf(".") == -1) {
		frm.res_email.focus();
		var email_digitado = frm.res_email.value;
		alert("Desculpe, mas você informou um e-mail inválido: \""+ email_digitado +"\".\nConfira-o por favor.");
		return false;
	}
	if(frm.res_ddd.value.replace(/\s/gi,"")=="") {
		frm.res_ddd.focus();
		alert("Por favor, digite o DDD do seu telefone.");
		return false;
	}
	if(frm.res_telefone.value.replace(/\s/gi,"")=="") {
		frm.res_telefone.focus();
		alert("Por favor, digite o seu telefone.");
		return false;
	}
	if(frm.res_qt_adultos.value.replace(/\s/gi,"")=="") {
		frm.res_qt_adultos.focus();
		alert("Por favor, informe-nos a quantidade de adultos.");
		return false;
	}
	if(frm.res_qt_criancas.value.replace(/\s/gi,"")=="") {
		frm.res_qt_criancas.focus();
		alert("Por favor, informe-nos a quantidade de crianças.");
		return false;
	}
	/*if(frm.mostra_albergue.checked == false || frm.mostra_solteiro.checked == false) {
		alert("Por favor, informe-nos a quantidade e o tipo de quarto.");
		return false;
	}*/
	if(frm.res_data_chegada.value.replace(/\s/gi,"")=="") {
		frm.res_data_chegada.focus();
		alert("Por favor, diga-nos a data da sua chegada.");
		return false;
	}
	if(frm.res_data_saida.value.replace(/\s/gi,"")=="") {
		frm.res_data_saida.focus();
		alert("Por favor, diga-nos a data da sua partida.");
		return false;
	}
return true;
}
function ValidaCadastroNews(frm) {
	if(frm.usuario_nome.value.replace(/\s/gi,"")=="") {
		frm.usuario_nome.focus();
		alert("Informe o seu nome.");
		return false;
	}
	if(frm.usuario_email.value.replace(/\s/gi,"")=="") {
		frm.usuario_email.focus();
		alert("Informe o seu e-mail.");
		return false;
	}
	if(frm.usuario_email.value.indexOf("@")==-1 || frm.usuario_email.value.lastIndexOf(".")==-1) {
		frm.usuario_email.focus();
		alert("Informe um e-mail válido.");
		return false;
	}
return true;
}