// JavaScript Document
$(function(){
	
	$("#galeriaHorizontal, #galeriaMiniHorizontal, #galeriaMiniHorizontalCenter, #pacoteFixo").infiniteCarousel();
	$('.ampliar').fancybox({
		autoScale: false
	});
	//NEWSLETTERS
	$("#newsletterForm").submit(function(){
		$("#respostaNews").css({'color':'white'})
		var nome	= $("#nomeNews").val();
		var email	= $("#emailNews").val();
		var acao	= $("input[name='acao']:checked").val();
		
		$("#respostaNews").show().html("<img src='img/loading.gif' alt='...' /> Cadastrando");
		$.post('newsletters.post.php', {
				nome : nome,
			  	email: email,
				acao : acao
				
			   }, function(resposta) {			
				if (resposta != false) {
					$("#respostaNews").html(resposta);
				} 
				else {
					var retorno = "E-mail cadastrado com sucesso!";
					if(acao==2) var retorno = "Email removido com Sucesso";
					$("#respostaNews").html(retorno);				
				}
		});
	});//news
	
	//ENQUETE
	$("#enqueteForm").submit(function(){
		var obj = {
			pergunta : $("#perguntaEnquete").val(),
			resposta : $("input[name='resposta']:checked").val()
		}
		if(obj.pergunta == undefined || obj.resposta == undefined)return false;
		
		$("#respostaEnquete").show().html("<img src='img/ajaxLoader.gif' alt='Enviando' /> Enviando");
		$.post('votar.post.php', obj, function(retorno) {			
			$("#respostaEnquete").html(retorno);
		});
	});//enquete
	
	
	
	/**
		saibaMais | indicar | iframe | youtube
	**/
	$(".toolsbar").live('click',function(){
		$.fancybox({
			'width'				: 640,
			'height'			: 480,
	        'autoScale'     	: false,
	        'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'href'				: this.rel,
			'type'				: 'iframe'
		});
		return false;
	});
	
	$(".iframe").live('click',function(){
		$.fancybox({
			'width'				: 980,
			'height'			: 580,
	        'autoScale'     	: false,
	        'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'href'				: this.href,
			'type'				: 'iframe'
		});
		return false;
	});
	$("a.pacote").live('click',function(){
		$.fancybox({
			'width'				: 380,
			'height'			: 480,
	        'autoScale'     	: false,
	        'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'href'				: this.href,
			'type'				: 'iframe'
		});
		return false;
	});
	$(".reserva").live('click',function(){
		$.fancybox({
			'width'				: 380,
			'height'			: 480,
	        'autoScale'     	: false,
	        'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'href'				: this.href,
			'type'				: 'iframe'
		});
		return false;
	});
	$('.youtube').live('click',function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
		return false;
	});

})

