﻿
function PlayVideoClip(fileName, duration, playerID, linkContainerID, scroll)
{
	StopAllClips();
	
	// highlight the link background that was just clicked (if a link container id is available)
	if (linkContainerID)
	{
		$j("#" + linkContainerID).addClass("selected");
	}
	
	// get the player values
	var playerPath = eval("__RHMediaPlayersPlayerPath_" + playerID);
	var playerImagePath = eval("__RHMediaPlayersPlayerImagePath_" + playerID);
	var playerFileName = eval("__RHMediaPlayersPlayerFileName_" + playerID);
	var playerSkinFileName = eval("__RHMediaPlayersPlayerSkinFileName_" + playerID);
	var playerFlashVersion = eval("__RHMediaPlayersPlayerFlashVersion_" + playerID);
	var playerWidth = eval("__RHMediaPlayersPlayerWidth_" + playerID);
	var playerHeight = eval("__RHMediaPlayersPlayerHeight_" + playerID);	
	var allowFullScreen = eval("__RHMediaPlayersAllowFullScreen_" + playerID);
	var playerStaticHtml = eval("__RHMediaPlayersPlayerStaticHtml_" + playerID);
	
	// the FlashObject script component is used to write flash movies to the page
	var fo = new FlashObject(playerPath + playerFileName + "?VideoUrl=" + fileName + 
		"&SkinUrl=" + playerPath + playerSkinFileName + "&Duration=" + duration, "VideoPlayer", playerWidth, playerHeight, playerFlashVersion, "#FFFFFF");
	fo.addParam("wmode", "transparent");
	if (allowFullScreen)
		fo.addParam("allowFullScreen", allowFullScreen);
	fo.write(playerID);
	
	// scroll to the player
	if (scroll) 
	{
		$j("#" + playerID).scrollTo(1000);
	}
}
function PlayAudioClip(fileName, duration, playerID, linkContainerID, scroll)
{
	StopAllClips();
	
	// highlight the link background that was just clicked (if a link container id is available)
	if (linkContainerID)
	{
		$j("#" + linkContainerID).addClass("selected");
	}
	
	// get the player values
	var playerPath = eval("__RHMediaPlayersPlayerPath_" + playerID);
	var playerImagePath = eval("__RHMediaPlayersPlayerImagePath_" + playerID);
	var playerFileName = eval("__RHMediaPlayersPlayerFileName_" + playerID);
	var playerSkinFileName = eval("__RHMediaPlayersPlayerSkinFileName_" + playerID);
	var playerFlashVersion = eval("__RHMediaPlayersPlayerFlashVersion_" + playerID);
	var playerWidth = eval("__RHMediaPlayersPlayerWidth_" + playerID);
	var playerHeight = eval("__RHMediaPlayersPlayerHeight_" + playerID);
	var playerStaticHtml = eval("__RHMediaPlayersPlayerStaticHtml_" + playerID);

	// the FlashObject script component is used to write flash movies to the page
	var fo = new FlashObject(playerPath + playerFileName + "?AudioUrl=" + fileName + 
		"&SkinUrl=" + playerPath + playerSkinFileName + "&Duration=" + duration, "AudioPlayer", playerWidth, playerHeight, playerFlashVersion, "#FFFFFF");
	fo.addParam("wmode", "transparent");
	fo.write(playerID);

	// scroll to the player
	if (scroll) 
	{
		$j("#" + playerID).scrollTo(1000);
	}
}
function StopAllClips()
{
	ClearAllPlayers();
	ClearAllLinkHighlights();
}
function ClearAllPlayers()
{
	// for each video player
	$j("div.videoplayer").each(function (i) {
		// get the player values
		var playerImagePath = eval("__RHMediaPlayersPlayerImagePath_" + this.id);
		var playerFileName = eval("__RHMediaPlayersPlayerFileName_" + this.id);
		var playerWidth = eval("__RHMediaPlayersPlayerWidth_" + this.id);
		var playerHeight = eval("__RHMediaPlayersPlayerHeight_" + this.id);
		var playerStaticHtml = eval("__RHMediaPlayersPlayerStaticHtml_" + this.id);
		
		// clear all player containers; this prevents players from being able to overlap each other
		// if the user has clicked successive 'play now' links (without waiting for a clip to finish playing)
		$j(this).empty();
		$j(this).append(playerStaticHtml);
	});
	// for each audio player
	$j("div.audioplayer").each(function (i) {
		// get the player values
		var playerImagePath = eval("__RHMediaPlayersPlayerImagePath_" + this.id);
		var playerFileName = eval("__RHMediaPlayersPlayerFileName_" + this.id);
		var playerWidth = eval("__RHMediaPlayersPlayerWidth_" + this.id);
		var playerHeight = eval("__RHMediaPlayersPlayerHeight_" + this.id);
		var playerStaticHtml = eval("__RHMediaPlayersPlayerStaticHtml_" + this.id);
		
		// clear all player containers; this prevents players from being able to overlap each other
		// if the user has clicked successive 'play now' links (without waiting for a clip to finish playing)
		$j(this).empty();
		$j(this).append(playerStaticHtml);
	});
}
function ClearAllLinkHighlights()
{
	$j("div.rhmediaplayers_list_item").removeClass("selected");
	$j("div.rhmediaplayers_featured_item").removeClass("selected");
}

