function abrir_popup(URL) {

  var width = 300;
  var height = 300;

  var left = 199;
  var top = 199;

  window.open(URL,'janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abrir_popup2(URL) {

  var width = 600;
  var height = 400;

  var left = 199;
  var top = 199;

  window.open(URL,'janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

//Mostrar Itens do Formulario
function _PesquisarOpcao(opcao){
		var frm_aer = document.getElementById("busca-aer");
		var frm_hot = document.getElementById("busca-hot");
		var frm_pac = document.getElementById("busca-pac");
		var li1 = document.getElementById("li-busca1");
		var li2 = document.getElementById("li-busca2");
		var li3 = document.getElementById("li-busca3");
		
		if(opcao == 1){
			frm_aer.style.display = "block";
			frm_hot.style.display = "none";
			frm_pac.style.display = "none";
			li1.style.background = "#fdf1c2";
			li2.style.background = "#fff";
			li3.style.background = "#fff";
		}
		
		else if(opcao == 2){
			frm_aer.style.display = "none";
			frm_hot.style.display = "block";
			frm_pac.style.display = "none";
			li1.style.background = "#fff";
			li2.style.background = "#fdf1c2";
			li3.style.background = "#fff";
		}
		
		else{
			frm_aer.style.display = "none";
			frm_hot.style.display = "none";
			frm_pac.style.display = "block";
			li1.style.background = "#fff";
			li2.style.background = "#fff";
			li3.style.background = "#fdf1c2";
		}
	}

//Pop up
function e(id) {
	return document.getElementById(id);
}

	function lookup(origem) {
		if(origem.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("modulos/autocomplete/rpc.php", {queryString: ""+origem+""}, function(data){
				if(data.length >3) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function lookup2(destino) {
		if(destino.length == 0) {
			// Hide the suggestion box.
			$('#suggestions2').hide();
		} else {
			$.post("modulos/autocomplete/rpc2.php", {queryString: ""+destino+""}, function(data){
				if(data.length >3) {
					$('#suggestions2').show();
					$('#autoSuggestionsList2').html(data);
				}
			});
		}
	} // lookup2
	
		function lookup3(cidade) {
		if(cidade.length == 0) {
			// Hide the suggestion box.
			$('#suggestions3').hide();
		} else {
			$.post("modulos/autocomplete/rpc3.php", {queryString: ""+cidade+""}, function(data){
				if(data.length >3) {
					$('#suggestions3').show();
					$('#autoSuggestionsList3').html(data);
				}
			});
		}
	} // lookup
	
	
		function lookup4(termo) {
		if(termo.length == 0) {
			// Hide the suggestion box.
			$('#suggestions4').hide();
		} else {
			$.post("modulos/autocomplete/rpc4.php", {queryString: ""+termo+""}, function(data){
				if(data.length >3) {
					$('#suggestions4').show();
					$('#autoSuggestionsList4').html(data);
				}
			});
		}
	} // lookup
	
	function fill(thisValue) {
		$('#origem').val(thisValue);
		setTimeout("$('#suggestions').hide();", 200);
	}
	
	function fill2(thisValue) {
		$('#destino').val(thisValue);
		setTimeout("$('#suggestions2').hide();", 200);
	}
	
	function fill3(thisValue) {
		$('#cidade').val(thisValue);
		setTimeout("$('#suggestions3').hide();", 200);
	}
	
	function fill4(thisValue) {
		$('#termo').val(thisValue);
		setTimeout("$('#suggestions4').hide();", 200);
	}
	
$(function() {
	var dates = $('#data_ini, #data_ret').datepicker({
		dateFormat: "dd/mm/yy",
		numberOfMonths: 1,
		showOn: "focus", 
		minDate: 0, 
		maxDate: "+12M",
		onSelect: function(selectedDate) {
			var option = this.id == "data_ini" ? "minDate" : "maxDate";
			var instance = $(this).data("datepicker");
			var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
			dates.not(this).datepicker("option", option, date);
		}
	});
});

$(function() {
	var dates = $('#data_ini2, #data_ret2').datepicker({
		dateFormat: "dd/mm/yy",
		numberOfMonths: 1,
		showOn: "focus", 
		minDate: 0, 
		maxDate: "+12M",
		onSelect: function(selectedDate) {
		var option = this.id == "data_ini2" ? "minDate" : "maxDate";
		var instance = $(this).data("datepicker");
		var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
		dates.not(this).datepicker("option", option, date);
		}
	});
});

/* Traducaoo das datas do datepicker*/
/* Brazilian initialisation for the jQuery UI date picker plugin. */
/* Written by Leonildo Costa Silva (leocsilva@gmail.com). */
jQuery(function($){
	$.datepicker.regional['pt-BR'] = {
		closeText: 'Fechar',
		prevText: '&#x3c;Anterior',
		nextText: 'Pr&oacute;ximo&#x3e;',
		currentText: 'Hoje',
		monthNames: ['Janeiro','Fevereiro','Mar&ccedil;o','Abril','Maio','Junho',
		'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
		monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun',
		'Jul','Ago','Set','Out','Nov','Dez'],
		dayNames: ['Domingo','Segunda-feira','Ter&ccedil;a-feira','Quarta-feira','Quinta-feira','Sexta-feira','S&aacute;bado'],
		dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','S&aacute;b'],
		dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','S&aacute;b'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 0,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['pt-BR']);
});

function enviarEmail() {
		if($("#emailContato").val().length == 0 || $("#mensagemContato").val().length == 0 || $("#emailContato").val().indexOf("@") < 1 && $("#emailContato").val().indexOf('.') < 7) {
			alert('Informe ao menos o e-mail e a mensagem');
		} else {
		$("#enviarContato").hide();
		$("#enviarContato").after('<span id="status"><img src="http://www.salvatur.com.br/img/ajax-loader.gif" alt="Enviando" style="vertical-align:bottom" />Enviando...</span>');
		$.post("http://www.salvatur.com.br/contato/enviar/", {nomeContato: $('#nomeContato').val(), empresaContato: $('#empresaContato').val(), emailContato: $('#emailContato').val(),	telefoneContato: $('#telefoneContato').val(), mensagemContato: $('#mensagemContato').val(), tipoContato: $('#tipoContato').val()},  
		function(data){
			alert(data);
			$("#enviarContato").show();
			$("#status").hide();
			$("#nomeContato, #empresaContato, #emailContato, #telefoneContato, #mensagemContato ").val('');
			}
		);
	}
}

function cadastrarEmail() {
	if($("#email").val().indexOf("@") < 1 || $("#email").val().indexOf('.') < 7 || $("#email").val().length == 0 || $("#email").val() == 'E-mail:') {
		alert('Informe o e-mail corretamente');
	} else {
		$("#btnCadastrarEmail").hide();
		$("#btnCadastrarEmail").after('<span id="status"><img src="http://www.salvatur.com.br/img/ajax-loader.gif" alt="Enviando" style="vertical-align:bottom" />Cadastrando...</span>');
		$.post("http://www.salvatur.com.br/newsletter/", {email: $('#email').val()},
		function(data){
			alert(data);
			$("#btnCadastrarEmail").show();
			$("#status").hide();
			$("#email").val('E-mail:');
			}
		);
	}
}
