/* =================================================

Captivate controller function
by Philip Hutchison, Oct-Nov 2007, revised Sept 2008
http://pipwerks.com/lab/captivate

Copyright (c) 2008 Philip Hutchison
MIT-style license. Full license text can be found at 
http://www.opensource.org/licenses/mit-license.php

==================================================== */


//Handle the Captivate commands
function control(swfID, command, usesSkin){

	//Get SWF as an object so we can use SetVariable
	var swf = document.getElementById(swfID);
	
	//Error-checking is good.
	if(!swf){ return false; }

	//Declare our prefix variable in case we need it.  Leave as empty string for now.
	var prefix = "";
	
	//If the Captivate SWF uses a skin, change the prefix var to include the skin's movieclip name
	if(usesSkin){ prefix = "cpSkinLoader_mc."; }
	
	//Which command is being invoked?
	switch (command) {
		case "pause": command = "rdcmndPause"; break;
		case "resume": command = "rdcmndResume"; break;
		case "rewindStop": command = "rdcmndRewindAndStop"; break;
		case "rewindPlay": command = "rdcmndRewindAndPlay"; break;
		case "next": command = "rdcmndNextSlide"; break;
		case "prev": command = "rdcmndPrevious"; break;
		case "info": command = "rdcmndInfo"; break;
		case "exit": command = "rdcmndExit"; break;
	}
	
	swf.SetVariable(prefix + command, 1);
	
	return false;
	
}