sub ShowHideLayer(name,Show)
	ItemID = IInformationTree.FindItem(name)
	if IInformationTree.IsGroup(ItemID) then
		IInformationTree.SetGroupVisibility ItemID,Show
	else
		Set ITerraExplorerObject = Nothing
		Set ITerraExplorerObject = IInformationTree.GetObject(ItemID)
		If Not ITerraExplorerObject Is Nothing  then 
			If ITerraExplorerObject.ObjectType <= 18 OR ITerraExplorerObject.ObjectType >= 23 Then ' Only terrain Objects
				ITerraExplorerObject.Visible = Show
			End If
		End If
	end if

end sub

sub MonitorMouse()

IPlane.GetPosition LOx,LOy,EH,Direct,tilt,R,doubleCameraDeltaYaw, doubleCameraDeltaPitch

Dist = "30"

abstilt = abs(tilt)												

if Direct >=0 and Direct < 90 then
	ROx = LOx - (sin(Direct*3.14159/180)*cos(abstilt*3.14159/180)*Dist) * 0.000009
	ROy = LOy - (cos(Direct*3.14159/180)*cos(abstilt*3.14159/180)*Dist) * 0.000009
elseif Direct >= 91 and Direct < 180 then
	ROx = LOx - (sin((180 - Direct)*3.14159/180)*cos(abstilt*3.14159/180)*Dist) * 0.000009
	ROy = LOy + (cos((180 - Direct)*3.14159/180)*cos(abstilt*3.14159/180)*Dist) * 0.000009
elseif Direct >= 181 and Direct < 270 then
	ROx = LOx + (sin((Direct - 180)*3.14159/180)*cos(abstilt*3.14159/180)*Dist) * 0.000009
	ROy = LOy + (cos((Direct - 180)*3.14159/180)*cos(abstilt*3.14159/180)*Dist) * 0.000009
elseif Direct >= 271 and Direct < 360 then
	ROx = LOx + (sin((360 - Direct)*3.14159/180)*cos(abstilt*3.14159/180)*Dist) * 0.000009
	ROy = LOy - (cos((360 - Direct)*3.14159/180)*cos(abstilt*3.14159/180)*Dist) * 0.000009
end if

LOh = ITerrain.GetGroundHeight(LOx,LOy,0)

ROTh = ITerrain.GetGroundHeight(ROx,ROy,0)

H = sin(abstilt*3.14159/180)*Dist

ITerraExplorer.GetUserUnits Us,Ua,Uat,Ullt

if Uat = 5 then	'AGL
	ROh = H + (LOh - ROTh)
elseif Uat = 6 then	'ABS
	ROh = H + LOh
end if	

MapiCreateConnection LOx,LOy,EH,Direct,tilt,Dist

end sub

