$(function() {

	$('.introvideo, .playvideo').click(function(){
		switch($(this).html()) {
			case 'Intoduction Video':
				if(!$('#introVideo').length) {
					break;
				}
				
				$('#introVideo .header').html($(this).attr('title'));
				$("#introVideo .content").html('<embed id="ivplayer" name="ivplayer" ' +
						'src="/jwplayer/player.swf" width="640" height="480" allowscriptaccess="always" allowfullscreen="true" ' +
						'flashvars="file='+introVideoURL+'">');
				$('#introVideo').popIn();
				break;
			
			case 'Advanced Video':
				if(!$('#advancedVideo').length) {
					break;
				}
				
				$('#advancedVideo .header').html($(this).attr('title'));
				$("#advancedVideo .content").html('<embed id="ivplayer" name="ivplayer" ' +
						'src="/jwplayer/player.swf" width="640" height="480" allowscriptaccess="always" allowfullscreen="true" ' +
						'flashvars="file='+advancedVideoURL+'">');
				$('#advancedVideo').popIn();
				break;
				
			default:
				if(!$('#overviewVideo').length) {
					break;
				}
				
				$('#overviewVideo .header').html($(this).attr('title'));
				$("#overviewVideo .content").html('<embed id="overview_player" name="overview_player" ' +
						'src="/jwplayer/player.swf" width="640" height="480" allowscriptaccess="always" allowfullscreen="true" ' +
						'flashvars="file='+overviewVideoURL+'">');
				$('#overviewVideo').popIn();
				break;
		}
	});

	$('.ajax').click(function(){
		var h = $(this).attr('href');
		var t = $(this).html();
		$.get(h, function(data){
			$('body').append('<table class="popup" style="display: none;"><tr><td class="p">'
							+'	<div id="ajaxLink" class="block">'
							+'		<div class="header">'+t+'</div><a class="close"><span>&times;</span> Close</a>'
							+'		<div class="content">'
							+			data
							+'		</div>'
							+'	</div>'
							+'</td></tr></table>');
			$('#ajaxLink').parents('table').fadeIn().find('.close').click(function(){
				$(this).parents('table').fadeOut(function(){
					$(this).remove();
				})
			});
		});
		return false;
	});

});

