$(function() {
		// If the media area has more than 1 image, cycle it!
	if ($(".media img").length > 1) {
		$(".media").cycle({
			timeout: 7500,
			speed: 2000
		});
	}
	
		// Activate the tablesorter(s)
	$("body#past_projects #fancy-table").tablesorter({
		sortList: [[0,0]]
	});
	$("body#staff #fancy-table").tablesorter({
		sortList: [[1,0]]
	});
	
		// Make the table rows clickable
	$("#fancy-table tr").bind("click", function() {
		var loc = $(this).find("td:first a").attr("href");
		window.location.href = loc;
	});
	
		// Enable flash fallback for appropriate devices
	if (!Modernizr.video.h264) {
		$("video").each(function() {
			var $self, $video;
			$self = $(this);
			$video = $('<div class="flow-player-container"></div>');
			$video
				.width($self.attr("width"))
				.height($self.attr("height"))
				.flowplayer(window.location.protocol + "//" + window.location.host + '/assets/flowplayer/flowplayer-3.2.5.swf', {
					clip: {
						url: $self.attr('src'),
						autoPlay: false
					}
				});
				
				// Replace the html5 video tag with the flash fallback
			$self.replaceWith($video);
		});
	}

});
