$(document).ready(function() {
	
	//home
	if ($("#home").length>0) {
		var h = $(window).height();
		var h2 = $(".intro").height();
		var m = Math.ceil((h-h2)/2);
		$(".intro").css("margin-top",m+'px');
		$(".intro").fadeIn(1000);
	}
	
	//fixes ie7 e ie6
	if ($("#mainContent").length>0 && $.browser.msie && ($.browser.version=="6.0" || $.browser.version=="7.0")) {
		$("body").addClass("ie");
	}
	
	
	//menu
	$("#footer ul li a").hover(function(){
		$(this).animate({fontSize: '24px'},100);
	},function(){
		$(this).animate({fontSize: '20px'},100);
	});
	
	//fotos
	if ($(".fotos").length>0) {
		var i = 0;
		$(".fotos img").each(function(){
			$(this).wrap('<div class="foto" id="foto_'+i+'">');
			i++;
		});
		$(".fotos").before('<a href="#" class="fotobtn prev">Anterior</a><a href="#" class="fotobtn next">Proxima</a>');
		$(".fotos").after('<ul class="nav">').cycle({
			fx:		'fade',
			timeout: 0,
			pager:	'.nav',
			pagerAnchorBuilder: function(idx, slide) { 
				var path = $(".fotos #foto_"+idx+" img").attr("src");
				return '<li class="shadow"><a href="#"><img src="' + path + '" /></a></li>'; 
			},
			cleartype: 'false',
			prev:	'.prev',
			next:	'.next',
			before:	function(){ $(".fotobtn").addClass("hidebtn"); },
			after:	function(){ $(".fotobtn").removeClass("hidebtn"); }
		});
		
		$(".fotos .foto img").hover(function(){
			var w = $(this).width();
			var h = $(this).height();
			var wbtn = Math.ceil(w/2);
			var o = $(this).offset();
			$(".fotobtn").css("height",h+"px").css("width",wbtn+"px").css("top",(o.top+2)+"px");
			$(".prev").css("left",(o.left+2)+"px");
			$(".next").css("left",(o.left+wbtn+2)+"px");
			$(".fotobtn").css("display","block");
		});
		$(".fotobtn, .prev, .next").mouseout(function(){
			$(".fotobtn").hide();
		});
	}
	
	//galeria
	if ($(".galeria").length>0) {
		$(".galeria .nav li a").lightBox({
			overlayOpacity: 0
		});
	}
	
	//valida contato
	if ($(".contatp").length>0) {
		$(".contato .form form").submit(function(){
			var ok = true;
			return ok;
		});
	}
	
	//suítes
	$("#left a.mais").click(function(){
		var lnk = $(this).attr("href");
		window.open(lnk,'suites','width=560,height=600,scrollbars=yes');
		return false;
	});
	
	//tarifas
	$("#footer ul li.m8 a").click(function(){
		var lnk = $(this).attr("href");
		window.open(lnk,'tarifas','width=1030,height=600,scrollbars=yes');
		return false;
	});
	
	//aerpoport
	if ($("div.aeroporto-modal").length>0) {
		$("a.aeroporto").click(function(){
			var of = $(this).offset();
			$(".aeroporto-modal").css("left",(of.left+60)+'px').css("top",(of.top-10)+'px').fadeIn("fast");
			return false;
		});
		$("a.aeroporto-fechar").click(function(){
			$(".aeroporto-modal").fadeOut("fast");
			return false;
		});
	}
	
	
});

