

	//** Initialize Video player =======================
	function runVideoPlayer(video_name,video_poster) {
		jwplayer('videoContainer').setup({
			autostart: false,
			controlbar: 'bottom',
			volume: 80,
			width: 500,
			height: 306,
			file: video_name,
			image: video_poster,
			backcolor:'#b9b7aa',
			frontcolor:'#fcf8ef',
			lightcolor:'#726c58',
			screencolor:'#b8b8aa',
			stretching:'uniform',
			wmode:'transparent',
			bgcolor:'#000000',
			modes: [
        		{type: 'flash', src: '/js/player.swf'},
        		{type: 'html5'}
    		]
			
		});
	}
	
	
	function loadPlayListItem(playlist_item, autoplay) {
		
		var	video_location = playlist_item.attr('href').match('youtu') == 'youtu' ? 'youtube' : 'local',
			video_poster_path = playlist_item.children('img').attr('src');
			
		if (video_location == 'youtube') {
			
			var	video_file = 'http://www.youtube.com/watch?v='+playlist_item.attr('href').replace('http://youtu.be/', '');
			
		} else {
		
			var	video_file = playlist_item.attr('href');
		
		}
		
		runVideoPlayer(video_file,video_poster_path);
		
		
		if (autoplay == 'play') {
			
			jwplayer("videoContainer").play(true);
		
		}
		
		return false
	}	
	
	
$(document).ready(function($) {

	loadPlayListItem($("#featured_video a"), "noplay");
	
	
	$('.playlist-item').each(function () {
		
		if ($(this).find('img').attr('src').match('youtu') == 'youtu') {
			$(this).find('img').addClass('youtube');
		}
		
	});
	
	$(".playlist-item a").click(function() {
		
		loadPlayListItem($(this), "play");
		return false
	
	});
	
	
	
});
