

function CFLASHFLV ( oFlash, oMedia,i_myJSONObject )
{
	
	this.Flash = oFlash;
	this.Media = oMedia;
	this.cbFunction = null;	
	this.PlayerState = null;
	
	
	CFLASHFLV.prototype.Play = FLASHFLV_Play;
	CFLASHFLV.prototype.Stop = FLASHFLV_Stop; 
	CFLASHFLV.prototype.Pause = FLASHFLV_Pause; 
	CFLASHFLV.prototype.CB = FLASHFLV_CB;
	CFLASHFLV.prototype.Exec = FLASHFLV_Exec;



	YAHOO.log(i_myJSONObject);


	this.LayerDIVName=i_myJSONObject["divname"]; // UniplayDivName"];	
	 var t_UniplayDivName=this.LayerDIVName+"CFLASHFLV"; //this.Player;	
	    
	
	

//	this.LayerDIVName=i_myJSONObject["UniplayDivName"];	
	
	var s1 = new SWFObject("Loflv.swf","single","100%","100%","7");
    s1.addVariable("file",this.Media.URL);
    s1.addVariable("divname",this.LayerDIVName);
	// s1.addVariable("flashVarText", "POpo say this is passed in via FlashVars for example only"); // this line is optional, but this example uses the variable and displays this text inside the flash movie		
	s1.write(t_UniplayDivName);
	
	
	
	
	CFLASHFLV.prototype.Duration = FLASHFLV_Duration;
	CFLASHFLV.prototype.TimeOut = FLASHFLV_TimeOut;			
	CFLASHFLV.prototype.Inital = FLASHFLV_Inital;
	// Inital
	this.Inital(i_myJSONObject);			
}



var g_EventArrayTemp;
function FLASHFLV_Inital(i_myJSONObject)
{
	////////////////////////////////////////
	// for Duration time
			
	
		YAHOO.log(t_duration);
	    var t_UniplayDivName=this.LayerDIVName+"CFLASHFLV"; //this.Player;	

		YAHOO.log(t_duration);	    
		var  EventArray = {"action":"event","actiondetail":"PlayStateChange","player":"CFLASHFLV","data":0};		
             EventArray["UniplayDivName"]=t_UniplayDivName;			 
             EventArray["jsondata"]=i_myJSONObject;		
		var t_currentcontent=i_myJSONObject["currentcontent"];	
	    var t_duration=0;
		try
	    {
		    t_duration=i_myJSONObject["jsondata"][t_currentcontent]["parameter"]["duration"];		
		}catch(err)
		{
			t_duration=g_GlobeValue["default"]["duration"];
			//var g_GlobeValue = {"title":"globe","default":{"duration":15000} };
		}	
		YAHOO.log(t_duration);			 	 							
		

			this.Duration(EventArray,t_duration);
		
			
}
function FLV_getTextFromFlash(str)
{
	
	var t_Function=str.split("=>");
	if (t_Function[0]=="008FLV")
	{		
		if (t_Function[1]=="status")
		{		
			if (t_Function[2]=="NetStream.Play.Stop"  || t_Function[2]=="NetStream.Buffer.Empty")
			{
				FLASHFLV_TimeOut(g_EventArrayTemp);
				//alert(str);
			}
		}				
	}
	
	//Level: status	 Code: NetStream.Play.Stop
	//alert(i_str)
}
function FLASHFLV_TimeOut(i_EventArray)
{
	var myObject = i_EventArray.parseJSON();
	// YAHOO.log(myObject);   
	JS_JSONStringProcess(myObject);
}

function FLASHFLV_Duration(i_EventArray,t_duration)
{
	var t_divname=i_EventArray["jsondata"]["divname"];	
	i_EventArray["TimeIDField"]= t_divname;
	// var timerID=0; 	
	this.EventArray=i_EventArray;
	var t_EventArrayString=i_EventArray.toJSONString();
	var t_CallBackFunction="FLASH_TimeOut('"+t_EventArrayString+"')";	
	var timerID=0;
	if (t_duration==-1)
	{				
			g_EventArrayTemp=t_EventArrayString;								
			
			t_duration=1000*60*20;
		    timerID=setTimeout(t_CallBackFunction,t_duration);	
	}else
	{
			g_EventArrayTemp=t_EventArrayString;				
		    timerID=setTimeout(t_CallBackFunction,t_duration);	
	}
	

	return timerID;
}

function FLASHFLV_CB(obj)
{

	//if(this.cbFunction == null ) return;
	 if(obj.PlayerState == undefined ) return;
	UNI_CB( obj.PlayerState, obj );
	//this.cbFunction(obj);
}
var _flshp;
function FLASHFLV_Play()
{
	this.Flash.LoadMovie(0, this.Media.url);
	this.Flash.Play();
	/*
	var oUni = oUniPlayer;
			oUni.dsInfoArea('visible');
			
	switch(this.PlayerState) {
		case 'play':
			//this.Pause();
			break;
		case 'pause':
		default:
			//this.Flash.LoadMovie(0, 'c..');
			
			this.Flash.LoadMovie(0, this.Media.url);
			this.Flash.Play();
			this.PlayerState = 'play';
			var oUni = oUniPlayer;
			FLASH_PlayStateChange(oUni, this.PlayerState);

			if (this.Media.Duration > 0)
			{
				clearTimeout(_flshp);
				_flshp = setTimeout(function(){
				FLASH_FSCommand(oUniPlayer, 'mediaEnd', 123);
				}, this.Media.Duration * 1000);
			}
	}
	*/
}

function FLASHFLV_Stop()
{
	this.Flash.Stop();
    this.Flash.LoadMovie(0, "images/dummy.jpg");
	this.PlayerState = 'stop';
	
	var oUni = oUniPlayer;
	FLASH_PlayStateChange(oUni, this.PlayerState);
}

function FLASHFLV_Pause()
{
	if (indx != -1)
	{
		this.Flash.LoadMovie(0, "images/dummy.jpg");
	}
	else
	{
		this.Flash.Stop();
	}
	this.PlayerState = 'pause';
}

//Event
function FLASHFLV_FSCommand(oUni, command, args)
{
	var CFLASH = oUni.CurrPlayer;
	var o = new Object();
var oUni = oUniPlayer;
	switch(command) {
		case 'mediaEnd':

					try
					{
						
						if(this.Media.Duration != undefined) 
						{
							if(this.Media.Duration != 0 && this.Media.Duration != '')
							{
								if (args != 123)
								{
									this.Flash.Stop();
								}
								else
								{
									this.Flash.Stop();
								}
							}
						}
					}
					catch(errr)
					{
					}
					
				

				
		
			o.oUni = oUni;
			o.on = false;
            this.PlayerState = 'end';
			CFLASH.PlayerState = 'end';
			//CFLASH.CB(o);
             FLASH_PlayStateChange(oUni, this.PlayerState);
			break;
		case 'mouseDown':						
			/*if(safeToCall('parent.toggleDMMonClick')) { //commented by christy to fix double click issue
				
				parent.toggleDMMonClick();
				UNI_doClickedMedia();
			}
			flcnt = flcnt + 1;
			clearTimeout(fltmr);
			fltmr = setTimeout('flcnt = 0', 500);
			if (flcnt > 1)
			{
				if(safeToCall('parent.toggleDMMonClick')) 
				{
					UNI_toggleScreenDisplay();
				}
			}
			*/
			UNI_toggleScreenDisplay();
		break;
		case "mouseMove":
			
			/*if(safeToCall('parent.toggleDMMonClick'))
			{
				parent.toggleDMMonClick();
			}*/ //commented to fix DMM bugs
		  break;						
			return;						
	}
}
var fltmr;
var flcnt = 0;
function FLASHFLV_PlayStateChange(oUni, PlayState)
{
	var CFLASH = oUni.CurrPlayer;
	var o = new Object();
	
	switch(PlayState) {
		case 'play' :
			CFLASH.PlayerState = PlayState;
			o.imgFile = '';
			o.on = false;
            o.PlayerState = CFLASH.PlayerState;
			CFLASH.CB(o);
			break;
		case 'end' :
		case 'stop' :
		case 'pause' :
			CFLASH.PlayerState = PlayState;
			o.oUni = oUni;
			o.on = false;
			o.PlayerState = CFLASH.PlayerState;
			CFLASH.CB(o);
	}
}

function FLASHFLV_Exec()
{
	
	if (oUniPlayer.Media.Stretch == false)
	{
		/*var cW = parent.parent.document.body.clientWidth;
		var cH = parent.parent.document.body.clientHeight;
		var wW = window.screen.width;
		var wH = window.screen.height;
		var strtch = false
		if ((wW - cW)/cW < 0.09)
		{
			strtch = true;
		}
		
		if ((wH - cH)/cH < 0.09)
		{
			strtch = true;
		}
	
		if (strtch)
		{
			this.Flash.Scale = 'exactfit';
		}
		else
		{*/
			this.Flash.Scale = 'showall';
		//}
	}
	else
	{
		this.Flash.Scale = 'exactfit';
	}

}


















/*
 * 
 * 123123
 */














