$(document).ready(function() {		
	
	$("#clippings").tinycarousel();
	
	$(".img_clipping").ezpz_tooltip({
		contentId: 'teste',
		showContent: function(content) {
			content.fadeIn('slow');
		},
		hideContent: function(content) {
			// if the showing animation is still running, be sure to stop it
			// and clear the animation queue. otherwise, repeatedly hovering will
			// cause the content to blink.
			content.stop(true, true).fadeOut('slow');
		}
	});
	
	$(".bt_newsletter").click(function() {
    	$(".bt_newsletter").toggle();
	  	$("#form_newsletter").toggle();
	});
	
	$(".bt_enviar").click(function() { 
		alert("Cadastro efetuado com sucesso!");
		$("#quick_subscribe_form").submit();
	  	$("#form_newsletter").toggle();
		$(".bt_newsletter").toggle();
	});
	
	$(".menu_pai a").click(function() {    	
		$(".menu_filho").fadeOut();
		$(this).parent().parent().siblings(".menu_filho").fadeIn();
	});
	
	$(".lnk_loja").click(function() {    	
		$("#mapa_loja").html($(this).parent().next(".google_maps").html());
		$("#endereco_loja").html($(this).parent().next(".google_maps").next(".endereco").html());
	});
	
	$(".lnk_multimarca").click(function() {    	
		$("#mapa_multimarca").html($(this).parent().next(".google_maps").html());
		$("#endereco_multimarcas").html($(this).parent().next(".google_maps").next(".endereco").html());
	});
	
	$(window).resize(function() {
			var ratio = 768/1024;
			var imagewidth = 1024;
			var imageheight = 768;
			var browserwidth = $(window).width();
			var browserheight = $(window).height()-170;
			var offset;			
			
			//Resize image to proper ratio
			if ((browserheight/browserwidth) > ratio){
				imageheight = browserheight;
				imagewidth = (browserheight / ratio);
			} else {
				//imagewidth = browserwidth ;
				//imageheight = (browserwidth * ratio);
				imageheight = browserheight;
				imagewidth = (browserheight / ratio);
			}
			
			$(".ad-image").css('width', browserwidth);
			$(".ad-image").css('height', imageheight);
			$(".ad-image img").attr('width', imagewidth);
			$(".ad-image img").attr('height', imageheight);
			$(".ad-image-wrapper").css('width', browserwidth);
			$(".ad-image-wrapper").css('height', imageheight);
			$(".ad-nav").css('width', browserwidth-40);
		});

});

function movedown(){
	if ($("#posts").css("top")>=($("#posts").height()*(-1)+100))
	{
		$("#posts").css("top",$("#posts").css("top")-95);
	}
}

function moveup(){
	if ($("#posts").css("top")<=0)
	{
		$("#posts").css("top",$("#posts").css("top")+95);
	}
}

/*
function resizebackground()
{
	//Define image ratio
	var ratio = 768/1024;
	var headerheight = 10;
	var footerheight = 10;
	
	//Gather browser and current image size
	var imagewidth = $("#background").width();
	var imageheight = $("#background").height();
	var browserwidth = $(window).width();
	var browserheight = $(window).height()-headerheight-footerheight;
	var offset;

	//Resize image to proper ratio
	if ((browserheight/browserwidth) > ratio){
		$("#background img").height(browserheight);
		$("#background img").width(browserheight / ratio);
		$("#background img").children().height(browserheight);
		$("#background img").children().width(browserheight / ratio);
		
		$("#background").height(browserheight);
		$("#background").width(browserheight / ratio);
		$("#background").children().height(browserheight);
		$("#background").children().width(browserheight / ratio);		
		
	} else {
		$("#background img").width(browserwidth);
		$("#background img").height(browserwidth * ratio);
		$("#background img").children().width(browserwidth);
		$("#background img").children().height(browserwidth * ratio);
		
		$("#background").width(browserwidth);
		$("#background").height(browserwidth * ratio);
		$("#background").children().width(browserwidth);
		$("#background").children().height(browserwidth * ratio);		
		
	}
	
	//$("#background").children().css('left', (browserwidth - $(this).width())/2);
	//$("#background").children().css('top', (browserheight - $(this).height())/2);
}
*/


