<!--

/**
 *
 * Copyright (C) 1999-2006 Pictron Inc.
 * All Rights Reserved
 * This Software Contains Pictron Inc. Confidential, Proprietary, and Trade Secret.
 *
 */
 
//**Start Encode**
var MaxVideoTranscriptLine = 22;
var MaxAudioTranscriptLine = 14;
var SkipSteps = 4;

function GotoSetting()
{
	document.location.href = "Setting.asp?VideoID=" + document.all.VideoID.value;
}

function OpenTranscript(docFormat)
{
	DaURL = "OpenTranscript.asp?VideoID=" + document.all.VideoID.value + "&Format=" + docFormat;
	window.self.name = 'LACounty Homepage';
    ItsTheWindow = window.open(DaURL, "Transcript");
    ItsTheWindow.focus();
}
function ViewTranscript()
{
	DaURL = "OpenTranscript.asp?VideoID=" + document.all.VideoID.value + "&Format=" + document.all.TranscriptFormat.value;
	window.self.name = 'LACounty Homepage';
    ItsTheWindow = window.open(DaURL, "Transcript");
    ItsTheWindow.focus();
}

function OpenPlayer()
{
	document.location.href = "Player.asp?VideoID=" + document.all.VideoID.value;
}

function GotoPage(available, curPage)
{
	if(available == 1)
	{
		document.DPdf1.setCurrentPage(curPage);
	}
	else if (available == 2)
	{
		window.opener.location.href = "Homepage.asp";
		window.self.close();
	}
	else if (available == 3)
	{
		window.opener.location.href = "SearchAllMeetings.asp";
		window.self.close();
	}
	else
	{
		window.opener.location.href = "unavailable.asp";
		window.self.close();
	}
}

function PlayVideo()
{
	if(document.MediaPlayer1)
	{
		if(MediaPlayer1.ReadyState == 1)
		{
			setTimeout("PlayVideo()", 1000);
			return;
		}
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.playState == 2)
			{
				document.MediaPlayer1.controls.play();
			}
			else if (MediaPlayer1.playState != 3)
			{
				document.MediaPlayer1.controls.currentPosition = PlayerPosition - vgClipStart;
				document.MediaPlayer1.controls.play();
				
				PlayerPosition = 0;
			}
		}
		else
		{
			if (MediaPlayer1.PlayState == 1)
			{
				MediaPlayer1.Play();
			}
			else if (MediaPlayer1.PlayState != 2)
			{
				document.MediaPlayer1.CurrentPosition = PlayerPosition;
				MediaPlayer1.Play();
				PlayerPosition = 0;
			}
		}
	}
}

function PauseVideo()
{
	if(document.MediaPlayer1)
	{
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.playState == 3)
			{
				MediaPlayer1.controls.pause();
			}
		}
		else
		{
			if (MediaPlayer1.PlayState == 2)
			{
				MediaPlayer1.Pause();
			}
		}
	}
}

function MuteAudio()
{
	if(document.MediaPlayer1)
	{
		if (MediaPlayer1.controls)
		{
			MediaPlayer1.settings.mute = MediaPlayer1.settings.mute?false:true;
			
		}
	
	}
}

function PlayAudio()
{
	if(document.MediaPlayer1)
	{
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.settings.mute)
			{
				MediaPlayer1.settings.mute = false;
			}
		}
		else
		{
			if (MediaPlayer1.Mute)
			{
				MediaPlayer1.Mute = false;
			}
		}
	}
}

function GotoStart()
{
	if(document.MediaPlayer1)
	{
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.playState==3)
			{
				MediaPlayer1.controls.stop();
			}
		}
		else
		{
			if (MediaPlayer1.PlayState==2)
			{
				MediaPlayer1.Stop();
			}
		}	
		PlayerPosition = 0;
		
		
		var nLine = document.all["Transcript"].length;
		if (nLine > 0)
		{
			 document.all["Transcript"].selectedIndex = 0;
		}
	
	}
}

function GotoEnd()
{
	if(document.MediaPlayer1)
	{
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.playState==3)
			{
				MediaPlayer1.controls.stop();
			}
		}
		else
		{
			if (MediaPlayer1.PlayState==2)
			{
				MediaPlayer1.Stop();
			}
		}	
		
		var nLine = document.all["Transcript"].length;
		if (nLine > 0)
		{
			document.all["Transcript"].selectedIndex = nLine - 1;
			PlayerPosition = document.all["Transcript"].options[nLine - 1].value;
		}
	
	}
}
function GotoPreviousPage()
{
	if(document.MediaPlayer1)
	{
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.playState==3)
			{
				MediaPlayer1.controls.stop();
			}
		}
		else
		{
			if (MediaPlayer1.PlayState==2)
			{
				MediaPlayer1.Stop();
			}
		}	
		
		var nLine = document.all["Transcript"].length;
		if (nLine > 0)
		{
			var currentIndex = document.all["Transcript"].selectedIndex;
			var selectLine = currentIndex - SkipSteps;	
			if (selectLine < 0)
				selectLine = 0;
				
			document.all["Transcript"].selectedIndex = selectLine;
			PlayerPosition = document.all["Transcript"].options[selectLine].value;
		}
		
	}
}

function GotoNextPage()
{
	if(document.MediaPlayer1)
	{
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.playState==3)
			{
				MediaPlayer1.controls.stop();
			}
		}
		else
		{
			if (MediaPlayer1.PlayState==2)
			{
				MediaPlayer1.Stop();
			}
		}	
	
		
		var nLine = document.all["Transcript"].length;
		if (nLine > 0)
		{
			var currentIndex = document.all["Transcript"].selectedIndex;
			var selectLine = currentIndex + SkipSteps;	
			if( selectLine >= nLine)
				selectLine = nLine-1;
						
			document.all["Transcript"].selectedIndex = selectLine;
			PlayerPosition = document.all["Transcript"].options[selectLine].value;
		}
	
	}
}

function TranscriptPositionChange()
{
	var nLine = document.all["Transcript"].length;
	if (nLine > 0)
	{
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.playState==3 || MediaPlayer1.playState == 2)
			{
				MediaPlayer1.controls.stop();
			}
		}
		else
		{
			if (MediaPlayer1.PlayState==2)
			{
				MediaPlayer1.Stop();
			}
		}	
		PlayerPosition =  document.all["Transcript"].value;
		vgNextSegment = 0;
		vgNextSegmentTime = 0;
		NextSearchLine = 0;
		PlayVideo();
	}
}

function SearchTranscript(SearchType)
{
	var SearchString = document.all.SearchValue.value;
	if((document.MediaPlayer1) && (SearchString != ""))
	{
	
		if (MediaPlayer1.controls)
		{
			if (MediaPlayer1.playState==3)
			{
				MediaPlayer1.controls.stop();
			}
		}
		else
		{
			if (MediaPlayer1.PlayState==2)
			{
				MediaPlayer1.Stop();
			}
		}	
		
		SearchString = SearchString.toUpperCase();
		
		if(SearchString != LastSearchString)
		{
			NextSearchLine = 0;
			LastSearchString = SearchString;
		}
		
		for (i=NextSearchLine; i< document.all["Transcript"].options.length; i++)
		{
			TranscriptLine =  document.all["Transcript"].options[i].text;
			TranscriptLine = TranscriptLine.toUpperCase();
			if(TranscriptLine.indexOf(SearchString) >= 0 )
			{
				var nLine = document.all["Transcript"].length;
				document.all["Transcript"].selectedIndex = nLine - 1;
				document.all["Transcript"].selectedIndex = i;
				PlayerPosition = document.all["Transcript"].options[i].value;
				NextSearchLine = i + 1;
				return;
			}	
		}
		alert("No results");

	}	
}
function scrollTranscript()
{
	if(document.MediaPlayer1 && document.all["Transcript"])
	{
		//
		// check to see if we need to scroll
		//
		if(MediaPlayer1.ReadyState == 1)
		{
			//do nothing
		}
		else if (MediaPlayer1.controls)
		{
			//alert (MediaPlayer1.status);
			//alert ( MediaPlayer1.controls.currentPositionString);
			if (document.all.PlayerStatus) document.all.PlayerStatus.innerHTML = MediaPlayer1.status;
			if (document.all.PlayerPosition) document.all.PlayerPosition.innerHTML = MediaPlayer1.controls.currentPositionString;
			if (MediaPlayer1.playState == 3) // dynamic change state only when the player is playing
			{
				vgCurTime = document.MediaPlayer1.controls.currentPosition;
				setFocusTranscript(vgCurTime+vgClipStart);
				//setFocusSegment(vgCurTime);
			}
			else
			{		
				vgNextLine = 0;
				vgNextLineTime = 0;
				//vgNextSegment = 0;
				//vgNextSegmentTime = 0;
			}
		}
		else
		{
			if (MediaPlayer1.PlayState == 2) // dynamic change state only when the player is playing
			{
				vgCurTime = document.MediaPlayer1.CurrentPosition;
				setFocusTranscript(vgCurTime);
				//setFocusSegment(vgCurTime);
			}
			else
			{		
				vgNextLine = 0;
				vgNextLineTime = 0;
				//vgNextSegment = 0;
				//vgNextSegmentTime = 0;
			}
		}
		setTimeout("scrollTranscript()", 1000); // check to see if we need to scroll key frame. Frequency is once per second
	}
}



function setFocusTranscript(nCurTime)
{
	
    if ((nCurTime < vgNextLineTime) || (vgNextLine < 0))
    {
    	return;
    }
    
    var MaxTranscriptLine = MaxVideoTranscriptLine;
   	if (PlayerSetting == "AUDIO") 
   		MaxTranscriptLine = MaxAudioTranscriptLine;
   	
   	var nLine = document.all["Transcript"].length;
    
   	if (nLine<=0) return;
   		
    if ((vgNextLineTime == 0) && (vgNextLine == 0))
    {
		var i;
		for (i=nLine-1; i>0; i--)
		{
			LineTime = document.all["Transcript"].options[i].value;
			if (nCurTime >= parseFloat(LineTime))
			{	
				break;
			}
		}	
		vgNextLine = i;
		document.all["Transcript"].selectedIndex = (vgNextLine - (vgNextLine % MaxTranscriptLine)) + MaxTranscriptLine - 1;
    }
    
    var lastline = vgNextLine % MaxTranscriptLine;
    if((vgNextLine!=0) && (lastline == 0))
    {
		lastline = vgNextLine + MaxTranscriptLine - 1;
		if (lastline > nLine-1)
			lastline = nLine-1;
		document.all["Transcript"].selectedIndex = lastline;
	}
	
	document.all["Transcript"].selectedIndex = vgNextLine;
    
    if (vgNextLine < nLine -1)
		vgNextLine = vgNextLine + 1;
    else	
		vgNextLine = nLine -1
    
    vgNextLineTime = document.all["Transcript"].options[vgNextLine].value;
}

function LoadVideoTranscript(VideoID)
{
	DaURL = "LoadVideoTranscript.asp?VideoID=" + VideoID
	window.self.name = 'LACounty Homepage';
	ItsTheWindow = window.open(DaURL, "Transcript", "height=50,width=100,scrollbars=no,resizable=no,toolbar=0");
	window.focus();	
}

function addTranscriptOption(text, value)
{
	var newElem = document.createElement("OPTION");
	newElem.text = text;
	newElem.value = value;
	document.frmTranscript.Transcript.options.add(newElem);
	
}

function SearchResultTranscript(frmName)
{
    
	if((frmName.SearchValue) && (frmName.SearchValue.value != ""))
	{	SearchString = frmName.SearchValue.value;
		SearchString = SearchString.toUpperCase();
		startLine = frmName.Transcript.selectedIndex;
		for (i=startLine+1; i< frmName.Transcript.options.length; i++)
		{
			TranscriptLine =  frmName.Transcript.options[i].text;
			TranscriptLine = TranscriptLine.toUpperCase();
			if(TranscriptLine.indexOf(SearchString) >= 0 )
			{
				frmName.Transcript.selectedIndex = i;
				return;
			}
		}	
	}
}
/*
function SegmentChange()
{
	var nLine = document.all["MeetingSegment"].length;
	if (nLine > 0)
	{
		if (MediaPlayer1.PlayState==2)
		{
			MediaPlayer1.Stop();
		}
		
		PlayerPosition =  document.all["MeetingSegment"].value;
		vgNextLine = 0;
		vgNextLineTime = 0;
		setFocusTranscript(PlayerPosition);
		
	}
}

function setFocusSegment(nCurTime)
{
    if ((nCurTime < vgNextSegmentTime) || (vgNextSegment < 0))
    {
    	return;
    } 
    var nLine = document.all["MeetingSegment"].length;
    if ((vgNextSegmentTime == 0) && (vgNextSegment == 0))
    {
		var i;
		for (i=nLine-1; i>0; i--)
		{
			LineTime = document.all["MeetingSegment"].options[i].value;
			if (nCurTime >= parseInt(LineTime))
				break;
		}	
		vgNextSegment = i;
    }
         
    document.all["MeetingSegment"].selectedIndex = vgNextSegment;
    
    if (vgNextSegment < nLine -1)
		vgNextSegment = vgNextSegment + 1;
    else	
		vgNextSegment = nLine -1
        
    vgNextSegmentTime = document.all["MeetingSegment"].options[vgNextSegment].value;
}
*/
//-->