Option Explicit
Dim counter
Dim apply


'code to access third person view and controlling toggle buttons
public sub thirdperson_Click()

Dim third
dim first
Dim v 

Set v = nwControl01.State.CurrentView.ViewPoint
third = nwControl01.State.GetEnum("eCameraMode_ThirdPerson")
first = nwControl01.State.GetEnum("eCameraMode_FirstPerson")

if v.Viewer.CameraMode = third then
   
   v.Viewer.CameraMode = first
   thirdperson.src = "/mirror/files/activex/thirdperson_f.png"
else

	v.Viewer.CameraMode = third
	thirdperson.src = "/mirror/files/activex/thirdperson_s.png"
end if

end sub

'--------------------------------------------------------------

public sub thirdperson_onmouseover()
Dim third
dim first
Dim v 

Set v = nwControl01.State.CurrentView.ViewPoint
third = nwControl01.State.GetEnum("eCameraMode_ThirdPerson")
first = nwControl01.State.GetEnum("eCameraMode_FirstPerson")

	   if v.Viewer.CameraMode = first then
		thirdperson.src = "/mirror/files/activex/thirdperson.png"
		end if

end sub


public sub thirdperson_onmouseout()

Dim third
dim first
Dim v 

Set v = nwControl01.State.CurrentView.ViewPoint
third = nwControl01.State.GetEnum("eCameraMode_ThirdPerson")
first = nwControl01.State.GetEnum("eCameraMode_FirstPerson")

	if v.Viewer.CameraMode = first then
	   thirdperson.src = "/mirror/files/activex/thirdperson_f.png"
	end if

end sub
'--------------------------------------------------------
public Sub hyperlinks_Click()

		if NWControl01.State.URLsEnabled = True then
		   NWControl01.State.URLsEnabled = false
		   hyperlinks.src = "/mirror/files/activex/hyperlink_f.png"
		else
			NWControl01.State.URLsEnabled = True  
			hyperlinks.src = "/mirror/files/activex/hyperlink_s.png"
		end if
    
End Sub

'--------------------------------------------------------
public sub hyperlinks_onmouseover()

		if NWControl01.State.URLsEnabled = false then
		hyperlinks.src = "/mirror/files/activex/hyperlinks.png"
		end if
		
	end sub

public sub hyperlinks_onmouseout()
	   
	   if NWControl01.State.URLsEnabled = false then
		hyperlinks.src = "/mirror/files/activex/hyperlink_f.png"
		end if
		
	end sub
'------------------------------------------------------------------
public sub btnViewAll_Clicked()

		NWControl01.state.ViewAll
		
	end sub

public sub btnViewAll_onmouseover()
		
		btnViewAll.src = "/mirror/files/activex/viewall.png"
		
	end sub

public sub btnViewAll_onmouseout()

		btnViewAll.src = "/mirror/files/activex/viewall_f.png"
		
	end sub

'---------------------------------------------------------------
public sub btnNav1_onmouseover()

	 if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (3) then 
		btnNav1.src = "/mirror/files/activex/walk.png"
	end if 
	
	end sub

public sub btnNav1_onmouseout()

		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (3) then 
		btnNav1.src = "/mirror/files/activex/walk_f.png"
		end if 
		
	end sub

'-------------------------------------------------------------
public sub btnNav2_onmouseover()
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (1) then 
		btnNav2.src = "/mirror/files/activex/lookAround.png"
		end if
		
	end sub
	
public sub btnNav2_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (1) then 
		btnNav2.src = "/mirror/files/activex/lookAround_f.png"
		end if
	end sub
	
'-------------------------------------------------------------

public sub btnNav3_onmouseover()
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (7) then 
		btnNav3.src = "/mirror/files/activex/zoom.png"
		end if
		
	end sub
	
public sub btnNav3_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (7) then 
		btnNav3.src = "/mirror/files/activex/zoom_f.png"
		end if
		
	end sub
'---------------------------------------------------------

public sub btnNav4_onmouseover()
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (12) then 
		btnNav4.src = "/mirror/files/activex/zoombox.png"
		end if
		
	end sub
	
public sub btnNav4_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (12) then 
		btnNav4.src = "/mirror/files/activex/zoombox_f.png"
		end if
		
	end sub
	
'--------------------------------------------------------

public sub btnNav5_onmouseover()
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (8) then 
		btnNav5.src = "/mirror/files/activex/pan.png"
		end if
		
	end sub
	
public sub btnNav5_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (8) then 
		btnNav5.src = "/mirror/files/activex/pan_f.png"
		end if
		
	end sub
	
'-------------------------------------------------------

public sub btnNav6_onmouseover()
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (11) then 
		btnNav6.src = "/mirror/files/activex/orbit.png"
		end if
		
	end sub
	
public sub btnNav6_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (11) then 
		btnNav6.src = "/mirror/files/activex/orbit_f.png"
		end if
		
	end sub
'-------------------------------------------------------

public sub btnNav7_onmouseover()
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (2) then 
		btnNav7.src = "/mirror/files/activex/examine.png"
		end if
		
	end sub
	
public sub btnNav7_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (2) then 
		btnNav7.src = "/mirror/files/activex/examine_f.png"
		end if
		
	end sub
'--------------------------------------------------------

public sub btnNav8_onmouseover()
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (4) then 
		btnNav8.src = "/mirror/files/activex/fly.png"
		end if
		
	end sub
	
public sub btnNav8_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (4) then 
		btnNav8.src = "/mirror/files/activex/fly_f.png"
		end if
		
	end sub
	
'-------------------------------------------------

public sub btnNav9_onmouseover()
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (5) then 
		btnNav9.src = "/mirror/files/activex/turntable.png"
		end if
		
	end sub
	
public sub btnNav9_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Paradigm <> (5) then 
		btnNav9.src = "/mirror/files/activex/turntable_f.png"
		end if 
		
	end sub
'-------------------------------------------------
public sub btnNavG_onmouseover()

		if NWControl01.state.CurrentView.ViewPoint.Viewer.Gravity = false then
		btnNavG.src = "/mirror/files/activex/gravity.png"
		end if
		
	end sub
	
public sub btnNavG_onmouseout()
	   
	   if NWControl01.state.CurrentView.ViewPoint.Viewer.Gravity = false then
		btnNavG.src = "/mirror/files/activex/gravity_f.png"
		end if
		
	end sub
	
'------------------------------------------------

public sub btnNavC_onmouseover()

		if NWControl01.state.CurrentView.ViewPoint.Viewer.CollisionDetection = false then
		btnNavC.src = "/mirror/files/activex/collision.png"
		end if 
		
	end sub
	
public sub btnNavC_onmouseout()

	   if NWControl01.state.CurrentView.ViewPoint.Viewer.CollisionDetection = false then
		btnNavC.src = "/mirror/files/activex/collision_f.png"
		end if
		
	end sub

'----------------------------------------------------

'controlling toggles for navigation buttons
public sub btnNav_Clicked(nmd_ndx)

		NWControl01.state.CurrentView.ViewPoint.Paradigm = (nmd_ndx)
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (3) then 
		btnNav1.src = "/mirror/files/activex/walk_s.png"
		else
		btnNav1.src = "/mirror/files/activex/walk_f.png"
		end if
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (1) then 
		btnNav2.src = "/mirror/files/activex/lookAround_s.png"
		else
		btnNav2.src = "/mirror/files/activex/lookAround_f.png"
		end if
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (7) then 
		btnNav3.src = "/mirror/files/activex/zoom_s.png"
		else
		btnNav3.src = "/mirror/files/activex/zoom_f.png"
		end if
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (12) then 
		btnNav4.src = "/mirror/files/activex/zoombox_s.png"
		else
		btnNav4.src = "/mirror/files/activex/zoombox_f.png"
		end if
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (8) then 
		btnNav5.src = "/mirror/files/activex/pan_s.png"
		else
		btnNav5.src = "/mirror/files/activex/pan_f.png"
		end if
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (11) then 
		btnNav6.src = "/mirror/files/activex/orbit_s.png"
		else
		btnNav6.src = "/mirror/files/activex/orbit_f.png"
		end if
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (2) then 
		btnNav7.src = "/mirror/files/activex/examine_s.png"
		else
		btnNav7.src = "/mirror/files/activex/examine_f.png"
		end if
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (4) then 
		btnNav8.src = "/mirror/files/activex/fly_s.png"
		else
		btnNav8.src = "/mirror/files/activex/fly_f.png"
		end if
		
		if NWControl01.state.CurrentView.ViewPoint.Paradigm = (5) then 
		btnNav9.src = "/mirror/files/activex/turntable_s.png"
		else
		btnNav9.src = "/mirror/files/activex/turntable_f.png"
		end if
		
		end sub
'-------------------------------------------------------------														  


	public sub btnNavG_Clicked()
	
	if NWControl01.state.CurrentView.ViewPoint.Viewer.Gravity = true then
		   NWControl01.state.CurrentView.ViewPoint.Viewer.Gravity = false
		   btnNavG.src = "/mirror/files/activex/gravity_f.png"
		else
			NWControl01.state.CurrentView.ViewPoint.Viewer.Gravity = true  
			NWControl01.state.CurrentView.ViewPoint.Viewer.CollisionDetection = true
			btnNavG.src = "/mirror/files/activex/gravity_s.png"
			btnNavC.src = "/mirror/files/activex/collision_s.png"
		end if
	
	end sub 
	
	public sub btnNavC_Clicked()
	
	if NWControl01.state.CurrentView.ViewPoint.Viewer.CollisionDetection = true then
		   NWControl01.state.CurrentView.ViewPoint.Viewer.CollisionDetection = false
		   btnNavC.src = "/mirror/files/activex/collision_f.png"
		else
			NWControl01.state.CurrentView.ViewPoint.Viewer.CollisionDetection = true  
			btnNavC.src = "/mirror/files/activex/collision_s.png"
		end if
	end sub 
	
'-------------------------------------------------------------------	
	
public Sub Combo1_DropDown()
'this procedure fills the drops down combo
Dim i
   apply = 0
    counter = 0
    for i = 0 to document.forms("viewpoint_settings").Combo1.Length
    	document.forms("viewpoint_settings").Combo1.Options.Remove 1
	next
    findall False
End Sub

public Sub Combo2_DropDown()
'when user drops down combo
Dim i
   apply = 0
    counter = 0
	for i = 0 to document.forms("viewpoint_settings").Combo2.Length
    	document.forms("viewpoint_settings").Combo2.Options.Remove 1
	next
    findall True
End Sub	

public Sub Combo1_onchange() ' displays views
    counter = 0
	apply = document.forms("viewpoint_settings").Combo1.SelectedIndex +1
	
    findall False
	
End Sub
	
Public Sub Combo2_onchange() ' displays animation
    counter = 0
    apply = document.forms("viewpoint_settings").Combo2.SelectedIndex +1
    findall True
End Sub
	
	
public Sub myrecurse(view, anims) 'runs through 3 different options, i.e. when a view is passed through 
	   	   				   		  ' the function, when an animation is passed through the function and
								  ' when a group of views are passed.

Dim cmd
Dim oOption
Dim eCmd_Play

Select Case view.ObjectName
Case "nwOpView"
    If Not anims Then
        counter = counter + 1
			
        If apply > 0 Then
		  
           If apply = counter + 1 Then 
		   
		   NWControl01.State.ApplyView view
		   
		   end if
        	Else
			'msgbox apply
				Set oOption = document.createElement("OPTION")
				oOption.text= view.Name
				oOption.value=view.Name

				document.forms("viewpoint_settings").Combo1.Add oOption
			
        	End If

    End If
	
Case "nwOpAnimView"
   If anims Then
        counter = counter + 1
        If apply > 0 Then
		   
            If apply = counter + 1 Then
			
                NWControl01.State.CurrentAnimation = view
				play_Clicked()
				
            End If
        Else
            Set oOption = document.createElement("OPTION")
			oOption.text= view.Name
			oOption.value=view.Name

			document.forms("viewpoint_settings").Combo2.Add oOption
        End If

    End If

Case "nwOpFolderView"
    
    Dim folder
    Set folder = view
    Dim childview 
    For Each childview In folder.SavedViews
        myrecurse childview, anims
    Next
End Select

document.forms("viewpoint_settings").Combo1.SelectedIndex = 0
document.forms("viewpoint_settings").Combo2.SelectedIndex = 0

End Sub
	

public sub pause_Clicked()
	   
	    NWControl01.AnimationCommand NWControl01.State.GetEnum("eCmd_Pause")
		stop1.src = "/mirror/files/activex/stop_f.png"
		play.src = "/mirror/files/activex/play_f.png"
		pause.src = "/mirror/files/activex/pause_s.png"
		btnNav_Clicked(NWControl01.state.CurrentView.ViewPoint.Paradigm)
		
end sub


public sub stop1_Click()
Dim nmd_ndx   
	   NWControl01.AnimationCommand NWControl01.State.GetEnum("eCmd_Stop")
	    stop1.src = "/mirror/files/activex/stop_s.png"
		play.src = "/mirror/files/activex/play_f.png"
		pause.src = "/mirror/files/activex/pause_f.png" 
		btnNav_Clicked(NWControl01.state.CurrentView.ViewPoint.Paradigm)
		
end sub

public sub play_Clicked()
   
	   NWControl01.AnimationCommand NWControl01.State.GetEnum("eCmd_Play")
	    stop1.src = "/mirror/files/activex/stop_f.png"
		play.src = "/mirror/files/activex/play_s.png"
		pause.src = "/mirror/files/activex/pause_f.png"
		
	   
end sub

public Sub findall(anims) 'checks each viewpoint for animations/groups
    Dim view 
	
    For Each view In NWControl01.State.SavedViews
        myrecurse view, anims
    Next
	
    btnNav_Clicked(NWControl01.state.CurrentView.ViewPoint.Paradigm)
End Sub

public Sub NWControl01_onmouseout()

	   btnNav_Clicked(NWControl01.state.CurrentView.ViewPoint.Paradigm)
	   
end sub


'-------------------------------------------------------------
sub window_onLoad()

	NWControl01.src = "http://navisworks.com/mirror/files/activex/Brewery.nwd"
	
	Combo1_DropDown()
	Combo2_DropDown()
	
	
End Sub