/*****************************************************************
	nait-video-setup-swfobject.js
	developer: Randy Troppmann, NAIT D3 Team
	date: June 10, 2008
	
	purpose: initialize custom Flash video controller in HTML page
*****************************************************************/



//--------------------------------------------------------------------------------------
// These functions are used by External Interface in Flash
function getVarsFromJavascript(){
	//alert("call from flash: " + thisMovie("D3VideoController").name );
	var obj = new Object();			
	obj.videoName = videoName; 
	obj.streamingServerURL = streamingServerURL; 
	obj.width = width;
	obj.height = height;
	obj.introFrame = introFrame; 
	obj.title = title;
	obj.autoPlay = autoPlay;
	obj.stageColor = stageColor;
	obj.videoXML = videoXML;
	obj.showListControl = showListControl;
	obj.isLive = isLive;
	obj.debugMode = debugMode;
	thisMovie("D3VideoController").sendVarsToFlash(obj);
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}


var flashvars = {};
flashvars.showListControl = showListControl;
flashvars.showChapterControl = showChapterControl;
flashvars.videoXML = videoXML;
flashvars.isLive = isLive;
flashvars.videoName = videoName;
flashvars.streamingServerURL = streamingServerURL;
flashvars.width = width.toString();
flashvars.height = height.toString();
flashvars.title = title;
flashvars.autoPlay = autoPlay;
flashvars.debugMode = debugMode;
flashvars.introFrame = introFrame;
flashvars.videoListTitle = videoListTitle;
flashvars.isAudio = isAudio;
// looking for the value for "v" which needs to be an interger (min value of 1)
// this property in initialized in nait-video-props.js
// the jumpToIndex value will be used to play a specific video in the xml video list
flashvars.jumpToVideoIndex = getQueryVariable("v");
// looking for a "c" which is a jump to chapter number
flashvars.jumpToChapterIndex = getQueryVariable("c");
var params = {};
params.scale = "noscale";
params.salign = "tl";
params.wmode = "transparent";
params.bgcolor = "#eeeeee";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
var attributes = {};
attributes.id = "D3VideoController";
if (showListControl == "true") width += 215;
if (showChapterControl == "true") width += 226;
height += 51; //add height for control bar
//swfobject.embedSWF(	"http://www.nait.ca/flash_videos/assets/D3VideoPlayer.swf", 
swfobject.embedSWF(	"http://www.nait.ca/flash_videos/assets/D3VideoPlayer.swf", 
				   	videoDivID, 
					width.toString(), 
					Math.max(height,5).toString(), 
					"9.0.115", 
					"http://www.nait.ca/flash_videos/assets/expressInstall.swf", 
					flashvars, 
					params, 
					attributes					
					);
					
					
// pull value from the query string
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
}