// FLASH / VIDEO EMBEDDING FUNCTIONS

// Major version of Flash required
var requiredMajorVersion = 7;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;


// dependencies: 
//	product_config.js
//	AC_OETags.js

function getFlashMovieObject(movieName)
{
if (window.document[movieName]) 
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName]; 
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}

// this function is relying upon the presence of data in product_config.js. As 
// such, be sure to include that file if you are going to include these embed
// functions. It  follows, that in order to specify what function gets called 
// below, you must change the FIFTY_LESSONS_FILE_TYPE variable in product_config.js

function embedVideo(filename) {
	switch(FIFTY_LESSONS_FILE_TYPE.toLowerCase()) {
		case 'flv': 
			embedFlashVideo(filename);
		break;
		
		case 'mov':
			// embedMov(filename);	  uncomment & define below
		break;
			
		case 'mpeg':
			// embedMPEG(filename);	  uncomment & define below
		break;
			
		// ... 
		// you can define an arbitrary number of
		// file type embeds. Simply add a corresponding case statement
		// above, and define an appropriate embedding function below
		// example:
		
		// case 'rm':
		// 	embedRM(filename); // this needs to be defined 
		// break;
	}
}

// embed flash video
function embedFlashVideo(filename) {
  var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
  if(hasRequestedVersion) {
	var version =    FLASH_VIDEO_VERSION;
	var location =   PATH_TO_FIFTY_LESSONS_CLIPS;
	var media =      "video/" + filename + "." + FIFTY_LESSONS_FILE_TYPE;
	var labelXML =   PATH_TO_FIFTY_LESSONS_XML + filename + "_labels.xml";
	var captionXML = PATH_TO_FIFTY_LESSONS_XML + filename + "_captions.xml";
	var src = 	 "flv_player";
	var basePath =   PATH_TO_FIFTY_LESSONS_CLIPS;
	var id =	 filename;
	var scale = 	 "showall";
	var w = 	 FIFTY_LESSONS_WIDTH;
	var h =		 FIFTY_LESSONS_HEIGHT;
	var wMode = 	 "opaque";
	var bgColor =	 FIFTY_LESSONS_BG;
	var splashType =  "flv_splash.swf";
	var playAudio = PLAY_AUDIO_BY_DEFAULT;
	var showCaption = SHOW_CAPTIONS_BY_DEFAULT;
	
	// Ubiquitous config file
	if(!configXML) var configXML = 'xml/config.xml';
	
        // Write object embed
	var embedText = "";
	embedText +=
	"\n<object " + 
	"classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + version + "' " +
	"width='" + w + "' height='" + h + "' id='" + id + "' align='top'> \n" +
	"<param name='allowScriptAccess' value='always' /> \n" +
	"<param name='movie' value='" + location + src + ".swf?basePath=" + basePath + "&media=" + media + "&labelXML=" + location + labelXML + "&captionXML=" + location + captionXML + "&splashType=" + location + splashType + "&configXML=" + location + configXML + "&playAudio=" + playAudio + "&showCaption=" + showCaption + "' /> \n" +
	"<param name='menu' value='false' /> \n" +
	"<param name='quality' value='best' /> \n" +
	"<param name='scale' value='" + scale + "' /> \n" +
	"<param name='salign' value='t' /> \n" +
	"<param name='wmode' value='" + wMode + "' /> \n" +
	"<param name='bgcolor' value='" + bgColor + "' /> \n" +
	"<embed src='" + location + src + ".swf?basePath=" + basePath + "&media=" + media + "&labelXML=" + location + labelXML + "&captionXML=" + location + captionXML + "&splashType=" + location + splashType + "&configXML=" + location + configXML + "&playAudio=" + playAudio + "&showCaption=" + showCaption + "' " + 
	" menu='false' quality='best' scale='" + scale + "' salign='t' wmode='" + wMode + "' bgcolor='" + bgColor + "' " +
	" width='" + w + "' height='" + h + "' name='" + id + "' align='top' allowScriptAccess='always' " +
	" type='application/x-shockwave-flash' swLiveConnect='true' pluginspage='http://www.macromedia.com/go/getflashplayer' /> \n" +
	" </object>\n";
		
	document.write(embedText);
  } else {
    var flashDownload = document.createElement('a');
    flashDownload.href = 'http://www.adobe.com/products/flashplayer/';
    flashDownload.innerHTML = flashMessage;
    flashDownload.appendChild(document.createElement('br'));
	var textDiv = document.getElementById("CONTENT_BODY");
	if (textDiv.innerHTML.indexOf("M_PLAYER") != -1) {
	var mediaDiv = document.getElementById("M_PLAYER");
	}
	if (textDiv.innerHTML.indexOf("INTACTV") != -1) {
	var mediaDiv = document.getElementById("INTACTV");
	}
	mediaDiv.appendChild(flashDownload);
	}
}



// embed flash object
function embedFlash(version, location, media, captionXML, labelXML, basePath, src, id, scale, w, h, wMode, bgColor, splashType) {
  var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
  if(hasRequestedVersion) {    
    // Defaults if no param specified
    if(!version) var version='7,0,0,0';
    if(!location) var location='flash/';
    if(!media) var media='';
    if(!labelXML) var labelXML='';
    if(!captionXML) var captionXML='';
    if(!src) var src='placeholder';
    if(!basePath) var basePath=location;
    if(!id) var id='flashObj';
    if(!scale) var scale='showall';
    if(!w) var w='90';
    if(!h) var h='90';
    if(!wMode) var wMode='opaque';
    if(!bgColor) var bgColor='#ffffff';
    if(!splashType) var splashType = 'mp_splash.swf';
    var playAudio = PLAY_AUDIO_BY_DEFAULT;
    var showCaption = SHOW_CAPTIONS_BY_DEFAULT;

    // Ubiquitous config file
    if(!configXML) var configXML = 'xml/config.xml';
    
    // Write object embed
	var embedText = "";
	embedText +=
	"\n<object " + 
	"classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + version + "' " +
	"width='" + w + "' height='" + h + "' id='" + id + "' align='top'> \n" +
	"<param name='allowScriptAccess' value='always' /> \n" +
	"<param name='movie' value='" + location + src + ".swf?basePath=" + basePath + "&media=" + media + "&labelXML=" + location + labelXML + "&captionXML=" + location + captionXML + "&splashType=" + location + splashType + "&configXML=" + location + configXML + "&playAudio=" + playAudio + "&showCaption=" + showCaption + "' /> \n" +
	"<param name='menu' value='false' /> \n" +
	"<param name='quality' value='best' /> \n" +
	"<param name='scale' value='" + scale + "' /> \n" +
	"<param name='salign' value='t' /> \n" +
	"<param name='wmode' value='" + wMode + "' /> \n" +
	"<param name='bgcolor' value='" + bgColor + "' /> \n" +
	"<embed src='" + location + src + ".swf?basePath=" + basePath + "&media=" + media + "&labelXML=" + location + labelXML + "&captionXML=" + location + captionXML + "&splashType=" + location + splashType + "&configXML=" + location + configXML + "&playAudio=" + playAudio + "&showCaption=" + showCaption + "' " + 
	" menu='false' quality='best' scale='" + scale + "' salign='t' wmode='" + wMode + "' bgcolor='" + bgColor + "' " +
	" width='" + w + "' height='" + h + "' name='" + id + "' align='top' allowScriptAccess='always' " +
	" type='application/x-shockwave-flash' swliveconnect='true' pluginspage='http://www.macromedia.com/go/getflashplayer' /> \n" +
	" </object>\n";
		
	document.write(embedText);
	
  } else {
  var flashDownload = document.createElement('a');
  flashDownload.href = 'http://www.adobe.com/products/flashplayer/';
  flashDownload.innerHTML = flashMessage;
  flashDownload.appendChild(document.createElement('br'));
  var textDiv = document.getElementById("CONTENT_BODY");
	if (textDiv.innerHTML.indexOf("M_PLAYER") != -1) {
	var mediaDiv = document.getElementById("M_PLAYER");
	}
	if (textDiv.innerHTML.indexOf("INTACTV") != -1) {
	var mediaDiv = document.getElementById("INTACTV");
	}
	mediaDiv.appendChild(flashDownload);
	}
}

function exitFunction(){
    if(document.getElementById('cBlockButton1')){
    	if(exitType == 'revealPractice'){
    		practice_mClick = 0;
    		togglePracticeDrawer('reveal_question', 'divImage1', 'cBlockButton1');
    	}
    }
}
