$(function(){
	
	$('.titulo .bread a:last-child').addClass("last");
	
	$(".lista-eventos").find("li a img").load(function(){
		var $height_img = $(this).height();
		var $height_a = $(this).parent().height();
		if($height_img >= $height_a)
		{
			var $marginTop = parseInt((diff=($height_img - $height_a)) / 3.5) * -1;
			$(this).css({"margin-top": $marginTop + "px"});
		}
		else
		{
			$(this).height($height_a);
		}
	});
	
	$('#EventoCategoriaId').change(function(){
		window.location.href = window.defaultUrl + "eventos/categoria/" + this.value;
	}).parent().css({"visibility": "visible"});
	
	if($("#exibe-eventos").length > 0)
	{
		$("#galeria").flash({
			url: window.defaultUrl + "swf/galeria.swf",
			width: "100%",
			height: "100%",
			wmode: "transparent",
			allowFullScreen: "true",
			variables: {
				"defaultUrl": window.defaultUrl,
				"galeria_id": window.galeria_id
			}
		});
	}
	
	$("#conteudo .videos-relacionados ul li a img").each(function(){
		
		var $replaceImage = true;
		
		if(jQuery.browser.msie && /MSIE (\d+\.\d+);/.test(navigator.userAgent))
		{
			var ieversion = new Number(RegExp.$1);
			if(ieversion >= 6 && ieversion < 7)
			{
				$replaceImage = false;
			}
		}
		
		if($replaceImage)
		{
			$src = $(this).attr("src");
			$(this)
				.attr("src", window.defaultUrl + "imagens/bt_video.png")
				.css({
					"background": "url(" + $src + ")"
				});
		}
		
	});
	
	if(!empty($("#conteudo div.outros-eventos")) || !empty($("#conteudo div.videos-relacionados")))
	{
		$("#linha-galeria").show();
	}
	
});

function refreshGaleria(h)
{
	if(h < 460)
	{
		return false;
	}
	
	$("#galeria").height(h-5);
}

$(window).load(function(){
	$(".lista-eventos").find("li a img").trigger("load");	
});