//For function reference visit http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html

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);
  }
}

function swfIsLoaded(movieName){
	loaded = false;
	swf = getFlashMovieObject(movieName);
	if (swf.PercentLoaded() == 100) { loaded = true; }
	return loaded;
}
 
function swfIsPlaying(movieName){
	playing = false;
	swf = getFlashMovieObject(movieName);
	if (swf.IsPlaying()) { playing = true; }
	return playing;
}

function swfPlay (movieName){
	swf = getFlashMovieObject(movieName);
	swf.Play();
}

function swfStop (movieName){
	swf = getFlashMovieObject(movieName);
	swf.StopPlay();
}

function swfRewind (movieName){
	swf = getFlashMovieObject(movieName);
	swf.Rewind();
}

function swfGotoFrame (movieName, frame){
	swf = getFlashMovieObject(movieName);
	swf.GotoFrame(frame);
}

function swfSetVariable (movieName, variableName, variableValue){
	swf = getFlashMovieObject(movieName);
	swf.SetVariable(variableName, variableValue);
}

function swfGetVariable (movieName, variableName){
	swf = getFlashMovieObject(movieName);
	return swf.GetVariable(variableName);
}

function swfGotoLabel (movieName, target, frame){
	swf = getFlashMovieObject(movieName);
	swf.TGotoLabel(target, frame);
}

function rotatePromo (movieName, promo){
	if (promo > promoArray.length - 1) promo = 0;
	promoLabel = promoArray[promo];
	if ((swfIsLoaded(movieName)) && (swfGetVariable(movieName, 'gogo') != 1)){
		//alert(swfGetVariable(movieName, 'gogo'));
		swfGotoLabel(movieName, "/", promoLabel);
		swfPlay(movieName);
		promo = promo + 1;
	} 
	setTimeout('rotatePromo("'+movieName+'", '+promo+')',100);

}
