////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 9/21/2015	ELL
// Modified: 4/6/2016	ELL
// Restructured to work with having object passed to correct bugs with using multiple players.

function LoadMedia(media_player)
{
	var jquery_jplayer = "#jquery_jplayer_" + media_player.media_num;
	var jp_container = "#jp_container_" + media_player.media_num;
	if (media_player.media_type == "audio")
	{
		$(jquery_jplayer).jPlayer({
			ready: function (event) {
				$(this).jPlayer("setMedia", {
					title: media_player.audio_title,
					mp3: media_dir_rel + media_player.audio_mp3,
					m4a: media_dir_rel + media_player.audio_m4a,
					oga: media_dir_rel + media_player.audio_oga,
					webma: media_dir_rel + media_player.audio_webma,
					wav: media_dir_rel + media_player.audio_wav,
					fla: media_dir_rel + media_player.audio_fla,
					rtmpa: media_dir_rel + media_player.audio_rtmpa,
					poster: media_dir_rel + media_player.audio_poster
				});
			},
			swfPath: scripts_dir_rel + "/jplayer/jplayer",
			supplied: "mp3, m4a, oga, webma, wav, fla, rtmpa",
			cssSelectorAncestor: jp_container,
			wmode: "window",
			useStateClassSkin: true,
			autoBlur: false,
			smoothPlayBar: true,
			keyEnabled: true,
			remainingDuration: true,
			toggleDuration: true
		});
	}
	else if (media_player.media_type == "video")
	{
		if (media_player.video_width == "640")	{
			video_width = "640px";
			video_height = "360px";
			video_class = "jp-video-360p";
		}
		else if (media_player.video_width == "480")	{
			video_width = "480px";
			video_height = "270px";
			video_class = "jp-video-270p";
		}
		else if (media_player.video_width == "full")	{
			video_width = "100%";
			video_height = "100%";
			video_class = "jp-video-full";
		}
		$(jquery_jplayer).jPlayer({
			ready: function () {
				$(this).jPlayer("setMedia", {
					title: media_player.video_title,
					m4v: media_dir_rel + media_player.video_m4v,
					ogv: media_dir_rel + media_player.video_ogv,
					webmv: media_dir_rel + media_player.video_webmv,
					flv: media_dir_rel + media_player.video_flv,
					rtmpv: media_dir_rel + media_player.video_rtmpv,
					poster: media_dir_rel + media_player.video_poster
				});
			},
			swfPath: scripts_dir_rel + "/jplayer/jplayer",
			supplied: "m4v, flv, ogv, webmv, rtmpv",
			cssSelectorAncestor: jp_container,
			size: {
				width: video_width,
				height: video_height,
				cssClass: video_class
			},
			useStateClassSkin: true,
			autoBlur: false,
			smoothPlayBar: true,
			keyEnabled: true,
			remainingDuration: true,
			toggleDuration: true
		});
	}
	return(jquery_jplayer);
}
