'
' <eStream v3.1 Viewer> Copyright (C) 2001-2004 Xinics Inc. All rights reserved. #3.1.200408.1024
'
Const MSG_1 = "Àü¿¡ º¸¾Ò´ø ³»¿ëÀÔ´Ï´Ù."
Const MSG_2 = "ºÎÅÍ ÀÌ¾î¼­ º¸½Ã°Ú½À´Ï±î?"
Const MSG_3 = "ÀÌ¾îº¸±â"
Const MSG_4 = "½ÃÃ»ÁßÀÏ ¶§¸¸ ¸Þ¸ð°¡ °¡´ÉÇÕ´Ï´Ù."
Const MSG_5 = "ÆÇ¼­¸¦ ÀÐÁö ¸øÇß½À´Ï´Ù."
Const MSG_6 = "ÄÁÅÙÃ÷ ½ÃÃ»À» À§ÇÑ ÄÄÆ÷³ÍÆ®°¡ ¼³Ä¡µÇÁö ¾Ê¾Ò½À´Ï´Ù."
Const MSG_7 = "¹Ìµð¾î ÇÃ·¹ÀÌ¾î°¡ ¼³Ä¡µÇ¾î ÀÖÁö ¾Ê½À´Ï´Ù."
//Const Msg_8 = "ÄÁÅÙÃ÷ ½ÃÃ»À» À§ÇÑ ÄÄÆ÷³ÍÆ®°¡ ¼³Ä¡µÇÁö ¾Ê¾Æ ViewerOcx.exe ¼³Ä¡¸¦ ½ÃÀÛÇÕ´Ï´Ù."
Const MSG_LOG1 = "¼­¹ö¿¬°á¿¡ ½ÇÆÐÇß½À´Ï´Ù. ½ÃÃ»½Ã°£ÀÌ ±â·ÏµÇÁö ¾Ê½À´Ï´Ù."
Const MSG_LIVE1 = "»ý¹æ¼ÛÀÌ ÁøÇàÁßÀÏ ¶§¸¸ Áú¹®ÀÌ °¡´ÉÇÕ´Ï´Ù."
Const MSG_LIVE2 = "»ý¹æ¼Û ¼­¹ö ¿¬°á¿¡ ½ÇÆÐÇß½À´Ï´Ù."
Const MSG_LIVE3 = "»ý¹æ¼Û ¼­¹ö ¿¬°á¿¡ ½ÇÆÐÇß½À´Ï´Ù.ÆÇ¼­°¡ ³ª¿ÀÁö ¾Ê½À´Ï´Ù.(sn2 Connect Fail)"
Const MSG_LIVE4 = "»ý¹æ¼ÛÀÌ ³¡³µ½À´Ï´Ù."
Const MSG_LIVE5 = "»ý¹æ¼ÛÀÌ ÀÌ¹Ì ÁøÇàÁßÀÔ´Ï´Ù. "
Const MSG_LIVE6 = " ÆäÀÌÁöÀÔ´Ï´Ù."
Const MSG_LIVE7 = "»ý¹æ¼ÛÀÌ ¾ÆÁ÷ ½ÃÀÛÇÏÁö ¾Ê¾Ò½À´Ï´Ù."
Const MSG_LIVE8 = "»ý¹æ¼ÛÀÌ ½ÃÀÛµÇ¾ú½À´Ï´Ù."
Const MSG_LIVE9 = "»ý¹æ¼Û¿¡¼­´Â Áö¿øÇÏÁö ¾Ê½À´Ï´Ù."

Const BufText = "<font color=red>¹öÆÛ¸µÁßÀÔ´Ï´Ù...</font>"
Const BufText2 = "¹öÆÛ¸µ"

Const gInc = 100
Dim gCurListIndex,gListNum

'Array index - 1:posLeft, 2:posTop, 3:posWidth, posHeight:4
Dim gNormalWindow(2), gTitleBar(2)
Dim gSlideRect(4),gVideoRect(4), gInitSlideRect(4), gInitVideoRect(4)
Dim gSlideControlRect(4),gSlideControlRect2(4),gNoteRect(4),gNoteRect2(4),gMemoRect(4),gMemoRect2(4)
Dim gVideoControlRect(4),gVideoControlRect2(4),gMuteRect(4),gMuteRect2(4)
Dim gEllapseRect(4),gEllapseRect2(4)
Dim gTrackRect(4),gTrackRect2(4),gTrackPosRect(4),gTrackPosRect2(4)

Dim gBgVideoBoxPos(2), gBgContentsBoxPos(2), gBgSlideBoxPos(2)
Dim gTopLogoPos(2), gTitleVideoPos(2), gTitleSlidePos(2), gTitleContentsPos(2)
Dim gVideoTablePos(2), gSlideTablePos(2), gListTablePos(2), gPageTablePos(2)
Dim gHLine1Pos(2), gHLine2Pos(2), gHLine3Pos(2), gHLine4Pos(2), gHLine5Pos(2)
Dim gVLine1Pos(2), gVLine2Pos(2), gVLine3Pos(2), gVLine4Pos(2), gBgTopPos(2), gBgBottomPos(2)
Dim gListPos(2), gPagePos(2), gInfoPos(2)
Dim gQuestionPos(2), gSwapPos(2), gVideoMaxPos(2), gSlideMaxPos(2), gPrintPos(2), gHelpPos(2)
Dim gViewerUtilPos(2)

Dim gIsLiveFirstTry
Dim gPrevMarker

Dim gMarkers()
Dim gMarkerNum
Dim gLateMarker
Dim gGUID
Dim gLiveOn
Dim gLoggingOn
Dim gbMP7
Dim gDataVideo
Dim gUIMode
Dim gLiveStop

'WMP9
Dim bWindowLoaded
Dim bReservePlayReady
Dim bReserveOpen
Dim gPlayState

Sub Mute_onClick()
	if gbMP7 then
		MPlay1.settings.mute = not MPlay1.settings.mute
		b = MPlay1.settings.mute
//	else
//		MPlay1.Mute = not MPlay1.Mute
//		b = MPlay1.Mute
//	end if
//	if b then
//		Sound.src = "images/SoundOff.gif"
//	else
//		Sound.src = "images/button_Sound.gif"
	end if
End Sub

Sub DoZoom(state)
	offsetX = getStartPos("w")
	offsetY = getStartPos("h")

'	if gIsSlideFull or IsVideoFull() then exit sub
	if IsVideoFull() then MP_Fullscreen False
	if gIsSlideFull then SlideNormal_onClick

	if state = gZoomState then exit sub
	gZoomState = state

	LoadRect VideoLogoLayer, gSlideRect 
	LoadRect VideoLogo, gSlideRect 
	if gbMP7 then
		h = 64
	else
		h = 73
	end if
	gSlideRect(4) = gSlideRect(4) + h
	LoadRect MPlay1, gSlideRect 
	LoadRect VideoLayer, gSlideRect 
	gSlideRect(4) = gSlideRect(4) - h
	
	gVideoRect(4) = gVideoRect(4) - h
	LoadRect SlideLayer, gVideoRect 
	gVideoRect(4) = gVideoRect(4) + h

	if state = 1 then
		LoadRect VideoControl, gVideoControlRect
		LoadRect Ellapse, gEllapseRect
		LoadRect MuteLayer, gMuteRect

		gSlideControlRect(1) = gSlideControlRect(1) + offsetX
		gSlideControlRect(2) = gSlideControlRect(2) + offsetY
		LoadRect SlideControl, gSlideControlRect
		gSlideControlRect(1) = gSlideControlRect(1) - offsetX
		gSlideControlRect(2) = gSlideControlRect(2) - offsetY
		
		gNoteRect(1) = gNoteRect(1) + offsetX
		gNoteRect(2) = gNoteRect(2) + offsetY
		LoadRect NoteLayer, gNoteRect
		gNoteRect(1) = gNoteRect(1) - offsetX
		gNoteRect(2) = gNoteRect(2) - offsetY
		
		gMemoRect(1) = gMemoRect(1) + offsetX
		gMemoRect(2) = gMemoRect(2) + offsetY
		LoadRect MemoLayer, gMemoRect
		gMemoRect(1) = gMemoRect(1) - offsetX
		gMemoRect(2) = gMemoRect(2) - offsetY		

		LoadRect Track, gTrackRect
		LoadRect TrackPos, gTrackPosRect

		if IsObj(td_Slide) AND (not gbMP7) then
			td_Video.style.posHeight = td_Video.style.posHeight + 9
			td_Slide.style.posHeight = td_Slide.style.posHeight - 9
		end if
		if IsObj(tit_Slide) then tit_Slide.src = "images/tit_Slide.gif" 
		if IsObj(tit_Video) then tit_Video.src = "images/tit_Video.gif" 
		if (bHideTitle) then ShowLayer SlideTitle

	else
		LoadRect VideoControl, gVideoControlRect2 
		LoadRect Ellapse, gEllapseRect2 
		LoadRect MuteLayer, gMuteRect2 
		
		gSlideControlRect2(1) = gSlideControlRect2(1) + offsetX
		gSlideControlRect2(2) = gSlideControlRect2(2) + offsetY
		gSlideControlRect2(3) = gSlideControlRect(3)
		gSlideControlRect2(4) = gSlideControlRect(4)
		LoadRect SlideControl, gSlideControlRect2 
		gSlideControlRect2(1) = gSlideControlRect2(1) - offsetX
		gSlideControlRect2(2) = gSlideControlRect2(2) - offsetY

		gNoteRect2(1) = gNoteRect2(1) + offsetX
		gNoteRect2(2) = gNoteRect2(2) + offsetY
		gNoteRect2(3) = gNoteRect(3) 
		gNoteRect2(4) = gNoteRect(4) 
		LoadRect NoteLayer, gNoteRect2 
		
		gNoteRect2(1) = gNoteRect2(1) - offsetX
		gNoteRect2(2) = gNoteRect2(2) - offsetY

		gMemoRect2(1) = gMemoRect2(1) + offsetX
		gMemoRect2(2) = gMemoRect2(2) + offsetY
		gMemoRect2(3) = gMemoRect(3) 
		gMemoRect2(4) = gMemoRect(4) 		
		LoadRect MemoLayer, gMemoRect2 
				
		gMemoRect2(1) = gMemoRect2(1) - offsetX
		gMemoRect2(2) = gMemoRect2(2) - offsetY		

		LoadRect Track, gTrackRect2 
		LoadRect TrackPos, gTrackPosRect2 

		if IsObj(td_Slide) AND (not gbMP7) then
			td_Video.style.posHeight = td_Video.style.posHeight - 9
			td_Slide.style.posHeight = td_Slide.style.posHeight + 9
		end if

		if IsObj(tit_Slide) then tit_Slide.src = "images/tit_Video.gif" 
		if IsObj(tit_Video) then tit_Video.src = "images/tit_Slide.gif" 
		if (bHideTitle) then HideLayer SlideTitle
	end if

	SaveRect gSlideRect, SlideLayer 
	SaveRect gVideoRect, VideoLayer

	if IsObj(SlideTitle) then
		SlideTitle.style.posLeft = SlideLayer.style.posLeft
		SlideTitle.style.posTop = SlideLayer.style.posTop + SlideLayer.style.posHeight + 1
		SlideTitle.style.posWidth = SlideLayer.style.posWidth
	end if

	ShowSlideNumber gCurListIndex
	if ( bWindowLoaded ) then
		ShowDuration
	end if	

End Sub

Sub SlideMax_onClick()
	if gIsSlideFull then exit sub
	if IsVideoFull() then MP_Fullscreen False
	gIsSlideFull = True

	gNormalWindow(1) = window.top.document.body.clientWidth  - 2
	gNormalWindow(2) = window.top.document.body.clientHeight - 2

	ScreenWidth  = screen.availWidth
	ScreenHeight = screen.availHeight

	window.top.moveTo 0,0
	window.top.resizeTo ScreenWidth, ScreenHeight
	wx = window.top.screenLeft
	wy = window.top.screenTop
	gTitleBar(1) = (wx+3) * 2	'12
	gTitleBar(2) = wy + 2 * (wx+1) + 1	'31

	ScreenWidth  = ScreenWidth  - gTitleBar(1)
	ScreenHeight = ScreenHeight - gTitleBar(2)
	ControlPos   = ScreenWidth  - bgSlideControl.style.posWidth

	Dim TempRect(4)
	TempRect(1) = 0
	TempRect(2) = 0
	TempRect(3) = ControlPos - TempRect(1)	
	if gbMP7 then
		TempRect(4) = ScreenHeight - 64
	else
		TempRect(4) = ScreenHeight - 73
	end if

	if ( 3 * TempRect(3) < 4 * TempRect(4) ) then
		TempRect(3) = TempRect(3) - (TempRect(3) mod 4)
		TempRect(4) = 3 * TempRect(3) / 4
	else
		TempRect(4) = TempRect(4) - (TempRect(4) mod 3)
		TempRect(3) = 4 * TempRect(4) / 3
	end if
	TempRect(1)     = (ControlPos - TempRect(3)) / 2
	LoadRect SlideLayer, TempRect

	TempRect(2)     = TempRect(4) - 1
	if gbMP7 then
		TempRect(4) = 65	' +1 À» Ãß°¡
	else
		TempRect(4) = 74	' +1 À» Ãß°¡
	end if
	LoadRect VideoLayer, TempRect
	LoadRect MPlay1, TempRect

	if (not bHideSlideControl) then
		ControlPos                   = TempRect(1) + TempRect(3)
		bgSlideControl.style.posLeft = ControlPos
		ShowLayer bgSlideControl

		ControlPos                   = bgSlideControl.style.posLeft
		SlideControl.style.posTop    = 13
		SlideControl.style.posLeft   = ControlPos + ( (bgSlideControl.style.posWidth - SlideControl.style.posWidth) / 2 )
	end if

	SlideNormal.style.posTop         = TempRect(2)
	SlideNormal.style.posLeft        = ControlPos + ( (bgSlideControl.style.posWidth - SlideNormal.style.posWidth) / 2 )
	ShowLayer SlideNormal

	HideLayer TopLayer
	HideLayer TopLogo
	HideLayer LeftLayer
	HideLayer RightLayer
	HideLayer VideoControl
	HideLayer MuteLayer
	HideLayer Track
	HideLayer TrackPos
	HideLayer ListLayer
	if IsObj(PageLayer) and (( PageLayer.style.posLeft + PageLayer.style.posWidth > ControlPos ) or ( PageLayer.style.posTop + PageLayer.style.posHeight > TempRect(2) + TempRect(4) )) then
		HideLayer PageLayer
	end if
	HideLayer VideoLogoLayer
	HideLayer PenColor
	HideLayer PenWidth
	HideLayer VideoMax
	HideLayer SlideMax
	HideLayer Question	
	HideLayer Swap
	HideLayer PrintBtn
	HideLayer Help
	HideLayer NoteLayer
	HideLayer MemoLayer
	HideLayer TopButton
	HideLayer SlideTitle
	HideLayer Info

	HideLayer ViewerBorder
	HideLayer table_Video
	HideLayer table_Slide
	HideLayer bg_HLine1
	HideLayer bg_HLine2
	HideLayer bg_HLine3
	HideLayer bg_HLine4
	HideLayer bg_VLine1
	HideLayer bg_VLine2
	HideLayer bg_LiveLine
	HideLayer ViewerUtil	

	if IsObj(VideoLogoLayer) then
		VideoLogoLayer.style.zIndex = 0
		VideoLogoLayer.style.posLeft = VideoLayer.style.posLeft
	end if
End Sub

Sub VideoMax_onClick()
	MP_Fullscreen True
	if gIsSlideFull then SlideNormal_onClick
End Sub

Sub SlideNormal_onClick()
	offsetX = getStartPos("w")
	offsetY = getStartPos("h")

	HideLayer VideoLayer

	ShowLayer TopLayer
	ShowLayer TopLogo
	ShowLayer LeftLayer
	ShowLayer RightLayer
	ShowLayer VideoControl
	ShowLayer MuteLayer
	ShowLayer Track
	ShowLayer TrackPos
	ShowLayer SlideControl
	ShowLayer ListLayer
	ShowLayer PageLayer
	if ( IsAudioContent() ) then
		ShowLayer VideoLogoLayer
	else
		HideLayer VideoLogoLayer
	end if
	ShowLayer VideoLayer
	ShowLayer PenColor
	ShowLayer PenWidth
	ShowLayer VideoMax
	ShowLayer SlideMax	
	ShowLayer Swap
	ShowLayer NoteLayer
	ShowLayer MemoLayer
	ShowLayer TopButton
	if not (bHideTitle AND gZoomState = 2) then
		ShowLayer SlideTitle
	end if
	ShowLayer Info

	ShowLayer PrintBtn
	ShowLayer Help
	ShowLayer ViewerBorder
	ShowLayer table_Video
	ShowLayer table_Slide
	ShowLayer bg_HLine1
	ShowLayer bg_HLine2
	ShowLayer bg_HLine3
	ShowLayer bg_HLine4
	ShowLayer bg_VLine1
	ShowLayer bg_VLine2
	ShowLayer Buttons
	if (LiveMode) then
		ShowLayer bg_LiveLine
		ShowLayer Question
	end if
	ShowLayer ViewerUtil

	gIsSlideFull = False
	HideLayer SlideNormal
	HideLayer bgSlideControl

	window.top.resizeTo gNormalWindow(1) + gTitleBar(1), gNormalWindow(2) + gTitleBar(2)
'	SlideLayer.style.posWidth = 0
'	SlideLayer.style.posHeight = 0

	LoadRect MPlay1, gVideoRect

	if (gZoomState = 2) then
		gSlideControlRect2(1) = gSlideControlRect2(1) + offsetX
		gSlideControlRect2(2) = gSlideControlRect2(2) + offsetY
		LoadRect SlideControl, gSlideControlRect2
		gSlideControlRect2(1) = gSlideControlRect2(1) - offsetX
		gSlideControlRect2(2) = gSlideControlRect2(2) - offsetY
	else
		gSlideControlRect(1) = gSlideControlRect(1) + offsetX
		gSlideControlRect(2) = gSlideControlRect(2) + offsetY
		LoadRect SlideControl, gSlideControlRect
		gSlideControlRect(1) = gSlideControlRect(1) - offsetX
		gSlideControlRect(2) = gSlideControlRect(2) - offsetY
	end if

	LoadRect VideoLayer, gVideoRect
	LoadRect SlideLayer, gSlideRect

	if IsObj(VideoLogoLayer) then
		VideoLogoLayer.style.zIndex = VideoLayer.style.zIndex
		VideoLogoLayer.style.posLeft = VideoLayer.style.posLeft
	end if
End Sub

Sub Restore()
	if gIsSlideFull then SlideNormal_onClick
	if IsVideoFull() then MP_Fullscreen False
End Sub

Sub Eraser_onClick()
	if ( not CheckSN() ) then exit sub
	if ( sn2 = "" ) then exit sub
	if ( gSNScreenMode = False ) then exit sub
	sn2.HideAllObjects
	if ( gCurListIndex = "" ) then exit sub

	objs = gPMarkers & ","
	pos = InStr( objs, "," )
	while pos <> 0
		t = Left( objs, pos-1 )
		
		if t<>"" then sn2.DeleteObject CLng(t)
		objs = Right( objs, len(objs)-pos )
		pos = InStr( objs, "," )
	wend
	gPMarkers = ""

	if LiveMode then 
		SlideIndex = gCurListIndex
	else
		ListIndex = 0
		m = GetMarkerIndex( gCurListIndex )
		SlideIndex = GetSlideIndex( GetEventItem(m) )
	end if
	objs = PlayRange(SlideIndex, False)
	DoSlideObject( SlideIndex )
	PlayObjects objs, False
End Sub

Sub Question_OnClick()
	if not gLiveOn then 
		MsgBox MSG_LIVE1, 48
		exit sub
	end if

	ret = ShowModalDialog( "ques.htm", "", "dialogWidth:443px;dialogHeight:190px;resizable:no;scroll:no;status:no" )
	if ret <> "" then
		ViewerUtil.LiveConnect LiveIP, LiveChannel
		ViewerUtil.LiveQuestion "LQ" & ret
		ViewerUtil.LiveClose
	end if
End Sub

Sub sn2_PacketReceived(id)
	if gLateMarker >= 0 then
		if sn2.PlayObject(gLateMarker, False) then
			gLateMarker = -1
		end if
	end if
End Sub

Sub sn2_StatusMatched()
	Select Case sn2.strStatusText
	Case "PlayingStart"
		gReservePause  = False
		gReservePause2 = False
		sn2.strStatusText = "---"
		SetTimeout "MP_Play()", 500
	Case "PlayingEnd"
		sn2.strStatusText = "---"
		SetTimeout "MP_Play()", 500		
	End Select
End Sub

Sub sn2_PacketGenEnd( id )
	if gPMarkers <> "" then gPMarkers = gPMarkers & ","
	gPMarkers = gPMarkers & id
End Sub

Sub ViewerUtil_OnLiveInfo( IsStarted, SlideNum, GUID )
	if IsStarted then
		if SlideNum > 0 and gIsLiveFirstTry then 
			MsgBox MSG_LIVE5 & SlideNum & MSG_LIVE6, 64
			Redim gMarkers(gInc)
			gMarkerNum = 1
			gLateMarker = -1
			gMarkers(gMarkerNum) = LiveMarker( SlideNum )
			GotoSlide -1, LiveMarker( SlideNum ), "", ""
			if ( IsAudioContent() ) then showAudioLogo
		end if
		gGUID = GUID
		ViewerUtil.LiveClose
		gLiveOn = True
		gLiveStop = False
	else
		MsgBox MSG_LIVE7, 64
		gLiveOn = False
		gLiveStop = True
	end if
End Sub

Sub ViewerUtil_OnLiveStart()
	msgbox MSG_LIVE8, 64
	Redim gMarkers(gInc)
	gMarkerNum = 1
	gMarkers(gMarkerNum) = LiveMarker( 1 )
	gLateMarker = -1
	sn2.ResetContent
	if gIsSync then SetSync False
	if not gbMP7 and MPlay1.PlayState <> 2 then 'not playing
		MPlay1.FileName = VideoUrl
	elseif gbMP7 and MPlay1.PlayState <> 3 then 'not playing
		MPlay1.URL = VideoUrl
	end if
	gIsLiveFirstTry = False
	ViewerUtil.LiveGetInfo
	if ( IsAudioContent() ) then showAudioLogo
End Sub

Sub window_onfocus()
	if ( not CheckSN() ) then exit sub
	if ( sn2 = "" ) then exit sub
	sn2.ReserveDelayedUpdate
End Sub

Sub ShowToolTip()
	SetAlt document.all.item("Print"), "Print"
	SetAlt Help, "HELP"
	SetAlt SlideMax, "SLIDE FULL SCREEN"
	SetAlt VideoMax, "VIDEO FULL SCREEN"	
	SetAlt Swap, "SWITCH VIDEO/SLIDE"
	SetAlt Play, "PLAY"
	SetAlt Pause, "PAUSE"
	SetAlt document.all.item("Stop"), "STOP"
	SetAlt Mute, "MUTE"
	SetAlt Prev, "PREV"
	SetAlt Sync, "VIDEO/SLIDE SYNC"
	SetAlt document.all.item("Next"), "NEXT"
	SetAlt SlideNormal, "CLOSE"
	Setalt NoteLook, "NOTE ON/OFF"
	SetAlt MemoLook, "MEMO ON/OFF"
	SetAlt AnnoLook, "ANNOTATION ON/OFF"
	Setalt Pen, "PEN"
	SetAlt Eraser, "ERASER"
	SetAlt Memo, "MEMO"
	SetAlt Question, "QUESTION"
	SetAlt SNScreen, "NOTE ON/OFF"
End Sub

Function SkipPosition()
	SkipPosition = 0
	Dim pos
	if IsNull(gScormAPI) then
		pos = GetCookie(gGUID)
	'For Scorm
	else
		pos = gLessonLocation
	end if

	if pos <> "" then
		t = CInt(pos)
		if t<10 then exit function
		if ( MP_SourceFile() and not IsAudioContent() ) then HideLayer VideoLogoLayer
		d = FormatTime(t)
		str = MSG_1 & d & MSG_2
		if msgbox( str, 4, MSG_3 ) = 6 then
			SkipPosition = t
			gUIMode = ""
		end if
	end if
End Function

Function PlayRange( SlideIndex, bAnimation )
	Dim index, AniNum, bPlay, mn, hideindex, t, objs
	objs = ""
	AniNum = 0
	bPlay = False
	hideindex = 0
	if LiveMode then
		toIndex = gMarkerNum
	else
		toIndex = gEventCur
	end if
	for index=1 to toIndex
		if LiveMode then
			mn = gMarkers(index)
		else
			mn = GetEventItem(index-1)
		end if
		if LCase(Left(mn,5)) = "slide" then
			If SlideIndex = GetSlideIndex(mn) then
				bPlay = True
			Else
				bPlay = False
			End If
		elseif bPlay = True and LCase(Left(mn,7)) = "hideall" then
			hideindex = index
		end if
	next
	bPlay = False
	for index=1 to toIndex
		if LiveMode then
			mn = gMarkers(index)
		else
			mn = GetEventItem(index-1)
		end if
		if LCase(Left(mn,5)) = "slide" then
			If SlideIndex = GetSlideIndex(mn) then
				bPlay = True
			Else
				bPlay = False
			End If
		elseif bPlay = True and LCase(Left(mn,4)) = "note" and index > hideindex then
			objs = objs & Mid( mn, InStrRev( mn, "*" )+1, 50 ) & ","
		elseif bPlay = True and LCase(Left(mn,3)) = "ani" and LCase(Left(mn,7)) <> "anizoom" and LCase(Left(mn,7)) <> "aniswap"  then
			AniNum = AniNum + 1
		end if
	next
	if bAnimation then
		sn2.execScript "SetAniNum( " & AniNum & ")", "JavaScript"
	end if
	if objs <> "" then objs = Left( objs, Len(objs)-1 )
'window.status = "MPCur=" & toIndex & "," & MP_CurrentMarker() & ",objs=" & objs & ",Aninum=" & AniNum 
	PlayRange = objs
End Function

Sub Viewing()
	ViewerUtil.LogViewing 
End Sub

Sub ShowInfo()
	if not IsObj( info ) then exit sub
	infoc = Info.innerHTML
	infoc = Replace( infoc, "<contentTITLE>", gLectureTitle, 1, -1, 1 ) 'mpClipTitle
	infoc = Replace( infoc, "<contentAUTHOR>", gLectureAuthor, 1, -1, 1 ) 'mpClipAuthor
	infoc = Replace( infoc, "<contentDATE>", gLectureDate, 1, -1, 1 ) 'mpClipRating

	Info.innerHTML = infoc
End Sub

Function document_onkeydown()
	'if window.event.keycode = 27 then MP_Stop
	document_onkeydown = False
End Function

Sub SetSync(v)
	gIsSync = v	
	clearTimeout gEventTimeoutId
	MultiMouseOut "Sync", "button_"
End Sub

Sub GotoSlide( ListIndex, MarkerText, ShowAllPage, ListScroll )
	if ( not CheckSN() ) then exit sub 
	if ( sn2 = "" ) then exit sub
	if IsDataVideo( MarkerText ) and not LiveMode then
		if Abs(MP_CurrentPosition()-gPrevPosition) < 0.1 then exit sub
	end if

	'sn2.strStatusText = "---"

	SlideIndex = GetSlideIndex(MarkerText)
	PrevIndex = gCurListIndex
	if LiveMode then
		gCurListIndex = SlideIndex
	else
		gCurListIndex = ListIndex
		gUIMode = ""
	end if
	if gCurListIndex=0 then gCurListIndex = 1

	SetbScale MarkerText

	ChangeEntry gCurListIndex, ListScroll
	ShowSlideNumber gCurListIndex
	ShowDuration

	sn2.HideAllObjects

	title=Left( MarkerText, InStrRev( MarkerText, "*")-1 )
	title=Mid( title, InStr( title, "#")+1, Len(title) )
	if IsObj(SlideTitle) then SlideTitle.innerText = title

	if HasAnno(MarkerText) and not IsVideoFull() and (PrevIndex <> gCurListIndex) then
		DoAnno SlideIndex
	end if

	if not LiveMode and not IsVideoFull() and (PrevIndex <> gCurListIndex) then
		if IsObj(MemoLayer) then
			ViewerUtil.MemoCheck gGUID, gCurListIndex, window.screenLeft+MemoLayer.style.posLeft, window.screenTop+MemoLayer.style.posTop
		elseif IsObj(NoteLayer) then
			ViewerUtil.MemoCheck gGUID, gCurListIndex, window.screenLeft+NoteLayer.style.posLeft, window.screenTop+NoteLayer.style.posTop
		end if
	end if

	if gPlayState = 3 or gPlayState = 6 then
		if not gIsPrevStuff and not IsVideoFull() and PrevIndex <> gCurListIndex and InStr( gPrevMarker, "@") > 0 then
			On Error Resume Next
			if not LiveMode then 
				if gbMP7 then
					if MPlay1.playState = 6 then
						gReservePause = True
					elseif MPlay1.controls.isAvailable("pause") then 
						MP_Pause
					else
						gReservePause = True
					end if
					'gReservePause = True
				else
					MP_Pause
				end if
			end if
			On Error Goto 0

			if DoDataItems (GetSlideIndex(gPrevMarker), "media_end") = "play" then
				MP_Play
			end if
			gPrevMarker = ""

		elseif gQuizOnNextPage and not IsVideoFull() then
			On Error Resume Next
			if not LiveMode then 
				if gbMP7 then
					if MPlay1.playState = 6 then
						gReservePause = True
					elseif MPlay1.controls.isAvailable("pause") then 
						MP_Pause
					else
						gReservePause = True
					end if
					'gReservePause = True
				else
					MP_Pause
				end if
			end if
			On Error Goto 0
		
			QuizMarker = Right( gPrevMarker, Len(gPrevMarker)-InStrRev( gPrevMarker, "@" ) ) & ","
			DoQuiz QuizMarker
			if IsQuiz( MarkerText ) then
				gPrevMarker = MarkerText
				gQuizOnNextPage = True
			else
				gQuizOnNextPage = False
			end if
		end if
	else
		gPrevMarker = ""
		gQuizOnNextPage = False
	end if

	if IsQuiz( MarkerText ) then
		if gIsPrevStuff then gQuizOnNextPage = True
		gPrevMarker = MarkerText
	end if


	gPrevPosition = -1

	GetVideoMetadata ListIndex, volume, main_pause
	if volume = "" then volume = "-1"
	
	if IsDataVideo( MarkerText ) and  not LiveMode and not gIsSync then	
		sn2.strStatusText = "---"
		if gbMP7 then
			if MPlay1.playState = 6 then
				gReservePause = True
			elseif MPlay1.controls.isAvailable("pause") then 
				MP_Pause
			else
				gReservePause = True
			end if
			'gReservePause = True
		else
			MP_Pause
		end if
	end if

	SetInvalidate sType
	sn2.ReserveDelayedUpdate
	objs = PlayRange(SlideIndex, True)
	if IsDataVideo( MarkerText ) then
		if ManagerMode then 
			sManager="true"
		else
			sManager="false"
		end if
		if sType = 5 then  'AppVideo
			sScale="false"
		else
			sScale="true"
		end if
		if LiveMode then
			MediaUrl = DataVideoUrl & "/"
		else
			MediaUrl = MP_Url()
			MediaUrl = Replace( MediaUrl, "\", "/", 1, -1, 1 )
		end if
		if IsVideoFull() then MP_Fullscreen False
		sn2.execScript "DoDataVideo2 (" & SlideIndex & "," & sScale & ",'" & MediaUrl & "'," & volume & "," & sManager & ")", "JavaScript"
	else
		sn2.execScript "setFrames (" & SlideIndex & ", '" & ShowAllPage & "')", "JavaScript" 
	end if
	'WriteVisitLog ListIndex
	'SetTimeout "ReserveScrollBar()", 1500 '¹«Á¶°Ç ½ºÅ©·Ñ¹Ù¸¦ »õ·Î ¸¸µç´Ù.

	if IsDataVideo( MarkerText ) and not LiveMode and Trim(LCase(main_pause)) <> "yes" then
		sn2.strStatusText = "PlayingStart"
	elseif IsDataVideo( MarkerText ) and not LiveMode and Trim(LCase(main_pause)) = "yes" then
		sn2.strStatusText = "PlayingEnd"
	end if

	if IsDataVideo( MarkerText ) OR (sType = 6) then
		gDataVideo = True
	else
		gDataVideo = False
	end if
	PlayObjects objs, False, gDataVideo
	DoPrivateMarker PrevIndex, gCurListIndex
	DoSlideObject( ListIndex )
End Sub

Function IsAudioContent()
	Dim imgWidth

	If (gbMP7) Then
		imgWidth = MPlay1.currentMedia.imageSourceWidth
	Else
		imgWidth = MPlay1.ImageSourceWidth
	End If
	
	If (imgWidth = 0) Then
		IsAudioContent = True
	Else
		IsAudioContent = False
	End If
End Function

Sub PlayReady()
	if ( not bWindowLoaded ) then
		bReservePlayReady = True
		Exit Sub
	end if
	bReservePlayReady = False

	if LiveMode then
		Redim gMarkers(gInc)
		gMarkerNum = 1
		gMarkers(gMarkerNum) = LiveMarker( 1 )
		gLateMarker = -1
	else
		gIsLoadEst = LoadEst()
		if gListNum = "" then gListNum = InitListNew ()
		if gListNum = 0 then gListNum = InitList()
		SetUIMode
		gCurListIndex = 1
		ShowSlideNumber gCurListIndex
		gCurListIndex = 0
		ShowDuration
		ShowInfo

'		gIsLoadEst = LoadEst()
		gSkipPos = 0
		if gIsLoadEst then
'			gGUID = sn2.GetGUID
			ViewerUtil.NoteLoad gGUID
			gSkipPos = SkipPosition()
		else
			MsgBox MSG_5   'ÆÇ¼­¸¦ ÀÐÁö ¸øÇß½À´Ï´Ù.
		end if
		if gIsLoadEst and gSkipPos > 0 then MP_SetCurrentPosition gSkipPos 
		StartTimer gEventCur
	end if

	dim interval, dur
	if LiveMode then
		dur = 0
	else
		dur = MP_Duration()
	end if
	if LogMode then
		interval = ViewerUtil.LogCreateSession( LogIp, ClientID, ClientName, L_Code, L_contentTITLE, dur )
		if interval > 0 then
			SetInterval "Viewing()", interval * 1000
			gLoggingOn = True
		else
			gLoggingOn = False
'			msgbox MSG_LOG1
		end if
	end if
	sn2.strStatusText = "---"
End Sub

Sub OnPlayStateChange(playState)
	if gClosed then exit sub
	if not gbMP7 then playState = playState + 1
	gPlayState = playState

	if gListNum = gCurListIndex and playState = 1 and not IsVideoFull() then
		if gQuizOnNextPage then
			QuizMarker = Right( gPrevMarker, Len(gPrevMarker)-InStrRev( gPrevMarker, "@" ) ) & ","
			DoQuiz QuizMarker
			gQuizOnNextPage = False
		else		
			if (InStr( gPrevMarker, "@") > 0) then
				DoDataItems GetSlideIndex(gPrevMarker), "media_end"
				gPrevMarker = ""
			end if
		end if
	end if

	if LiveMode and gLiveStop and not gClosed then 'mpStopped
		if gLiveOn then msgbox MSG_LIVE4, 64
		gLiveOn = False
		if not ViewerUtil.LiveConnect (LiveIP, LiveChannel) then
'			msgbox MSG_LIVE2, 16
		end if
	end if

	select case playState
	case 3	'mpPlaying
		if ( IsAudioContent() ) then 
			showAudioLogo
			ShowLayer VideoLogoLayer
		else
			HideLogo
			HideLayer VideoLogoLayer
		end if

		StartTimer gEventCur
		if gLoggingOn then ViewerUtil.LogResume
		if gUIMode="MAXVIDEO" then 
			MP_Fullscreen True 
			gUIMode = ""
		elseif gUIMode="MAXSLIDE" then 
			SlideMax_onClick()
			gUIMode = ""		
		end if
	case 1	'mpStopped
		gIgnoreOnce = True
		MP_SetCurrentPosition 0 
		clearTimeout gEventTimeoutId
		gEventCur = 0
		if gLoggingOn then ViewerUtil.LogPause
	case 2	'mpPaused
		clearTimeout gEventTimeoutId
		if gLoggingOn then ViewerUtil.LogPause
	end select
End Sub

Sub Stop_onClick()
	if not LiveMode then
		'MP_SetCurrentPosition 0 
		MP_Stop
	end if
End Sub

Sub List_onClick( ListIndex )
	if LiveMode then
		MarkerText = LiveMarker( ListIndex )
		GotoSlide -1, MarkerText, "ShowAllPage", ""
		if not gIsSync then SetSync True
		exit sub
	end if

'	if ListIndex <> gCurListIndex then
		m = GetMarkerIndex( ListIndex )
		gEventCur = m+1
		mn = GetEventItem(m)
		gIgnoreOnce = True
		MP_SetCurrentPosition GetEventTime(m)/1000.0 + 0.5
		StartTimer gEventCur
		if gIsSync then SetSync False
		if ListIndex = gCurListIndex then gQuizOnNextPage = False
		if IsDataVideo(mn) and  not LiveMode then
			SetTimeout "GotoSlide(" & ListIndex & ", '" & mn & "','','')", 1000
		else
			GotoSlide ListIndex, mn, "", ""
		end if
'	end if
End Sub
