$(function () {
	$('a.video').click(function() {
		var videoPath = $(this).attr('href');
		var videoFile = videoPath.split('/');
		var videoName = videoFile[videoFile.length - 1];
		if (videoFile[0] == "..") {
			var playerPath = '../video/player.swf';
		} else {
			var playerPath = 'video/player.swf';
		};
		$('#mediaBox').show();
		$('#coverScreen').animate({"opacity": 0.8}, 1500);
		$('#mediaPlayer').show();
		if ($.flash.available) {
			$('#videoReplace').flash({ 
				// test_flashvars.swf is the flash document 
				swf: playerPath, 
				// these arguments will be passed into the flash document 
				params: { 
					allowfullscreen: 'true', 
					allowscriptaccess: 'always', 
					wmode: 'transparent'			
				}, 
				flashvars: { 
					file: videoName, 
					backcolor: 'ffffff', 
					controlbar: 'none',
					dock: 'false', 
					autostart: 'true', 
					stretching: 'fill'			
				},
				height:360,
				width:480,
				id: 'video'
			});
		} else {
			$('#videoReplace').html('<p>You must have <a href="http://get.adobe.com/flashplayer/">Abode Flash</a> installed to view this video</p>');
		}
		return false;
	});
	$('img.closeMedia').click (function() {
		$('#coverScreen').animate({"opacity": 0}, 500);
		$('#mediaPlayer').hide();
		$('#mediaBox').hide(500);
		$('#videoReplace').html('');
	});
});
