﻿// Tira o bug de background em links no IE
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(r) {}

(function($){
// Redimensiona as legendas de acordo com suas respectivas fotos (obs.: tem que ser no window.load por causa de bug no Chrome) 
$(window).load(function(){
	$('.legenda').each(function(){
		$(this).css('width', $(this).siblings('img').width());
	});
});

$(function(){		
	// Box de newsletter do rodapé
	$('.boxNewsLetter').css({
		'bottom': '85px',
		'opacity': 0
	});
	
	$('.btAssineNews').click(function(e){
		e.preventDefault();
		
		if ($(this).hasClass('news_ativo')){
			$('.boxNewsLetter').animate({
				'bottom': '85px',
				'opacity': 0
			}, 200, function(){
				$('.boxNewsLetter').css('visibility', 'hidden');	
			});
			
			$(this).removeClass('news_ativo')
		
		} else {
			$('.boxNewsLetter').css('visibility', 'visible');
			$('.boxNewsLetter').animate({
				'bottom': '55px',
				'opacity': 1				
			}, 200);
			
			$(this).addClass('news_ativo');
		}
	});
	
	$('input[placeholder]').placeholder();
		
	// Twitter - rodapé
	$.twitter('plazahoteis', 1, function(d){
		$('.boxTwitter').find('p').html(d[0].text);
	});
	
	// Botão de comentários dos posts
	$('.btVerComentarios').click(function(e){
		e.preventDefault();
		
		if ($(this).hasClass('p5')){
			$(this)
				.removeClass('p5').addClass('p7')
				.siblings('.hide')
				.slideDown();
		} else {
			$(this)
				.removeClass('p7').addClass('p5')
				.siblings('.hide')
				.slideUp();	
		}
	});
	
	// Borda das imagens nos posts
	$('img.insetBorder').each(function(){
		$(this).wrap('<div />').parent().append('<b/>')[0].className = this.className;
		this.className = '';
	});
	
});

}(jQuery));
