function controlFlashPause(obj) {
	var flash_player = document.getElementById(obj);
	if(flash_player)
	{
		flash_player.StopPlay();
		controlButtonState(obj);
	}
}

function controlFlashPlay(obj) 
{
//	debugEcho("Play : player is "+obj );

	var flash_player = document.getElementById(obj);
	if(flash_player)
	{
		flash_player.Play();
		controlButtonState(obj);
		setTimeout("controlFlashSliderUpdate('"+obj+"');", 100);
	}

}


function controlFlashReverse(obj)
{
	var flash_player = document.getElementById(obj);	
	if(flash_player)
	{
		var frame = flash_player.CurrentFrame();
		var totalFrames = flash_player.TotalFrames();
		var newFrame = frame - (totalFrames/20);
		if(newFrame <0)
			newFrame = 0;
		flash_player.GotoFrame(newFrame);
		controlFlashPlay(obj);
	}
}

function controlFlashForward(obj)
{
	var flash_player = document.getElementById(obj);	
	if(flash_player)
	{
		var frame = flash_player.CurrentFrame();
		var totalFrames = flash_player.TotalFrames();
		var newFrame = frame + (totalFrames/20);
		if(newFrame > totalFrames)
			newFrame = totalFrames;
		flash_player.GotoFrame(newFrame);
		controlFlashPlay(obj);
	}
}

function controlFlashPlayPause(obj) 
{
	var flash_player = document.getElementById(obj);

//	alert(flash_player.IsPlaying());
//	debugEcho("PlayPause : player is "+obj);

	if(flash_player)
	{
		if(flash_player.IsPlaying() == true)
		{
			flash_player.StopPlay();
		}
		else
		{
			flash_player.Play();
			setTimeout("controlFlashSliderUpdate('"+obj+"');", 100);
		}
		controlButtonState(obj);
	}
}

function controlFlashSliderUpdate(obj)
{
	var flash_player = document.getElementById(obj);
//	debugEcho("f"+obj);
	if(flash_player)
	{
//		debugEcho("s");
		var frame = flash_player.CurrentFrame();
		var totalFrames = flash_player.TotalFrames();
		var progress = 100 * (frame/totalFrames);
		eval(obj+"Slider.f_setValue("+progress+",0);");
		
		progress = Math.round(progress);
		document.getElementById('progressCell'+obj).innerHTML = progress+"%"; 
		//document.getElementById('percentCell').innerHTML = percent+"%"; 
		if(flash_player.IsPlaying()==true){
			setTimeout("controlFlashSliderUpdate('"+obj+"')", 100);
		}
		if(progress == 100)
			flash_player.StopPlay();
	}
}


function controlFlashStop(obj)
{
	var flash_player = document.getElementById(obj);
	if(flash_player)
	{
		flash_player.Rewind();
		controlButtonState(obj);
	}
}

function controlButtonState(obj)
{
	var flash_player = document.getElementById(obj);
	var img = document.getElementById("flash"+obj+"PlayPauseIMG");

	if(flash_player.IsPlaying()==true)
	{
//		debugEcho("SetPauseIMG : "+obj);
		img.src= "/images/flash_pause.png";
	}
	else
	{
//		debugEcho("SetPlayIMG : "+obj);
		img.src= "/images/flash_play.png";
	}

}

function flashLoad(swf, swfID,swfResX, swfResY)
{
//	debugEcho("Loading : "+swf+" into "+swfID);
	var contents = "<OBJECT ID=\""+swf+"OBJ\" CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" WIDTH=\""+swfResX+"\" HEIGHT=\""+swfResY+"\" CODEBASE=\"http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0\"><PARAM NAME=\"MOVIE\" VALUE=\""+swf+"\"><PARAM NAME=\"PLAY\" VALUE=\"true\"><PARAM NAME=\"QUALITY\" VALUE=\"best\"><EMBED ID=\""+swfID+"\" SRC=\""+swf+"\" WIDTH=\""+swfResX+"\" HEIGHT=\""+swfResY+"\" PLAY=\"true\" LOOP=\"true\" QUALITY=\"best\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></EMBED></OBJECT>";

	document.getElementById("flashObj"+swfID).innerHTML = contents; 

	setTimeout("flashLoadProgress('"+swfID+"')", 100);
	setTimeout("controlButtonState('"+swfID+"')", 100);
	setTimeout("controlFlashSliderUpdate('"+swfID+"')", 100);
}


function flashLoadProgress(obj)
{
	var flash_player = document.getElementById(obj);
	var percent = flash_player.PercentLoaded();

	if(percent < 100 && percent > -1)
	{
		document.getElementById('flashprogress'+obj).style.width = percent+"%"; 
		document.getElementById('flashprogress'+obj).height = 5; 
		setTimeout("flashLoadProgress('"+obj+"')", 1);
	}
	else
	{
		document.getElementById('flashprogress'+obj).style.width = "100%"; 
		document.getElementById('flashprogress'+obj).height = 5; 
	}
}

function debugEcho(text)
{
	document.getElementById('debugBox').innerHTML = text + "<br>"+ document.getElementById('debugBox').innerHTML; 

}

/*
Play() -------------------------------------------------------- ????
StopPlay()--------------------------------------------------- ????
IsPlaying()--------------------------------------------------- ????????
GotoFrame(frame_number)---------------------------- ??????
TotalFrames()---------------------------------------------- ????????
CurrentFrame()-------------------------------------------- ???????????-1
Rewind()---------------------------------------------------- ?????????
SetZoomRect(left,top,right,buttom)--------------- ??????
Zoom(percent)-------------------------------------------- ??????
Pan(x_position,y_position,unit)----------------------- ????x,y?????
PercentLoaded()------------------------------------------ ???????????
LoadMovie(level_number,path)----------------------- ????
TGotoFrame(movie_clip,frame_number)----------- movie_clip????????
TGotoLabel(movie_clip,label_name)----------------- movie_clip???????
TCurrentFrame(movie_clip)----------------------------- ??movie_clip????-1
TCurrentLabel(movie_clip)------------------------------ ??movie_clip????
TPlay(movie_clip)------------------------------------------ ??movie_clip
TStopPlay(movie_clip)----------------------------------- ??movie_clip???
GetVariable(variable_name)---------------------------- ????
SetVariable(variable_name,value)--------------------- ????
TCallFrame(movie_clip,frame_number)-------------- call??????action
TCallLabel(movie_clip,label)----------------------------- call??????action
TGetProperty(movie_clip,property)------------------ ??movie_clip?????
TSetProperty(movie_clip,property,number)------- ??movie_clip?????
*/

