
jQuery(document).ready(function() {
	var $ = jQuery;
	
	if($('.am-layout').length > 0) $('body').addClass('amember');
});

jQuery(window).load(function() {
	var $ = jQuery;

	$('.sample_video_list:not(.no-preview)').each(function() {
		var vurl = $('.bja_video:first-child .video_title a', this).attr('href');
		vurl = vurl.substr(1, vurl.length - 1);
		iurl = $('.bja_video:first-child .video_thumbnail img', this).attr('src');

		var div_id = $('.video_player_container div', this).attr('id');
		jwplayer(div_id).setup({
			flashplayer: "http://www.blackjackapprenticeship.com/wp-content/uploads/jw-player-plugin-for-wordpress/player/player.swf",
			file: vurl,
			controlbar: "over",
			image: iurl,
			height: 300,
			width: 400,
		});

		$('.bja_video a', this).click(function(e) {
			e.preventDefault();
			vurl = $(this).attr('href');
			vurl = vurl.substr(1, vurl.length - 1);
			iurl = $(this).parents('.bja_video').find('.video_thumbnail img').attr('src');

			jwplayer(div_id).setup({
				flashplayer: "http://www.blackjackapprenticeship.com/wp-content/uploads/jw-player-plugin-for-wordpress/player/player.swf",
				file: vurl,
				controlbar: "over",
				image: iurl,
				height: 300,
				width: 400,
			});
		});
	});

	$('.membership-options-wrap a.cta-button').click(function(e) {
		e.preventDefault();
		if($(this).siblings('.membership-options-list').css('display') != 'none') $(this).siblings('.membership-options-list').hide();
		else {
			$('.membership-options-list').hide();
			$(this).siblings('.membership-options-list').show();
		}
		return false;
	});
	$('body').click(function(e) {
		$('.membership-options-list').hide();
	});

});
