$(document).ready(function() {

//fancy things

	$("div.entry").fadeIn(400);

	$(".topnav a").click(function () {
		$(".topnav a").removeClass("selected");
		$(this).addClass("selected");
		$("div.entry").fadeTo(400, 0);
	});

//	$(".info h2 a").click(function () {
//		$("div.entry").fadeOut();
//	});


////////////////////////////////////////////////////////

//set up slideshows

var count = 1;

do {
				function onAfter(curr,next,opts) {
					$(this).parent().parent().find('.caption').html('<span>' + (opts.currSlide + 1) + '</span> of &nbsp;<span>' + opts.slideCount + '</span>');
				}

				$('.slideshow' + count).cycle({
					fx: 'fade',
					after: onAfter,
					speed: 300,
					timeout: 0,
					prev: '.prev' + count,
					next: '.next' + count
				});

count++;
} while (count <= $(".photos").length);


////////////////////////////////////////////////////////


//smooth scrolling 

    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 600);
                return false;
            }
        }
    });


});
