$(function() {

	// fade slides in/out on homepage
	/*
	$("#home-slide-1").show();
	$("#home-slide-2").hide();

	function nextImage() {
		$("#home-slide-1, #home-slide-2").toggle('slow');
	}
	setInterval(function() { nextImage(); }, 5000 );
	*/

	function fade1() {
		$("#home-slide-1").fadeIn("slow");
		$("#home-slide-2").fadeOut("slow");
		setTimeout(function() { fade2(); }, 3000);
	}
	function fade2() {
		$("#home-slide-2").fadeIn("slow");
		$("#home-slide-1").fadeOut("slow");
		setTimeout(function() { fade1(); }, 3000);
	}
	setTimeout(function() { fade1(); }, 3000);

	// hovers on event page
	$(".event-item").hover(function() { 
		$(this).addClass("over");
		var id = $(this).attr("id").replace("event-", "event-photo-");
		$("#"+id).removeClass("hidden");
	}, function() { 
		$(this).removeClass("over");
		$("#image-holder div").addClass("hidden");
	});

	// hovers on sunday page
	$("#location").hover(function() { 
		$("#church").removeClass("hidden");
	}, function() { 
		$("#church").addClass("hidden");
	});

	// convert email addresses
	$("span.mail").each(function() {
		var address = $(this).text();
		address = address.replace(/ at /, "@");
		address = address.replace(/ dot /g, ".");
		var link = $(this).attr("title") || address;
		$(this).html('<a href="mailto:'+address+'">'+link+'</a>');
	});
   
});
