$(document).ready(function() {
	$(".event-btn").css("margin-top", "-10px");
	$(".event").toggle(
		function(e) {
			
			if (!$(this).is(':animated') ) 
			{
			
			if(e.target.className != "event-btn")
			{	
				return
			}
			$(this).animate({height: "412px"}, 300, "linear", openComplete);
			$(this).children(".event-btn").hide("fast");
			
			
			}	
		},
		function(e) {
			if (!$(this).is(':animated') ) 
			{
			if(e.target.className != "event-map")
			{
				
				//$(this).attr("disabled", "disabled");
				$(this).animate({
					height: "72px"
				}, 300, "linear", closeComplete);
	
			}
			else
			{
				//alert($(this).children(".event-map"));
			}
		}
		}
	);
	
	
	
	function openComplete()
	{
		//alert("complete open");
		//$(this).attr("enabled", "enabled");
		$(this).children(".event-btn").css("margin-top", "5px");
		$(this).children(".event-btn").css("background-image", "url('../images/details_close.png')");
		$(this).children(".event-btn").show("slow");
		$(this).children(".event-details").show("slow");
		
	}
	
	function closeComplete()
	{
		//alert("complete close");
		$(this).children(".event-btn").css("margin-top", "-10px");
		$(this).children(".event-btn").css("background-image", "url('../images/viewdetails_event.png')");
		$(this).children(".event-btn").show("slow");
		$(this).children(".event-details").hide();
		
		//$(this).attr("enabled", "enabled");
	}
	
	$(".event").hover(
		function() {
			
			if ($(this).children(".event-details").css("display") != "block") {
				$(this).children(".event-btn").css("background-image", "url('../images/viewdetails_evento.png')");
			}
			$(this).addClass("event-open");
		},
		function() {
			if ($(this).children(".event-details").css("display") != "block") {
				$(this).children(".event-btn").css("background-image", "url('../images/viewdetails_event.png')");
				$(this).removeClass("event-open");
			}
		}
	);	

});


