'
' <eStream v3.1 Viewer> Copyright (C) 2001-2004 Xinics Inc. All rights reserved. #3.1.200404.001
'
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


Sub window_onload()
	window.focus()

	bWindowLoaded = False
	bReservePlayReady = False
	bReserveOpen = False

	SetSync False
	ShowToolTip
	MyInitLayers

	if (not gbMP7) and isObj(td_Video) then td_Video.style.posHeight = td_Video.style.posHeight + 9
	initColors
	UpdateSize

	if ( not CheckSN() ) then
		MsgBox Msg_8
		window.opener=window
		window.location.replace ("ViewerOCX.exe")
		setTimeout "window.close()", 1000
		exit sub
	end if

	showCustomLogo	'connectingÀ¸·Î º¯°æµÇ¾î¾ß...

	if LiveMode then
		ShowLayer Question		
		ShowLayer bg_LiveLine
		HideLayer TrackPos
'		ShowInfo

		if VideoUrl <> "" then
			gListNum = InitListLive()
			gCurListIndex = 1
			ShowSlideNumber gCurListIndex
			if (gListNum > 0) then SetbScale LiveMarker( gCurListIndex )
			if not ViewerUtil.LiveConnect (LiveIP, LiveChannel) then
				msgbox MSG_LIVE2, 16
			else
				if sn2.Connect( LiveIP, LiveChannel, False ) <> 0 then
					msgbox MSG_LIVE3, 16
				end if
			end if
			gIsLiveFirstTry = True
			ViewerUtil.LiveGetInfo
		end if
	else
		gListNum = InitListNew()
		SetUIMode
		if (gListNum > 0) then SetbScale GetEventItem( GetMarkerIndex( 1 ) )
'		SetInterval "SetVideoElapseTime()", 1000
	end if
	
	bWindowLoaded = True
	if bReservePlayReady then PlayReady
End Sub

Sub window_onresize()
	UpdateSize
End Sub

Sub OnOpenStateChangeMP6( lOldState, lNewState )
	if not gbMP7 and lNewState = 6 then
		if bReserveOpen then 
			bReserveOpen = False
			Exit Sub
		end if
		PlayReady
	end if
	if lNewState = 3 then bReserveOpen = True
End Sub

Sub OnOpenStateChangeMP7( openState )
	'If gbMP7 and openState = 13 then PlayReady
	if gbMP7 then 
		if (not LiveMode and openState = 12) then gIsLoadEst = LoadEst()
		if openState = 13 then PlayReady
	end if
End Sub

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
		if gListNum = "" then gListNum = InitListNew ()
		if gListNum = 0 then gListNum = InitList()
		gCurListIndex = 1
		ShowSlideNumber gCurListIndex
		gCurListIndex = 0
		ShowDuration
		ShowInfo

		'gIsLoadEst = LoadEst()
		if ( not gIsLoadEst ) then 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 DoEvent(mn)
	if LiveMode then exit sub
	if Not gSnReady then exit sub
	if gIsSync then exit sub
	if ( not CheckSN() ) then exit sub
	if sn2 = "" then exit sub

	if LCase(Left(mn,13)) = "anizoom slide" then
		DoZoom 1
	elseif LCase(Left(mn,13)) = "anizoom video" then
		DoZoom 2
	elseif LCase(Left(mn,8)) = "maxslide" then
		SlideMax_onClick()
	elseif LCase(Left(mn,8)) = "maxvideo" then
		VideoMax_onClick()
'	elseif LCase(Left(mn,7)) = "aniswap" then
'		Swap1_OnClick
	elseif LCase(Left(mn,7)) = "hideall" then
		sn2.HideAllObjects
		ListIndex = GetListIndex(gEventCur-1)
		DoSlideObject(ListIndex)
	elseif LCase(Left(mn,3)) = "ani" then
		sn2.execScript "DocAction()", "JavaScript"
		sn2.ReserveDelayedUpdate
	elseif LCase(Left(mn,4)) = "note" then
		objs = Mid( mn, InStrRev( mn, "*" )+1, 50 )
		PlayObjects objs, True, gDataVideo
	elseif LCase(Left(mn,5)) = "slide" then
		ListIndex = GetListIndex(gEventCur-1)
		GotoSlide ListIndex, mn, "", "LISTSCROLL"
	end if
End Sub

Sub OnScriptCommand(sType, sParam)
	if gClosed then exit sub
	if LCase(sType) = "text" then
	        CaptionLayer.innerHTML = sParam
		exit sub
	end if
	if not LiveMode then exit sub
	if not gSnReady then exit sub

	gMarkerNum = gMarkerNum + 1
	if gMarkerNum mod gInc = 0 then
		Redim Preserve gMarkers( gInc * (CInt(gMarkerNum/gInc) + 1) )
	end if
	gMarkers(gMarkerNum) = sParam
	if gIsSync then exit sub

	mn = gMarkers(gMarkerNum)
	if LCase(Left(mn,13)) = "anizoom slide" then
		DoZoom 1
	elseif LCase(Left(mn,13)) = "anizoom video" then
		DoZoom 2
	elseif LCase(Left(mn,8)) = "maxslide" then
		SlideMax_onClick()
	elseif LCase(Left(mn,8)) = "maxvideo" then
		VideoMax_onClick()
'	elseif LCase(Left(mn,7)) = "aniswap" then
'		Swap1_OnClick
	elseif LCase(Left(mn,7)) = "hideall" then
		sn2.HideAllObjects
	elseif LCase(Left(mn,3)) = "ani" then
		sn2.execScript "DocAction()", "JavaScript"
		sn2.ReserveDelayedUpdate
	elseif LCase(Left(mn,4)) = "note" then
		objs = Mid( mn, InStrRev( mn, "*" )+1, 50 )
		PlayObjects objs, True, gDataVideo
	elseif LCase(Left(mn,5)) = "slide" then
		ListIndex = GetListIndex(gEventCur-1)
		GotoSlide ListIndex, mn, "", "LISTSCROLL"
	end if
End Sub

Sub OnPlayStateChange(playState)
	if gClosed then exit sub
	if not gbMP7 then playState = playState + 1
	if playState = 1 and not IsVideoFull() then
		if gListNum = gCurListIndex and 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

	if playState = 3 then '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
	elseif playState = 1 then 'mpStopped
		gIgnoreOnce = True
		MP_SetCurrentPosition 0 
		clearTimeout gEventTimeoutId
		gEventCur = 0
		if gLoggingOn then ViewerUtil.LogPause
	elseif playState = 2 then 'mpPaused
		clearTimeout gEventTimeoutId
		if gLoggingOn then ViewerUtil.LogPause
	end if
End Sub

Sub window_onunload()
	gClosed = True
	gQuizOnNextPage = False
	if LogMode And gLoggingOn then ViewerUtil.LogEnd

	'DelCookie "ESTREAM" & gGUID
	SetCookie gGUID, MP_CurrentPosition(), 365

	if gIsLoadEst then 
		ViewerUtil.NoteSetMarkers gCurListIndex, gPMarkers
		gNoteDirty = True
	end if
	if gIsLoadEst and gNoteDirty then 
		ViewerUtil.NoteSetTitle gLectureTitle, gLectureAuthor, gLectureDate
		ViewerUtil.NoteSave
		sn2.SavePrivateFile gGUID & ".est"
	end if

	if ( IsOpenWindow(window.opener) ) then window.opener.focus()
End Sub

Sub OnPositionChange(oldPosition, newPosition)
	if gIgnoreOnce then
		gIgnoreOnce = False
		exit sub
	end if
	if LiveMode then exit sub
	if gIsSync then SetSync False
	Dim ListIndex, mn
	FindCurrentSlide ListIndex, mn
	gEventCur = GetCurrentEvent(newPosition*1000)
	StartTimer gEventCur
	if ListIndex = gCurListIndex then gQuizOnNextPage = False
	Dim num
	num = getAniNumber( gEventCur )
	GotoSlide ListIndex, mn, "", "LISTSCROLL"
	if ( num > 0 ) then
		setTimeout "PlayAnimations(" & num & ")", 2000
	end if
End Sub

Sub Print_onClick()
	if not gSnReady then exit sub
	sn2.execScript "DoPrint()", "JavaScript"
End Sub

Sub Help_onClick()
	DoHelp
End Sub

Sub Play_onClick()
	MP_Play
End Sub

Sub Pause_onClick()
	MP_Pause
End Sub

Sub Stop_onClick()
	if not LiveMode then
		MP_SetCurrentPosition 0 
		MP_Stop
	end if
End Sub

Sub Mute_onClick()
	if gbMP7 then
		MediaPlayer1.settings.mute = not MediaPlayer1.settings.mute
		b = MediaPlayer1.settings.mute
	else
		MediaPlayer1.Mute = not MediaPlayer1.Mute
		b = MediaPlayer1.Mute
	end if
	if b then
		Sound.src = "images/SoundOff.gif"
	else
		Sound.src = "images/button_Sound.gif"
	end if
End Sub

Sub Next_onclick()
	if gCurListIndex >= gListNum then exit sub

	if not gIsSync then SetSync True
	if LiveMode then
		MarkerText = LiveMarker( gCurListIndex )
		GotoSlide -1, MarkerText, "ShowAllPage", ""
		exit sub
	end if

	m = GetMarkerIndex( gCurListIndex+1 )
	mn = GetEventItem(m)
	GotoSlide gCurListIndex+1, mn, "ShowAllPage", "LISTSCROLL"
End Sub

Sub Prev_onclick()
	if gCurListIndex <= 1 then exit sub

	if not gIsSync then SetSync True
	if LiveMode then
		MarkerText = LiveMarker( gCurListIndex )
		GotoSlide -1, MarkerText, "ShowAllPage", ""
		exit sub
	end if

	m = GetMarkerIndex( gCurListIndex-1 )
	mn = GetEventItem(m)
	GotoSlide gCurListIndex-1, mn, "ShowAllPage", "LISTSCROLL"
End Sub

Sub Sync_onclick()
	if not gIsSync then exit sub

	SetSync False

	if LiveMode then
		for index=1 to gMarkerNum
			if LCase(Left(gMarkers(index),5)) = "slide" then
				MarkerText = gMarkers(index)
			end if
		next
		GotoSlide -1, MarkerText, "", "LISTSCROLL"
	else
		Dim ListIndex, mn
		FindCurrentSlide ListIndex, mn
		GotoSlide ListIndex, mn, "", "LISTSCROLL"
		gEventCur = GetCurrentEvent( MP_CurrentPosition() * 1000 )
		StartTimer gEventCur
	end if

End Sub

Sub SNScreen_onClick()	
	if (gSNScreenMode = True) then
		'±âº» ¼±ÅÃ ¸ðµå¿¡¼­ ¸µÅ© ¼±ÅÃ ¸ðµå·Î ÀüÈ¯. °³ÀÎ ÆÇ¼­ °ü·Ã ¸Þ´º »ç¿ë ±ÝÁö
		sn2.StopRecord
		gPenMode = false
		Pen.disabled = true
		PenColor.disabled= true
		PenWidth.disabled= true
		Eraser.disabled= true
	else
		'¸µÅ© ¼±ÅÃ ¸ðµå¿¡¼­ ±âº» ¼±ÅÃ ¸ðµå·Î ÀüÈ¯. °³ÀÎ ÆÇ¼­ °ü·Ã ¸Þ´º »ç¿ë °¡´É
		Pen.disabled = false
		PenColor.disabled= false
		PenWidth.disabled= false
		Eraser.disabled= false
	end if

	sn2.HideScreenWnd(gSNScreenMode)
	gSNScreenMode = not gSNScreenMode

	imgMouseOut "Pen"
	imgMouseOut "Eraser"
	imgSelectOn "SNScreen"
End Sub

Sub Pen_onClick()
	if ( not CheckSN() ) then exit sub
	if ( sn2 = "" ) then exit sub
	if ( gSNScreenMode = False ) then exit sub
	if gPenMode then 
		sn2.StopRecord
	else
		sn2.StartRecord True
		sn2.StartPrivateRecord
	end if
	gPenMode = not gPenMode
	sn2.PutProp -1, "bTranslucent", False

	cr = Trim(PenColor.value)
	if Left(cr,1) = "#" then
		cr = "&H" & Right( cr, Len(cr)-1 ) & "&"
		sn2.PutProp -1, "color", Eval( cr ) 
	else
		sn2.PutProp -1, "color", CInt(cr) 
	end if
	sn2.PutProp -1, "penWidth", CInt(PenWidth.value)*2 
End Sub

Sub PenColor_onChange()
	if ( not CheckSN() ) then exit sub 
	if ( sn2 = "" ) then exit sub
	if ( gSNScreenMode = False ) then exit sub
	cr = Trim(PenColor.value)
	if Left(cr,1) = "#" then
		cr = "&H" & Right( cr, Len(cr)-1 ) & "&"
		sn2.PutProp -1, "color", Eval( cr )
	else
		sn2.PutProp -1, "color", CInt(cr)
	end if
	sn2.focus
End Sub

Sub PenWidth_onChange()
	if ( not CheckSN() ) then exit sub 
	if ( sn2 = "" ) then exit sub
	if ( gSNScreenMode = False ) then exit sub
	sn2.PutProp -1, "penWidth", CInt(PenWidth.value)*2
	sn2.focus
End Sub

Sub Memo_onClick()
	if LiveMode then
		msgbox MSG_LIVE9, 16
		exit sub
	end if
	if gIsLoadEst then
		ViewerUtil.MemoLoad gGUID, gCurListIndex, window.event.screenX, window.event.screenY
		gNoteDirty = True
	else
		msgbox MSG_4, 16
	end if
End Sub

Sub Swap_OnClick()
	if gZoomState = 1 then 
		DoZoom 2
	else 
		DoZoom 1
	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 MediaPlayer1, 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 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

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 MediaPlayer1, 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 MediaPlayer1, 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 MediaPlayer1.PlayState <> 2 then 'not playing
		MediaPlayer1.FileName = VideoUrl
	elseif gbMP7 and MediaPlayer1.PlayState <> 3 then 'not playing
		MediaPlayer1.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() ) 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

	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 IsObj(MemoLayer) then
		ViewerUtil.MemoCheck gGUID, gCurListIndex, window.screenLeft+MemoLayer.style.posLeft, window.screenTop+MemoLayer.style.posTop
	elseif not LiveMode and not IsVideoFull() and IsObj(NoteLayer) then
		ViewerUtil.MemoCheck gGUID, gCurListIndex, window.screenLeft+NoteLayer.style.posLeft, window.screenTop+NoteLayer.style.posTop
	end if


	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 MediaPlayer1.playState = 6 then
					gReservePause = True
				elseif MediaPlayer1.controls.isAvailable("pause") then 
					MP_Pause
				else
					gReservePause = True
				end if
				'gReservePause = True
			else
				MP_Pause
			end if
		end if
		On Error Goto 0

		DoDataItems GetSlideIndex(gPrevMarker), "media_end"
		gPrevMarker = ""
		MP_Resume

	elseif gQuizOnNextPage and not IsVideoFull() then
		On Error Resume Next
		if not LiveMode then 
			if gbMP7 then
				if MediaPlayer1.playState = 6 then
					gReservePause = True
				elseif MediaPlayer1.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

	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	
		if gbMP7 then
			if MediaPlayer1.playState = 6 then
				gReservePause = True
			elseif MediaPlayer1.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
	'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

Sub DoPrivateMarker(PrevIndex, SlideIndex)
	if not gIsLoadEst then exit sub
	if not (PrevIndex=1 and SlideIndex=1) then 
		ViewerUtil.NoteSetMarkers PrevIndex, gPMarkers
		gNoteDirty = True
	end if
	gPMarkers = ViewerUtil.NoteGetMarkers(SlideIndex)
	if gPMarkers = "" then exit sub
	objs = gPMarkers & ","
	pos = InStr( objs, "," )
	while pos <> 0
		t = Left( objs, pos-1 )
		if t<>"" then sn2.PlayObject CLng(t), False
		objs = Right( objs, len(objs)-pos )
		pos = InStr( objs, "," )
	wend
End Sub

Sub ShowSlideNumber(curNum)
	if not IsObj( PageLayer ) then exit sub
	if (curNum = "") then exit sub
'	if (not gIsEditToc) then
		pNum = curNum
		tNum = gListNum
'	else
'		pNum = gLastList+1
'		tNum = gTocNum
'		if (pNum < 1) then pNum = 1
'	end if

	if IsUndefined( gPageInfo ) then
		strNumber = "SLIDE " & pNum & " / TOTAL " & tNum
	else
		strNumber = gPageInfo
		strNumber = replace(strNumber, "[1]", pNum)
		strNumber = replace(strNumber, "[2]", tNum)
	end if
	PageLayer.innerHTML =  strNumber
End Sub

Sub MyInitLayers
	SaveRect gSlideRect, SlideLayer 
	SaveRect gInitSlideRect, SlideLayer 
	VideoLayer.style.posWidth = MediaPlayer1.style.posWidth
	VideoLayer.style.posHeight = MediaPlayer1.style.posHeight
	SaveRect gVideoRect, VideoLayer
	SaveRect gInitVideoRect, VideoLayer
	SaveRect gVideoControlRect, VideoControl
	SaveRect gEllapseRect, Ellapse
	SaveRect gEllapseRect2, Ellapse
	SaveRect gMuteRect, MuteLayer
	SaveRect gSlideControlRect, SlideControl
	SaveRect gNoteRect, NoteLayer
	SaveRect gMemoRect, MemoLayer
	SaveRect gTrackPosRect, TrackPos
	SaveRect gTrackRect, Track

	gVideoControlRect2(1) = VideoControl_posLeft2
	gVideoControlRect2(2) = VideoControl_posTop2
	gEllapseRect2(1) = Ellapse_posLeft2
	gEllapseRect2(2) = Ellapse_posTop2
	gMuteRect2(1) = Mute_posLeft2
	gMuteRect2(2) = Mute_posTop2
	gSlideControlRect2(1) = SlideControl_posLeft2
	gSlideControlRect2(2) = SlideControl_posTop2
	gNoteRect2(1) = Note_posLeft2
	gNoteRect2(2) = Note_posTop2
	gMemoRect2(1) = Memo_posLeft2
	gMemoRect2(2) = Memo_posTop2	
	SaveRect gTrackRect2, Track
	gTrackRect2(1) = Track_posLeft2
	gTrackRect2(2) = Track_posTop2
	SaveRect gTrackPosRect2, TrackPos
	gTrackPosRect2(1) = TrackPos_posLeft2
	gTrackPosRect2(2) = TrackPos_posTop2

	SavePos gBgVideoBoxPos, bgVideoBox
	SavePos gBgContentsBoxPos, bgContentsBox
	SavePos gBgSlideBoxPos, bgSlideBox

	SavePos gTopLogoPos, topLogo
	SavePos gTitleVideoPos, tit_Video
	SavePos gTitleSlidePos, tit_Slide
	SavePos gTitleContentsPos, tit_Contents
	
	SavePos gVideoTablePos, table_Video
	SavePos gSlideTablePos, table_Slide
	SavePos gListTablePos, ListBorder
	SavePos gPageTablePos, table_Page
	
	SavePos gBgBottomPos, bgBottom

	SavePos gHLine1Pos, bg_HLine1
	SavePos gHLine2Pos, bg_HLine2
	SavePos gHLine3Pos, bg_HLine3
	SavePos gHLine4Pos, bg_HLine4
	SavePos gHLine5Pos, bg_HLine5
	
	SavePos gVLine1Pos, bg_VLine1
	SavePos gVLine2Pos, bg_VLine2
	SavePos gVLine3Pos, bg_VLine3
	SavePos gVLine4Pos, bg_LiveLine
	
	SavePos gListPos, ListLayer
	SavePos gPagePos, PageLayer
	SavePos gInfoPos, Info
	
	SavePos gQuestionPos, Question
	SavePos gSwapPos, Swap
	SavePos gVideoMaxPos, VideoMax
	SavePos gSlideMaxPos, SlideMax
	SavePos gPrintPos, Printbtn
	SavePos gHelpPos, Help
	
	SavePos gViewerUtilPos, ViewerUtil

End Sub

Sub FindCurrentSlide( ByRef ListIndex, ByRef SlideMarker )
	Dim index, mn
	ListIndex=0
	SlideMarker = ""
	for index=0 to gEventNum-1
		if GetEventTime(index) > MP_CurrentPosition() * 1000  then exit for
		mn = GetEventItem(index)
		if LCase(Left(mn,5)) = "slide" then 
			ListIndex = ListIndex + 1
			SlideMarker = mn
		end if
	next
End Sub

Sub SaveRect( rect, obj )
	If not IsObj(obj) Then exit Sub
	rect(1) = obj.Style.posLeft
	rect(2) = obj.Style.posTop
	rect(3) = obj.Style.posWidth
	rect(4) = obj.Style.posHeight
End Sub

Sub LoadRect( obj, rect )
	If not IsObj(obj) Then exit Sub
	obj.Style.posLeft = rect(1)
	obj.Style.posTop = rect(2)
	obj.Style.posWidth = rect(3)
	obj.Style.posHeight = rect(4)
End Sub

Sub DoSlideObject( ListIndex )
	if not gXmlLoad then exit sub
	objs = ""
	query = "lecture/slide[seq=" & ListIndex & "]/object"
	Set nodes = SlideList.XMLDocument.selectNodes(query)
	if nodes.length > 0 then 
		Set node = SlideList.XMLDocument.selectSingleNode(query)
		objs = node.text
	end if
	PlayObjects objs, False, False
End Sub

Sub GetVideoMetadata( ListIndex, volume, main_pause )
	volume = ""
	mian_pause = ""
	if Not IsObj(SlideList) then exit sub
	if SlideList.XMLDocument.parseError <> 0 then exit sub
	if ListIndex = -1 then
		query = "lecture/main_volume"
		Set nodes = SlideList.XMLDocument.selectNodes(query)
		if nodes.length > 0 then 
			Set node = SlideList.XMLDocument.selectSingleNode(query)
			volume = node.text
		end if
		exit sub
	end if

	query = "lecture/slide[seq=" & ListIndex & "]/volume"
	Set nodes = SlideList.XMLDocument.selectNodes(query)
	if nodes.length > 0 then 
		Set node = SlideList.XMLDocument.selectSingleNode(query)
		volume = node.text
	end if

	query = "lecture/slide[seq=" & ListIndex & "]/main_pause"
	Set nodes = SlideList.XMLDocument.selectNodes(query)
	if nodes.length > 0 then 
		Set node = SlideList.XMLDocument.selectSingleNode(query)
		main_pause = node.text
	end if
End Sub

Sub OnBuffering( Start )
	if Start=True then
		clearTimeout gEventTimeoutId
		if gReservePause then
			gReservePause = False
			gReservePause2 = True
		end if
		if gCurListIndex = 0 then
			showCustomLogo
			ShowLayer VideoLogoLayer
		end if
	else
		StartTimer gEventCur
		if gReservePause2 then
			gReservePause2 = False
			SetTimeout "ReservePause()", 100
		else
			MP_Play
		end if
	end if
End Sub

Function document_onmousemove()
	Exit Function
	window.status = window.event.clientX & "," & (screen.availWidth - 20)
	if gIsSlideFull and window.event.clientX > screen.availWidth - 20 and ListLayer.style.display = "none" then
		ShowLayer ListLayer
		ListLayer.style.zIndex = 2
		SlideLayer.style.zIndex = 1
	end if
End Function

Function getStartPos( mode )
	Dim s
	Select Case mode
	Case "w"
		s = document.body.clientWidth - viewerWidth
	Case "h"
		s = document.body.clientHeight - viewerHeight
	Case Else
		s = 0
	End Select
	
	If (s > 0) Then
		getStartPos = s / 2
	Else
		getStartPos = 0
	End If
End Function

Sub UpdateSize ()
	If (gIsSlideFull = True) Then Exit Sub
	w = getStartPos("w")
	h = getStartPos("h")
	
	'If (w = 0 and h = 0) Then Exit Sub

	If IsObj(ViewerBorder) Then
		ViewerBorder.style.posLeft = w - 1
		ViewerBorder.style.posTop = h - 1
	End If

	If IsObj(TopLayer) Then
		TopLayer.style.posLeft = w
		TopLayer.style.posTop = h
	End If

	MovePos gBgVideoBoxPos, bgVideoBox, w, h
	MovePos gBgContentsBoxPos, bgContentsBox, w, h
	MovePos gBgSlideBoxPos, bgSlideBox, w, h

	MovePos gTopLogoPos, topLogo, w, h
	MovePos gTitleVideoPos, tit_Video, w, h
	MovePos gTitleSlidePos, tit_Slide, w, h
	MovePos gTitleContentsPos, tit_Contents, w, h

	'MovePos gVideoTablePos, table_Video, w, h
	'MovePos gSlideTablePos, table_Slide, w, h

	MovePos gBgTopPos, bgTop, w, h
	MovePos gBgBottomPos, bgBottom, w, h

	MovePos gHLine1Pos, bg_HLine1, w, h
	MovePos gHLine2Pos, bg_HLine2, w, h
	MovePos gHLine3Pos, bg_HLine3, w, h
	MovePos gHLine4Pos, bg_HLine4, w, h
	MovePos gHLine5Pos, bg_HLine5, w, h
	
	MovePos gVLine1Pos, bg_VLine1, w, h
	MovePos gVLine2Pos, bg_VLine2, w, h
	MovePos gVLine3Pos, bg_VLine3, w, h
	MovePos gVLine4Pos, bg_LiveLine, w, h
	
	MovePos gQuestionPos, Question, w, h	
	MovePos gSwapPos, Swap, w, h
	MovePos gVideoMaxPos, VideoMax, w, h
	MovePos gSlideMaxPos, SlideMax, w, h
	MovePos gPrintPos, Printbtn, w, h
	MovePos gHelpPos, Help, w, h
	


	MovePos gVideoTablePos, table_Video, w, h
	MovePos gSlideTablePos, table_Slide, w, h

	MovePos gListTablePos, ListBorder, w, h
	MovePos gPageTablePos, table_Page, w, h
	MovePos gPagePos, PageLayer, w, h
	MovePos gListPos, ListLayer, w, h
	MovePos gInfoPos, Info, w, h
	
	MovePos gViewerUtilPos, ViewerUtil, w, h

	If (gZoomState = 2) Then
		MovePos gSlideControlRect2, SlideControl, w, h
		MovePos gNoteRect2, NoteLayer, w, h
		MovePos gMemoRect2, MemoLayer, w, h		

		MovePos gInitSlideRect, VideoLayer, w, h
		MovePos gInitVideoRect, SlideLayer, w, h
		MovePos gInitSlideRect, VideoLogoLayer, w, h
	Else
		MovePos gSlideControlRect, SlideControl, w, h
		MovePos gNoteRect, NoteLayer, w, h
		MovePos gMemoRect, MemoLayer, w, h

		MovePos gInitVideoRect, VideoLayer, w, h
		MovePos gInitSlideRect, SlideLayer, w, h
		MovePos gInitVideoRect, VideoLogoLayer, w, h
	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

End Sub

Sub SavePos ( posArr, obj )
	If not IsObj(obj) Then Exit Sub
	posArr(1) = obj.style.posLeft
	posArr(2) = obj.style.posTop
End Sub

Sub MovePos ( posArr, obj, offsetX, offsetY)
	If not IsObj(obj) Then Exit Sub
	If UBound(posArr) = 0 Then Exit Sub
	obj.style.posLeft = posArr(1) + offsetX
	obj.style.posTop = posArr(2) + offsetY

End Sub

Sub SetSlideTitlePos ()
	SlideTitle.style.posLeft = SlideLayer.style.posLeft
	SlideTitle.style.posTop = SlideLayer.style.posTop + SlideLayer.style.posHeight + 1
	SlideTitle.style.posWidth = SlideLayer.style.posWidth
End Sub


Function IsAudioContent()
	Dim imgWidth

	If (gbMP7) Then
		imgWidth = MediaPlayer1.currentMedia.imageSourceWidth
	Else
		imgWidth = MediaPlayer1.ImageSourceWidth
	End If
	
	If (imgWidth = 0) Then
		IsAudioContent = True
	Else
		IsAudioContent = False
	End If
End Function

Sub SetbScale( MarkerText )
	sType = GetSubType( MarkerText )

	if sType = 1 or sType = 2 or (not gIsPrevStuff and sType = 3) or sType = 5 then
		sn2.bScale = False
	else
		sn2.bScale = True
	end if
End Sub

Sub ShowDuration()
	if ( LiveMode ) then exit sub
	if not IsObj( PageLayer ) then exit sub

	strTime = MP_Duration()
	if ( strTime = "" or strTime = 0 ) then exit sub

	strTime = "(" & FormatTime(jsParseInt(strTime)) & ")"
	if not IsObj( TimeLayer ) then
		PageLayer.innerHTML = PageLayer.innerHTML & " " & strTime
	else
		TimeLayer.innerHTML = strTime
	end if
End Sub

Function IsUndefined( strVar )
	if ( VarType( strVar ) = 0 or VarType( strVar ) = 1 ) then 	'0:empty, 1:null
		IsUndefined = True
	else
		IsUndefined = False
	end if
End Function

Function GetHideListMetadata( ListIndex )
	if IsObj(SlideList) then  		
		if SlideList.XMLDocument.parseError <> 0 then					
			GetHideListMetadata = "visible"
			Exit Function
		end if
			
		query = "lecture/slide[seq=" & ListIndex & "]/list_visibility"		
		Set snodes = SlideList.XMLDocument.selectNodes(query)
		if snodes.length > 0 then		 
			Set snode = SlideList.XMLDocument.selectSingleNode(query)
			GetHideListMetadata = snode.text
		else
			GetHideListMetadata = "visible"
		end if
	else
		GetHideListMetadata = "visible"
	end if
End Function

Sub SetUIMode()
	if IsObj(SlideList) then  		
		if SlideList.XMLDocument.parseError <> 0 then					
			gUIMode = "NONE"		
		else			
			query = "lecture/initial_ui_mode"		
			Set snodes = SlideList.XMLDocument.selectNodes(query)
			if snodes.length > 0 then		 
				Set snode = SlideList.XMLDocument.selectSingleNode(query)
				gUIMode = snode.text
			else
				gUIMode = "NONE"
			end if
		end if
	else
		gUIMode = "NONE"
	end if
	
	Select Case gUIMode
	Case "NONE"	
	Case "MAXVIDEO"
		'VideoMax_onClick()		
	Case "MAXSLIDE"
		'SlideMax_onClick()
	Case "ZOOMVIDEO"
		DoZoom 2
	Case "ZOOMSLIDE"
	      	DoZoom 1
	End Select
End Sub

Sub PlayAnimations(num)
	if ( not CheckSN() ) then exit sub
	if ( sn2 = "" ) then exit sub
	sn2.execScript "AnimRange2(" & num & ")", "JavaScript"
	sn2.ReserveDelayedUpdate
End Sub

Sub Sn2_OnLiveStop()
	gLiveStop = True
End Sub
