$(document).ready(function() {
    AudioPlayer.setup("js/audio-player.swf", { width: 200 });
    
    var audioCount = 0;
    
    if (swfobject.getFlashPlayerVersion().major) {    
        $('.audio').each(function() {
            audioCount++;
            playerId = "player-" + audioCount;
        
            audioLink = $(this).find('a[href^=mp3]').get(0);
            audioFile = $(audioLink).attr('href');
            audioTitle = $(audioLink).text();
        
            $(audioLink).before($('<div id="' + playerId + '"></div>'));
            $(audioLink).replaceWith(audioTitle);
        
            AudioPlayer.embed(playerId, {
    		    'soundFile': audioFile,
    		    'transparentpagebg': 'yes',
    		    'noinfo': 'yes'
    		});		
        });
    }
    
    $('a[href$=jpg]').fancybox({
	    'titleShow': false,
	    'overlayOpacity': .8,
	    'overlayColor': '#000'
	});
	
	function modalOptions(width, height)
	{
	    return {
	        'width': width,
	        'height': height,
	        'autoDimensions': false,
	        'titleShow': false,
    	    'overlayOpacity': .8,
    	    'overlayColor': '#000'
	    }
    }
	
	$('a[href^="audio/"]').each(function() {
	    $(this).attr('href', $(this).attr('href') + '?modal=1');
	    $(this).fancybox(modalOptions(480, 240));
	});

	$('a[href^="gear/"]').each(function() {
	    $(this).attr('href', $(this).attr('href') + '?modal=1');
	    $(this).fancybox(modalOptions(480, 540));
	});
});

