/*<script type="text/javascript" src=\"http://www2.brightcove.com/guidepub/badgepub/createbadge.js\"></script>*/

function embedPlayer($playerID,$vid,$pType,$pW,$pH) {
// new players
if (!$vid) $vid = "null";
if (!$pType) $pType = "single_title_2";
if (!$pH) $pH = 0;
if (!$pW) $pW = 0;
if ($pType == "compact_tabbed_2") {
	$pW = 790;
	$pH = 620;
}
else if ($pType == "compact_minizing_with_list_2" || $pType == "compact_minizing") {
	$pW = 300;
	$pH = 361;
}
else if ($pType == "single_title_with_logo_2") {
	$pW = 510;
	$pH = 500;
}
else if ($pType == "single_title_with_lab_2") {
	$pW = 510;
	$pH = 610;
}
else if ($pType == "single_title_2") {
	if ($pW == 0) $pW = 486;
	if ($pH == 0) $pH = 412;
}
else if ($pType == "embedded" || $pType == "custom") {
	if ($pW == 0) $pW = 480;
	if ($pH == 0) $pH = 360;
}
else if ($pType == "tabbed_1.1") {
	$pW = 988;
	$pH = 540;
}
else if ($pType == "tabbed_2") {
	$pW = 988;
	$pH = 550;
}
else if ($pType == "thumbnail_2") {
	$pW = 917;
	$pH = 606;
}
else if ($pType == "minimizing_2") {
	$pW = 520;
	$pH = 587;
}

// now we do some player stuff...
	var config = new Array();
	var $refID=null;
	var $vidID=null;
    if ("string" != typeof $vid) {
	$vidID=$vid;
	} else {
	$refID=$vid;
	}
	config["videoId"] = $vid;
	config["videoRef"] = $refID;
	config["lineupId"] = null;
	config["playerTag"] = null;
	config["autoplay"] = false;
	config["preloadBackColor"] = "#8d9395"; //background color while loading the player
	config["playerId"] = $playerID; 
	config["width"] = $pW; 
	config["height"] = $pH;
	createExperience(config);
}

/* embedding a badge?  cool!
function embedBadge($columns,$rows,$pID,$bgcolor) {
	var config = new Array();
	config["playerId"] = $pID;
	config["columns"] = $columns;
	config["rows"] = $rows;
	config["bgcolor"] = "#"+$bgcolor;
	createbadge(config);
}*/

// Listener for title fetching...
function onTitleLoad(infoObj) {
	callFlash("loadTitleById",infoObj.parameters.title.id);
}

function onTemplateLoaded(message) {
	callFlash("addEventListener", "titleLoad", "onTitleLoad");
}

// want to load in an external video?
function loadVideo($videoId) {
	callFlash("fetchTitleById",$videoId);
}