$(document).ready(function() {
	/*
		Section: catalog
	*/

	// Append non-playing embed to preload sound
	// No preloading in IE

		// Relative url
		// var src = '../../sounds/snapshot.wav';

		// Absolute url
		var src = 'http://www.wolfslittlestore.be/2009/sounds/snapshot.wav';
		$('body').append('<embed style="height:0;line-height:0;visibility: hidden;position:absolute:left:-9000px;top:-9000px;" loop="false" src="' + src + '" autostart="false" hidden="true" />');

	// Snapshot animation with sound
	$('#catalog #entries a')
		.bind({
			click: function(event) {

				event.preventDefault();

				// Find image child
				var img = $(this).find('img');

				// Fade out
				img.stop().animate({ opacity: 0 }, { duration: 200, specialEasing: { opacity: 'easeInSine' }});

				// Play sound through jQuery sound plugin
				// Sound is short so we remove it from the DOM after timeout
				$.sound.play('http://www.wolfslittlestore.be/2009/sounds/snapshot.wav', { timeout: 500 });

				// Fade back in
				img.animate({ opacity: 1 }, { duration: 400, specialEasing: { opacity: 'easeOutSine' }});

				// Javascript redirect
				var url = $(this).attr('href');
				window.location = url;
			}
		});
});