$(document).ready(function() {

	//id,largura,altura(top[-1 para não aparecer as setas],left,right),(bottom[-1 para não aparecer as bolas],right),(intervalo de transição em milisegundos)
	iniciar_slideshow_opacidade("slider_grupo1","978","298","-1","-999999","-999999","13","14","5000");
	iniciar_slideshow_lateral("slider_grupo2","640","420","-1","-999999","-999999","445","9","9000");
	iniciar_slideshow_lateral("slider_grupo3","640","280","-1","-999999","-999999","258","9","13000");
	
	$("#pageflip").hover(
						 
		function() { 
								  
			$("#pageflip img, .papel_baixo").stop().animate(
						 
				{width: '230px', height: '239px'}, 
				500
					
			);
			
		}, 
		function() {
			
			$("#pageflip img").stop().animate(
											  
				{width: '65px', height: '67px'}, 
				220
				
			);
			$(".papel_baixo").stop().animate(
										   
				{width: '65px', height: '65px'}, 
				200
				
			);
			
		}
	
	);
	
	var fator = 0.10;
	$("img.efeito_imagem").one("load",
	 
		function() {
		
			$(this).wrap("<div style='position:relative; width:" + $(this).css("width") + "; height:" + $(this).css("height") + "; float:" + $(this).css("float") + ";' />");
			$(this).css({position:"absolute",left:"0px",top:"0px"});
			
			$(this).hover(
			
				function() {
					
					$(this).css({zIndex:"989"});
					$(this).stop(true,true).animate(
						
						{marginTop:"-=" + $(this).css("height").replace("px","")*fator/2 + "px",marginLeft:"-=" + $(this).css("width").replace("px","")*fator/2 + "px",width:$(this).css("width").replace("px","")*(1+fator) + "px",height:$(this).css("height").replace("px","")*(1+fator) + "px"},
						300
					
					);
					
				},
				function() {
					
					$(this).css({zIndex:"1"});
					$(this).stop(true,true).animate(
						
						{marginTop:"0px",marginLeft:"0px",width:$(this).css("width").replace("px","")*(1/(1+fator)) + "px",height:$(this).css("height").replace("px","")*(1/(1+fator)) + "px"},
						500
					
					);
					
				}
									  
			);
				
		}

	).each(function() {
		
		if (this.complete) {
			
			$(this).load();
			
		}

	});

	$(".expandir_imagem").each(
							   
		function () {				   
		
			$(this).attr("href",$(this).attr("src"));
			$(this).css({cursor:"pointer"});
			
		}
							   
	);
	
	$(".expandir_imagem").fancybox({
			
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	400, 
		'overlayShow'	:	true
		
	});	
	
	$(".link_topo").not(".link_selecionado").hover(
	
		function () {
			
			$(".link_selecionado").stop(true,false).animate(
			
				{backgroundPosition:"(right 0px)",color:"#444444"}, 
				370
			
			);
			$(this).stop(true,false).animate(
			
				{backgroundPosition:"(right -115px)",color:"#444444"}, 
				370
			
			);

		},
		function () {
			
			$(".link_selecionado").stop(true,false).animate(
			
				{backgroundPosition:"(right -115px)",color:"#444444"}, 
				370
			
			);
			$(this).animate(
			
				{backgroundPosition:"(right 0px)",color:"#444444"}, 
				450
			
			);	
			
		}	
	
	);

	$(".frases").hover(
	
		function () {
			
			$(this).stop(true,false).animate(
			
				{backgroundPosition:"(0px 0px)",color:"#333",marginLeft:"20px"}, 
				300
			
			);

			
		},
		function () {
			
			$(this).animate(
			
				{backgroundPosition:"(-540px 0px)",color:"#fff",marginLeft:"0px"}, 
				500
			
			);		
			
		}	
	
	);
	
	$(".item").hover(
	
		function () {
		
			$(this).stop(true,false).animate(
			
				{backgroundPosition:"(0px 0px)", color: "#000", paddingLeft: "50px"},
				300
			
			);	
			
		},
		function () {
			
			$(this).animate(
			
				{backgroundPosition:"(-330px 0px)", color: "#fff", paddingLeft: "30px"},
				500
			
			);
			
		}

	);
	
	$('#mensagem_caixa').dialog({

		show: "drop",
		
		hide: "drop",

		autoOpen: false,

		width: 400,

		modal: true,

		resizable: false,

		buttons: {

			"Close": function() { 

				$(this).dialog("close"); 

			} 

		}

	});				
	
	$('.contato').click(function(){

		$('#entrar_contato_caixa').dialog('open');

		return false;

	});
	
	$('.reserva').click(function(){

		$('#reservar_quarto_caixa').dialog('open');

		return false;

	});
	
	$('#entrar_contato_caixa').dialog({
		
		show: "drop",
		
		hide: "drop",

		autoOpen: false,

		width: 500,

		modal: true,

		resizable: true,

		buttons: {

			"Send": function() { 

				$("#formulario_entrar_contato").submit(); 

			}, 

			"Cancel": function() { 

				$(this).dialog("close"); 

			} 

		}

	});	
	
	$('#reservar_quarto_caixa').dialog({
		
		show: "drop",
		
		hide: "drop",

		autoOpen: false,

		width: 500,

		modal: true,

		resizable: true,

		buttons: {

			"Send": function() { 

				$("#formulario_reservar_quarto").submit(); 

			}, 

			"Cancel": function() { 

				$(this).dialog("close"); 

			} 

		}

	});	
	
	$('.newsletter').click(function(){

		$('#newsletter_caixa').dialog('open');

		return false;

	});
	
	$('#newsletter_caixa').dialog({
		
		show: "drop",
		
		hide: "drop",

		autoOpen: false,

		width: 430,

		modal: true,

		resizable: true,

		buttons: {

			"Assinar": function() { 

				$("#formulario_newsletter").submit(); 

			}, 

			"Cancel": function() { 

				$(this).dialog("close"); 

			} 

		}

	});	
	
	$('#galleria').galleria();
	
	if ($('#thumbs').length!=0) {

		// Initialize Advanced Galleriffic Gallery
		var gallery = $('#thumbs').galleriffic({
			delay:                     2500,
			numThumbs:                 7,
			preloadAhead:              10,
			enableTopPager:            false,
			enableBottomPager:         true,
			maxPagesToShow:            11,
			imageContainerSel:         '#slideshow',
			controlsContainerSel:      '#controls',
			renderSSControls:          true,
			renderNavControls:         true,
			playLinkText:              'Play Slideshow',
			pauseLinkText:             'Pause Slideshow',
			prevLinkText:              '&lsaquo; Previous Photo',
			nextLinkText:              'Next Photo &rsaquo;',
			nextPageLinkText:          'Próxima &rsaquo;',
			prevPageLinkText:          '&lsaquo; Anterior',
			enableHistory:             false,
			autoStart:                 false,
			syncTransitions:           true,
			defaultTransitionDuration: 900,
			onSlideChange:             function(prevIndex, nextIndex) {
				
			},
			onPageTransitionOut:       function(callback) {
				this.fadeTo('fast', 0.0, callback);
			},
			onPageTransitionIn:        function() {
				this.fadeTo('fast', 1.0);
			}
		});	
	
	}

});

