$(document).ready(function() {

	$('a.external').attr('target', '_blank');

	$('#slideshow img').css({opacity: 0}).show();
	$('#slideshow img:first').css({opacity: 1});
	setInterval(function() {
		var $active = $('#slideshow img.active');
		if ($active.length == 0)
			$active = $('#slideshow img:last');
		var $next = $active.next().length ? $active.next() : $('#slideshow img:first');
		$active.addClass('last-active');
		$next.css({opacity: 0}).addClass('active').animate({opacity: 1}, 1000, function() {
			$active.removeClass('active last-active');
		});
	}, 5000);

	$('div.gallery').each(function() {
		var id = $(this).attr('id');
		$('#'+id+' a').click(function() {
			$('#'+id+' div.big').css('background', 'transparent url(' + $(this).attr('href') + ') center no-repeat');
			return false;
		});
		$('#'+id+' a:first').trigger('click');
	});

});

Cufon.replace(['h1', 'h2', 'h3']);