

function CVLC ( oVLC, oMedia,i_myJSONObject )
{
	
	this.VLC = oVLC;
	this.Media = oMedia;
	this.cbFunction = null;	
	this.PlayerState = null;
		
	
	CVLC.prototype.Play = VLC_Play;
	CVLC.prototype.Stop = VLC_Stop; 
	CVLC.prototype.Pause = VLC_Pause; 
	CVLC.prototype.CB = VLC_CB;
	CVLC.prototype.Exec = VLC_Exec;




/*


		var t_Src="E:\\Books\\DirectShow-1\\Media\\chicken.wmv";	
	    var options = new Array(":input-repeat=0");
     
	  
	  alert("VLC");
//      document.getElementById('vlc').addTarget(t_Src, options, 4+8, -666);
	  
      document.getElementById('vlc').URL=t_Src;
	  
        document.getElementById('vlc').play();
	 	  alert("aaaaaa"); 
		  
		  return;
	*/	  
/*
	this.LayerDIVName=i_myJSONObject["divname"]; //t_vlc
	 var t_UniplayDivName=this.LayerDIVName+"CVLC"; //this.Player;	


	var targetURL=this.Media.URL;
	var options = new Array(":vout-filter=deinterlace", ":deinterlace-mode=linear");
	
	*/
	/*
   	var t_objUniplayDivName=JSFUN_getElementByIdCompatible(t_UniplayDivName);
//	t_objUniplayDivName
	document.vlc.addTarget(targetURL, options, 4+8, -666);
	  */ 
	   
	   
	
	
/*
	var s1 = new SWFObject(oMedia.URL,"single","100%","100%","7");
//	var s1 = new SWFObject("flvplayer.swf","single","100%","100%","7");
	s1.addParam("allowfullscreen","false");
	s1.addVariable("file",this.Media.URL);
	s1.addVariable("image","preview.jpg");
//	s1.addVariable("width","100%");
//	s1.addVariable("height","100%");
	s1.addVariable("autostart","true");
	s1.write(t_UniplayDivName);
*/	
	



	this.LayerDIVName=i_myJSONObject["divname"];	
	CVLC.prototype.Duration = VLC_Duration;
	CVLC.prototype.TimeOut = VLC_TimeOut;			
	CVLC.prototype.Inital = VLC_Inital;
	// Inital
	this.Inital(i_myJSONObject);	
	
	
	

}

function VLC_Inital(i_myJSONObject)
{
	////////////////////////////////////////
	// for Duration time
			

	
	////////////////////////////////////////
	// for Duration time
			
		YAHOO.log(t_duration);
	    var t_UniplayDivName=this.LayerDIVName+"CVLC"; //this.Player;	

		YAHOO.log(t_duration);	    
		var  EventArray = {"action":"event","actiondetail":"PlayStateChange","player":"CVLC","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"];		
			this.Duration(EventArray,t_duration);
		}catch(err)
		{
			t_duration=0;
	
			
				var t_Event="CVLC_status('"+EventArray.toJSONString()+"')";							 			
				setTimeout(t_Event, 1000 );
	
	
			
			// VLC_Stats();
			// t_duration=g_GlobeValue["default"]["duration"];
			//var g_GlobeValue = {"title":"globe","default":{"duration":15000} };
		}	
		YAHOO.log(t_duration);			 	 							
//		this.uniplay_Control.Duration(EventArray,t_duration);

			
	
	
	 var t_UniplayDivName=this.LayerDIVName+"CVLC"; //this.Player;	
		
//	t_UniplayDivName=this.LayerDIVName;
    	var t_objUniplayDivName=JSFUN_getElementByIdCompatible(t_UniplayDivName);
	
	// var t_objUniplayDivName=this.VLC;
			
		        t_objUniplayDivName.style.height = "100%";
		        t_objUniplayDivName.style.width  = "100%"; 
				

							
		if (BrowserDetect.browser=="Explorer")
		{
				try
		      	{
					
/*									
			//	document.getElementById('place').innerHTML=str;
		    //  	vlc.style.height = "100%";
		    //  	vlc.style.width  = "100%"; 										      	
				var t_mrl="DSContent/Event-2-6_8.jpg";
				t_mrl="DSContent/FighterPilotWMVHD.wmv";
				//				t_objUniplayDivName.Src=t_mrl;
				//t_objUniplayDivName.play();
				
				vlc.MRL=t_mrl;
				vlc.Src=t_mrl;
				vlc.play();
				vlc.fullscreen();
				vlc.stop(); 
				*/
				
				//      var  t_Str ='<OBJECT id="vlc" name="vlc" classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8" height="0" width="0"><param name="Loop" value="false"/> 
				//<param name="MRL" value="DSContent/FighterPilotWMVHD.wmv" />   </OBJECT>'; 
	
				//	vlc.MRL=t_mrl;
				//	vlc.Src=t_mrl;
				//	MRL=
				//	vlc.stop();
					
				//	vlc.play();
					 
					/*
				//	<param name="Src" value="path to file, streaming or what do you need" />
				
				//VLC_Play();
				
			
			//	t_mrl="DSContent/FighterPilotWMVHD.wmv";
			//	vlc.add_item(t_mrl);
				
		        	// document.vlc.stop();            
		       		//  document.vlc.play();																				
*/	
		      	}
		      	catch(e)
		      	{
		        	 alert("please install VLC ActiveX");
		      	}				
		}else
		{	
			 try
		     {
			 	

							
		      }
		      catch(e)
		      {
		          alert("please install VLC plug-in");
		      }		
		}	
		
		
		
		 // this.Duration(EventArray,t_duration);
			
}
//			var t_Event="CVLC_status('"+i_myJSONObject.toJSONString()+"')";							 			
//				setTimeout(t_Event, 1000 );

function CVLC_status(t_EventArrayString)
{ 


    var t_EventArray=t_EventArrayString.parseJSON();
	var i_myJSONObject=t_EventArray["jsondata"];  //t_UniplayDivNameString.parseJSON();


/*
		var  EventArray = {"action":"event","actiondetail":"PlayStateChange","player":"CVLC","data":0};		
             EventArray["UniplayDivName"]=t_UniplayDivName;			 
             EventArray["jsondata"]=i_myJSONObject;		
	*/		 

	
	var LayerDIVName=i_myJSONObject["divname"];
	var t_UniplayDivName=LayerDIVName+"CVLC"; //this.Player;	
	 
	
	try
	{
		    var t_objUniplayDivName=JSFUN_getElementByIdCompatible(t_UniplayDivName);	
			if (t_objUniplayDivName!=null)
			{
				if (BrowserDetect.browser=="Explorer")
				{
				}else
				{
					 var t_1=t_objUniplayDivName.isplaying(); // ? "Playing" : "Not playing";							
					
					if (t_1==false)
					{
					
						 VLC_Duration(t_EventArrayString,0);
					}else
					{
					
					
			
				var t_Event="CVLC_status('"+t_EventArrayString+"')";							 			
				setTimeout(t_Event, 1000 );
										
			//			var t_Event="CVLC_status('"+UniplayDivNameString+"','"+t_EventArrayString+"')";							 			
				//		setTimeout(t_Event, 1000 );
					}		
				}																				
			}
    }
	catch(e)
	{
		         alert("3333Error does not work in danish version");
	}						
}



function VLC_TimeOut(i_EventArray)
{
	var myObject = i_EventArray.parseJSON();
	// YAHOO.log(myObject);   
	JS_JSONStringProcess(myObject);
}

function VLC_Duration(i_EventArrayString,t_duration)
{

	var i_EventArray = i_EventArrayString.parseJSON();	
	
	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="VLC_TimeOut('"+t_EventArrayString+"')";	
	var timerID=setTimeout(t_CallBackFunction,t_duration);	
	return timerID;
}


function VLC_CB(obj)
{

	//if(this.cbFunction == null ) return;
	 if(obj.PlayerState == undefined ) return;
	UNI_CB( obj.PlayerState, obj );
	//this.cbFunction(obj);
}
var _flshp;
function VLC_Play()
{
	this.VLC.LoadMovie(0, this.Media.URL);
	this.VLC.Play();
	
}

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

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

//Event
function VLC_FSCommand(oUni, command, args)
{
	var CVLC = 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.VLC.Stop();
								}
								else
								{
									this.VLC.Stop();
								}
							}
						}
					}
					catch(errr)
					{
					}
					
				

				
		
			o.oUni = oUni;
			o.on = false;
            this.PlayerState = 'end';
			CVLC.PlayerState = 'end';
			//CVLC.CB(o);
             VLC_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 VLC_PlayStateChange(oUni, PlayState)
{
	var CVLC = oUni.CurrPlayer;
	var o = new Object();
	
	switch(PlayState) {
		case 'play' :
			CVLC.PlayerState = PlayState;
			o.imgFile = '';
			o.on = false;
            o.PlayerState = CVLC.PlayerState;
			CVLC.CB(o);
			break;
		case 'end' :
		case 'stop' :
		case 'pause' :
			CVLC.PlayerState = PlayState;
			o.oUni = oUni;
			o.on = false;
			o.PlayerState = CVLC.PlayerState;
			CVLC.CB(o);
	}
}

function VLC_Exec()
{
	
	if (oUniPlayer.Media.Stretch == false)
	{
		
	}
	else
	{
		this.Flash.Scale = 'exactfit';
	}

}


















/*
 * 
 * 123123
 */











/*
 * Firfox version
 * 
 * 
 * 
 */

/*

   function volume_up()
   {
	var previous =  document.video1.get_volume();
        var newvolume = previous + 10;
	if( newvolume > 200 )  newvolume = 200;
	document.video1.set_volume( newvolume );
	var volume = document.getElementById("volume_status");
        volume.innerHTML = document.video1.get_volume() + " %";
   }

   function volume_down()
   {
	var previous =  document.video1.get_volume();
        var newvolume = previous - 10;
	if( newvolume < 0 )  newvolume = 0;
	document.video1.set_volume( newvolume );
	var volume = document.getElementById("volume_status");
        volume.innerHTML = document.video1.get_volume() + " %";
   }

   function status()
   {
        var play_status = document.getElementById("play_status");
        var time = document.getElementById("time");
        var length = document.getElementById("length");

        play_status.innerHTML = document.video1.isplaying() ? "Playing" : "Not playing";
        if( document.video1.isplaying() == true )
        {
	        got_time = document.video1.get_time();
		hours = Math.floor(got_time/ 3600);
		minutes = Math.floor((got_time/60) % 60);
		seconds = got_time % 60;
		if ( hours < 10 ) hours = "0" + hours;
		if ( minutes < 10 ) minutes = "0" + minutes;
		if ( seconds < 10 ) seconds = "0" + seconds;
		time.innerHTML = hours+":"+minutes+":"+seconds;
	        got_length = document.video1.get_length();
		hours = Math.floor(got_length/ 3600);
		minutes = Math.floor((got_length/60) % 60);
		seconds = got_length % 60;
		if ( hours < 10 ) hours = "0" + hours;
		if ( minutes < 10 ) minutes = "0" + minutes;
		if ( seconds < 10 ) seconds = "0" + seconds;
                length.innerHTML = hours+":"+minutes+":"+seconds;
        }
        else
        {
                time.innerHTML = "--:--:--";
                length.innerHTML = "--:--:--";
        }
        setTimeout("status()", 1000 );
    }

    function play_selected()
    {
	select = document.getElementById("item");
	set_item( select.value );
	document.video1.play();
    }

    function set_item( name)
    {
       document.video1.stop();
       document.video1.clear_playlist();
       document.video1.add_item( name );
    }



*/


function make()
{   

	if (BrowserDetect.browser=="Explorer")
	{
			    var  str ='<OBJECT id="vlc" name="vlc" classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8" height="0" width="0"><param name="Loop" value="false"/> <param name="MRL" value="DSContent/FighterPilotWMVHD.wmv" />   </OBJECT>'; 
			
				document.getElementById('place').innerHTML=str;
		      	vlc.style.height = "100%";
		      	vlc.style.width  = "100%"; 		
				
		      	try
		      	{
		        	// document.vlc.stop();            
		       		//  document.vlc.play();
//	make();
 VLC_Play();
				 	
		      	}
		      	catch(e)
		      	{
		        	 alert("44444  Error does not work in danish version");
		      	}	  	  
	 }else
	 { 
				 var url="DSContent/Event-2-6_8.jpg";
			  	var t_Str='';
				//t_Str +=' <embed type="application/x-vlc-plugin" ';
				//        t_Str +=' name="vlc"   ';
				//        t_Str +=' autoplay="yes" loop="yes" height="545" width="100%"   ';
				//        t_Str +='  target="DSContent/Event-2-6_8.jpg" />  ';
				
				
				
				t_Str =' <object type="application/x-vlc-plugin"       id="vlc">  ';		 
				t_Str +=' </object> ';
				
		        // autoplay="yes" loop="yes" height="545" width="100%"
		        // target="http://202.120.58.165:1000" />		
				//       t_Str = '<object id="contentPlayer" type="application/x-ms-wmp" data="'+url+'" width="320" height="240">';
				//        t_Str += '<param name="URL" value="'+url+'" />';			
				document.getElementById('place').innerHTML=t_Str;
		        vlc.style.height = "100%";
		        vlc.style.width  = "100%"; 
			 try
		     {
		        // document.vlc.stop();            
		        //  document.vlc.play();
				// VLC_Play();
				var t_MRL="DSContent/Event-2-6_8.jpg";
					t_MRL=  "E:\\xampp\\htdocs\\svncheckout\\htdocs\\signage\\AD\\Movie_0002.wmv";
	t_MRL=  "http://localhost/svncheckout/htdocs/signage/AD/Movie_0003.wmv";
				// t_mrl="DSContent/FighterPilotWMVHD.wmv";
				vlc.add_item(t_MRL);
				document.vlc.play();
				//vlc.playmrl("DSContent/Event-2-6_8.jpg");				
		      }
		      catch(e)
		      {
		         alert("55555  Error does not work in danish version");
		      }		
	} 	        
}

function doGo(targetURL)
{
	
	var options = new Array(":vout-filter=deinterlace", ":deinterlace-mode=linear");
	document.vlc.addTarget(targetURL, options, 4+8, -666);

	setTimeout('VLC_Stats()',1000);	
};
function VLC_Play()
{
	var t_MRL= "http://wwitv.com/j_tv/6232.asx";
	t_MRL=  "http://www.scgov.net/appVideo/scgovtv.asx";
	t_MRL=  "E:\\xampp\\htdocs\\svncheckout\\htdocs\\signage\\AD\\Movie_0002.wmv";
	t_MRL=  "http://localhost/svncheckout/htdocs/signage/AD/Movie_0003.wmv";
		
	//"E:\\xampp\\htdocs\\svncheckout\\htdocs\\signage\\DSContent\\shell.wmv"; 
	doGo(t_MRL);
};

function VLC_Stats()
{
 	if ( vlc.Length== vlc.Time)
	{
	 //    alert("TimeOut"+vlc.Time);
	 fun_debug(vlc.Time);
	}else
	{
	 	setTimeout('VLC_Stats()',1000);
	}
};




