$(document).ready(function() {

    var gallery = $('#portfolio').galleriffic({
		delay: 500,
		thumbClass: 'series',
		thumbnailLinkObj: 'a',
		captionObj: 'cite',
		numThumbs:                 100,
		preloadAhead:              2,
		imageContainerSel:         '#feature',
		captionContainerSel:       '#caption',
		enableKeyboardNavigation:  true,
		defaultTransitionDuration: 100
    });	
	$("#portfolio ul.series a").click(function(){ 
		$("#slideshow").show(); 
	});
	
    $("#slideshow a.close").click(function(e) {
		$("#slideshow").hide();
    });


	function pageload(hash) {
		// hash doesn't contain the first # character.
		if(hash) {
		        $("#slideshow").show();
				$.galleriffic.gotoImage(hash);
			} else {
				$("#slideshow").hide();
			}
	}

	// Initialize history plugin.
	// The callback is called at once by present location.hash. 
	$.history.init(pageload);

});


$(document).keydown(function(e) {
    if (e.keyCode == 27) {
        $("#slideshow").hide();
    }
});
