
dim csNextFly
dim bOrtho

'sub TE_OnLoadFinished()
'   GetCookieProps 
'end sub

Sub SetCookieProp(strName , vntValue )
     Document.cookie = strName & "=" & CStr(vntValue) 
End Sub


Function GetCookieProp(strName) 
    Dim aryCookies 
    Dim strCookie 
    On Error resume next
    aryCookies = Split(Document.cookie, ";")
    GetCookieProp = ""
    For Each strCookie In aryCookies
        If Trim(Left(strCookie, InStr(strCookie, "=") - 1)) = Trim(strName) Then
            GetCookieProp = Trim(Mid(strCookie, InStr(strCookie, "=") + 1))
            Exit Function
        End If
        Err = 0
    Next 
End Function

sub SetCookieProps()
   
   plane.GetPosition X, Y, Z, Yaw, Pitch, Roll, DYaw, DPitch
   SetCookieProp "X",X
   SetCookieProp "Y",Y
   SetCookieProp "Z",Z
   SetCookieProp "Yaw",Yaw
   SetCookieProp "Pitch",Pitch
   SetCookieProp "Roll",Roll
   SetCookieProp "DYaw",DYaw
   SetCookieProp "DPitch",DPitch
   SetCookieProp "DRoll",DRoll
end sub

sub GetCookieProps()
 
   X = GetCookieProp("X")
   Y = GetCookieProp("Y")
   Z = GetCookieProp("Z")
   Yaw = GetCookieProp("Yaw")
   Pitch = GetCookieProp("Pitch")
   Roll = GetCookieProp("Roll")
   DYaw = GetCookieProp("DYaw")
   DPitch = GetCookieProp("DPitch")
   DRoll = GetCookieProp("DRoll")
   if X <> "" and Y <> "" and Z <> "" and _
      Yaw <> "" and Pitch <> "" and Roll <> "" and _
      DYaw <> "" and DPitch <> "" then
      plane.SetPosition X, Y, Z, Yaw, Pitch, Roll, DYaw, DPitch
   end if
end sub


sub GetNextFly()

   csTmp = TE.FlyName
   'msgbox csTmp
   csRep = ""
   MyposO = instrrev(csTmp, "_ortho", -1 ,1) 
   if MyposO = 0 then 
      MyposO = instrrev(csTmp, "_scan25", -1 ,1) 
   end if 
   MyposS = instrrev(csTmp, "/", -1 ,1) 
   if MyposS = 0 then 
      MyposS = instrrev(csTmp, "\", -1 ,1) 
   end if
   csNextFly = Mid(csTmp, MyposS+1, MyposO - MyposS - 1)
   csRep = Left(csTmp, MyposS)
   csTmp = terrain.MPTName
   MyposTGAdr = instrrev(csTmp, "navigalis.cg22.fr:8080", -1 ,1)
   if MyposTGAdr > 0 then
      csRep = "http://navigalis.cg22.fr/fly/" 
   end if
   MyposOrthoMPT = instrrev(csTmp, "_ortho.mpt", -1 ,1) 
   if MyposOrthoMPT > 0 then
      bOrtho = True
      csNextFly = csRep & csNextFly & "_scan25.fly"
      'document.getElementById("ButOrtho").src = "PhotosD.jpg"
      'document.getElementById("ButScan").src = "CarteU.jpg"
   else
      bOrtho = False
      csNextFly = csRep &  csNextFly & "_ortho.fly"
      'document.getElementById("ButOrtho").src = "PhotosU.jpg"
      'document.getElementById("ButScan").src = "CarteD.jpg"
   end if
   GetCookieProps
end sub

sub ClicOrtho()
   'document.getElementById("ButOrtho").src = "PhotosD.jpg"
   if bOrtho = False then
      SetCookieProps
      TE.Load csNextFly
      'GetCookieProps
      exit sub
   end if
end sub 

sub ClicScan()
   'document.getElementById("ButScan").src = "CarteD.jpg"
   if bOrtho = True then
      SetCookieProps
      TE.Load csNextFly
      'GetCookieProps
      exit sub
   end if
end sub 



