function ISAT_WM_PlayStateChange(FirstState, SecondState) {

	var State;
	var StateForFlash;

	if (WM_Version > 6) {
		State = FirstState;
		StateForFlash = State;
	}
	else {
		switch (SecondState) {
			case 0:			// Stopped
				State = 1;
				StateForFlash = "stopped"
				break;
			case 1:			// Paused
				State = 2;
				StateForFlash = "paused"
				break;
			case 2:			// Playing
				State = 3;
				StateForFlash = "playing"
				break;
			case 3:			// Waiting
				State = 7;
				StateForFlash = "waiting"
				break;
			case 4:			// ScanForward
				State = 4;
				StateForFlash = "running"
				break;
			case 5:			// ScanReverse
				State = 5;
				StateForFlash = "running"
				break;
			case 6:			// SkipForward
				State = 0;	// Undefined
				StateForFlash = "waiting"
				break;
			case 7:			// SkipReverse
				State = 0;	// Undefined
				StateForFlash = "waiting"
				break;
			case 8:			// Closed
				State = 10;	// Ready
				StateForFlash = "stopped"
				break;
		}
	}

	TaxPlayStateChange(State);

	Flash_Object.setVariable("PlayState", StateForFlash);
	if (State == "6" || State == "7" || State == "9" || State == "11") {
	//  Buffering,      Waiting,        Transitioning,  Reconnecting
		
		if (OKToPlay) {
			ISAT_ShowLoading();
		}
		else
			ISAT_WM_Stop();
	}
	else if (State == "8" || State == "10") {
	//       MediaEnded,     Ready
		// Retirado para não correr o risco de mostrar final caso caia a conexão.
		ISAT_ShowNothing();
		// ShowEnd();
	}
	else if (State == "1") {
	//       Stopped
		ISAT_ShowNothing();
	}
	else {
		if (OKToPlay) {
			ISAT_ShowMedia();
		
			if (WM_Version > 6) {
				if (WM_Object.currentMedia) {
					Flash_Object.setVariable("MediaURL", WM_Object.currentMedia.sourceURL); //Para Tarifação
					Flash_Object.setVariable("TotalTime", WM_Object.currentMedia.duration);
				}
			}
			else {
				Flash_Object.setVariable("MediaURL", WM_Object.sourceLink);
				Flash_Object.setVariable("TotalTime", WM_Object.duration);
			}
		}
		else {
			ISAT_WM_Stop();
		}
	}

	// Verifica playstate para mostrar ou esconder closed caption
	// Playing ou Paused = nao visivel
	// Outros = visivel
	if (WM_ClosedCaption) {
		if (State == "3" || State == "2") {
			ISAT_ShowClosedCaption();
		}
		else {
			ISAT_HideClosedCaption();
		}
	}
}

function ISAT_WM_Buffering(State) {

	if (State) {
		// Buffering started
		ISAT_Flash_BufferingStart();
	}
	else {
		// Buffering stopped
		ISAT_Flash_BufferingEnd();
	}

}

function ISAT_WM_PositionChange(OldPos, NewPos) {

	TaxPositionChange(OldPos, NewPos);

}

function ISAT_WM_ScriptCommand(ParamName, ParamValue) {

	if (ParamName)
		ParamName.toLowerCase();
		
	if (ParamValue)
		ParamValue.toLowerCase();
		
	switch (ParamName) {
		case "slide":
			var Slide = "Slide" + ParamValue + ".jpg";
			
			ISAT_Flash_ChangeSlide(Slide);
			break;

		case "premio":
			ISAT_Flash_ChangePremio(ParamValue);
			break;

		case "win":
			//alert("Param=" + ParamValue);
			Flash_Object.setVariable("Winner", ParamValue);
			break;		

		case "nome":
			//alert(ParamValue);
			Flash_Object.setVariable("nome", ParamValue);
			break;		

		case "reload":
			Flash_Object.setVariable("AtualizaXML", ParamValue);
			break;

		case "gc":
			ISAT_Flash_ChangeGC(ParamValue);
			break;

		case "live":
			OKToPlay = true;
			if (ParamValue != 'notUpdate') {
				ISAT_Flash_Interval('live');
			}
	
			ISAT_ShowMedia();
			ISAT_WM_Play();
			break;

		case "fim":
			if (ParamValue != 'notUpdate')
				ISAT_Flash_Interval('fim');
				
			ISAT_HideMediaAndStop();
			break;
			
		case "manutencao":
			//ISAT_ShowMaintenance();
			if (ParamValue != 'notUpdate')
				ISAT_Flash_Interval('manutencao');
				
			ISAT_HideMediaAndStop();
			break;
		
		case "cafe", "coffee":
			//ISAT_ShowBreak();
			if (ParamValue != 'notUpdate')
				ISAT_Flash_Interval('coffee');

			ISAT_HideMediaAndStop();
			break;

		case "almoco":
			//ISAT_ShowLunch();
			if (ParamValue != 'notUpdate')
				ISAT_Flash_Interval('almoco');

			ISAT_HideMediaAndStop();
			break;

		case "jantar":
			//ISAT_ShowDinner();
			if (ParamValue != 'notUpdate')
				ISAT_Flash_Interval('jantar');
	
			ISAT_HideMediaAndStop();
			break;

		case "reinicia_video":
			OKToPlay = true;
			ISAT_WM_ChangieMovie(ASXFile);
			break;

		case "palestra":
			document.location.href = 'player.asp?Palestra_ID=' + ParamValue;
			break;
	}
}
