function OnWarpEnter() 

	SetMarker("cs\\Warp_0214.wp" , 0 , 0)
--	SetMarker("Machine_Revolution", 4, 0)
	if HENRYCHART_ON_MACHINE_D3 and not PUZZLE_ASTROCHART_SOLVED and not OpenMachineW21 then
		SetMarker("Machine_Revolution", 4, 0)
	end
	SetMarker("zoomMachine", 4, 0)
	SetMarker("HENRY_CHARTN", 4, 0)

	ImportAnimationWarp("3D\\cs\\Warp_0021")

	-- manivelle du calculateur
	AnimationSetToStart("zoan",false)
	SetMarker("zoan", 4, 0)
	-- mécanisme du mobile
	AnimationSetToStart("vyan",false)

	if PuzzlePlanetSolved then
		PutObject("zwa1",false)
	end

	if not CoffreW221 then
		AnimationSetToStart("zyan")
		if AskMobile then
			SetMarker("zyan",4,0)
		end
	else
		AnimationSetToEnd("zyan")
		if AskMobile and not PuzzlePlanetPut then
			SetMarker("zyan",2,0)
		end
	end

	if not OpenMachineW21 then
		AnimationSetToStart("zman",false)
	elseif OpenMachineW21 then
		AnimationSetToEnd("zman",false)
		if HENRYCHART_ON_MACHINE_D3 then
			AnimationSetToStart("zna1",false)
			if PUZZLE_ASTROCHART_SOLVED then
				SetMarker("zna1",2,0)
			end
		end
	end

--------------------------------------------------------------------------- balcon
	if balcony_open then
	-- sortie du balcon
		if not ETAT_DAY == "D4" then
			SetMarker("cs\\Warp_0222.wp" , 0 , 0) 
		else
			if not PuzzlePlanetSolved then
				SetMarker("cs\\Warp_0222.wp" , 0 , 0) 
			end
		end
	end
	AnimationSetToEnd("cxan")
	AnimationSetToEnd("cyan")
---------------------------------------------------------------------------

--------------------------------------------------------------------------- Puzzle du thème astral
	if not PUZZLE_ASTROCHART_SOLVED then
		AnimationSetToStart("zaan",false)
		AnimationSetToStart("zcan",false)
		AnimationSetToStart("zean",false)
		AnimationSetToStart("zgan",false)
		AnimationSetToStart("zian",false)
		AnimationSetToStart("zkan",false)
	end
--------------------------------------------------------------------------- 

--DAY3 
	if ETAT_DAY == "D3" then 
		AnimationSetToStart("zoan",false)
		SetMarker("zoan",4,0)
		if HENRYCHART_ON_MACHINE_D3 then
			if PUZZLE_ASTROCHART_SOLVED and OpenMachineW21 then
				AnimationSetToStart("zna1",true)
				SetMarker("zna1",2,0)
			else
				SetMarker("HENRY_CHARTN",4,0)
			end
		else
			SetMarker("HENRY_CHARTN",4,0)
		end
	end
end

function OnDialogFinished(dialogName)
end

function OnMovieFinished(name)
end

function OnAnimationFinished(objectName)

	if objectName=="zoan" then
		AnimationSetToStart("zoan",true)
		SetMarker("zoan",4,0)
	end
end



function OnWarpLeave()
end


function OnWarpObjectHit(objectName)

	if objectName == "3D\\cs\\Warp_0222.wp" then 
		if balcony_open then
			if not ETAT_DAY == "D4" then
				ChangeWarp("3D\\cs\\Warp_0222.wp")
			else
				if not PuzzlePlanetSolved then
					ChangeWarp("3D\\cs\\Warp_0222.wp")
				else
					SetMarker("cs\\Warp_0022.wp", -1 , 0)
				end
			end
		end
	end

	if objectName == "3D\\cs\\Warp_0214.wp" then 
		ChangeWarp(objectName)
	end

	if objectName == "3D\\zoomMachine" then 
		ShowDocument("MachineRevolution")
	end

	if objectName == "3D\\HENRY_CHARTN" then
		if not HENRYCHART_ON_MACHINE_D3 then
			if Selected("A_theme_Henri_Navarre") and OpenMachineW21 then
				RemoveFromBag()
				AnimationSetToStart("zoan",false)
				HENRYCHART_ON_MACHINE_D3 = true
				AnimationSetToStart("zna1",false)
				PlaySound("Sounds/SFX/N_TournerPage.ogg",1)
			elseif not OpenMachineW21 then
				AnimationSetToEnd("zman",false)
				PlaySound("Sounds/SFX/N_FermeturePoele.ogg",1)
				OpenMachineW21 = true
			elseif OpenMachineW21 then
				AnimationSetToStart("zman",false)
				PlaySound("Sounds/SFX/N_FermeturePoele.ogg",1)
				OpenMachineW21 = false
			end
		elseif HENRYCHART_ON_MACHINE_D3 and not PUZZLE_ASTROCHART_SOLVED then
			if not OpenMachineW21 then
				DrawText("Ma0220","Ma0220.ogg",0) -- Pas encore !
			elseif OpenMachineW21 then
				AnimationSetToStart("zman",false)
				RemoveObject("zna1")
				PlaySound("Sounds/SFX/N_FermeturePoele.ogg",1)
				OpenMachineW21 = false
				SetMarker("Machine_Revolution",4,0)
			end
		end
	 end

	if objectName == "zna1" then
		if PUZZLE_ASTROCHART_SOLVED and HENRYCHART_ON_MACHINE_D3 then	
			RemoveObject("zna1")
			AddToBag("A_theme_Henri_Navarre")
			RemoveFromBag("A_theme_Henri_Navarre")
			SetDiaryPage(12, "Page12_02")
			SetDiaryPage(13, "Page13")
			HENRYCHART_ON_MACHINE_D3 = false
			SetMarker("HENRY_CHARTN",4, 0)
			SetMarker("zna1",-1,0)
			AstrochartTaken = true
		end

	elseif objectName == "zoan" then
		PlaySound("Sounds/SFX/N_BruitDeSerrure.ogg",1)
		StartAnimation("zoan",1)
		SetMarker("zoan",-1,0)
		if HENRYCHART_ON_MACHINE_D3 and PuzzleThemeDone and not OpenMachineW21 then
			PUZZLE_ASTROCHART_SOLVED = true
			AnimationSetToEnd("zman",false)
			PlaySound("Sounds/SFX/N_FermeturePoele.ogg",1)
			OpenMachineW21 = true
			AnimationSetToStart("zna1",false)
			SetMarker("zna1",2,0)
			OpenMachineW21 = true
			SetMarker("HENRY_CHARTN",-1, 0)
		end

	elseif objectName == "3D\\Machine_Revolution" then
		if not PuzzleThemeDone then
			ShowPuzzle(10)
		end
	
	end
end

function OnAstralThemePuzzleAnswered()
	PuzzleThemeDone = true
	SetMarker("Machine_Revolution",-1,0)
end
