$(document).ready(function(){
	
});
$(window).load(function () {
	$('.post').each(function (i) {
	 	var playing = '.playing_'+i;
       $(playing).css('opacity', 0.5);
    });
	$('.play').click(function() {						   
		var whichID = $(this).attr('id').substr(5); // This is the item number
		if ($(this).find('[name="settings"]').length > 0) {
			var media = $(this).find('[name="settings"]').attr('id');
		} else {
			var image = $(this).find('[name="image"]').attr('id');
			var media = '<img src="'+image+'" height="516px" />';
		}
		var which = $(this).find('[name="which"]').attr('value');
		var viewer = '#viewer_'+which;
		var playing = '.playing_'+which;
		var play = 'playing_'+which;
		$(playing).fadeTo('slow', 1, function() { $(this).removeClass(play); });
		$(this).find('img#fade').fadeTo('slow', 0.5, function() { $(this).addClass(play); });
		$(viewer).empty();
		$(viewer).append(media);
	});
	
	$("#splashPage").fadeIn();
	
	$('#splashPage').cycle({ 
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed: 300,
		prev: '#prev',
        next: '#next'
	});
	/*
	$('#pause').click(function() { 
		$('#splashPage').cycle('pause'); 
	});
	$('#play').click(function() { 
		$('#splashPage').cycle('play'); 
	});
	*/
	$('#play').toggle(function() {
	  $('#splashPage').cycle('pause');
	  $(this).text('Play');
	}, function() {
	  $('#splashPage').cycle('resume', true);
	  $(this).text('Pause');
	});
})
