function OnWarpEnter() 
	SetMarker("cs\\Warp_0072.wp" , 0 , 0) 
	--SetMarker("cs\\Warp_0071.wp" , 0 , 0) 
	SetMarker("cs\\Warp_0068.wp" , 0 , 0) 

	if Music_Change then
		Music_Change = false
		PlayMusic("Sounds/Musiques/M_FouillerChambre.ogg")
	end

	-- bougies
	AnimationSetToStart("exc1",false)

--DAY4
	if ETAT_DAY == "D4" then 
		if TALK_TO_QUEEN_D4 and not TOOK_MAP_FRAGMENT_D4 then
			PutObject("gec1")
		end
		if not TALK_TO_QUEEN_D4 then
			AnimationSetToStart("hac1",false)
			SetMarker("hac1",4,0)
		else
			AnimationSetToEnd("hac1",false)
			if not TALK_JEAN_D4 then
				SetMarker("cs\\Warp_0071.wp" , 0 , 0)
			else
				SetMarker("hac1",4,0)
			end
		end
	end 

--DAY5
	if ETAT_DAY == "D5" then 
		if not JEAN_DOOR_OPENED_D5 then
			AnimationSetToStart("hac1",false)
			SetMarker("hac1",4, 0)
		else
			AnimationSetToEnd("hac1",false)
			SetMarker("cs\\Warp_0071.wp" , 0 , 0)
		end
	end 
end

function OnDialogFinished(dialogName)
	if dialogName == "Ma2281" then
		SetMarker("cs\\Warp_0071.wp",-1, 0) 
--		SetMarker("cs\\Warp_0068.wp",-1,0) 
	end
	if dialogName == "Ma2357" then
		SetMarker("hac1",4,0)
	end
end

function OnWarpLeave()
	if Music_Change then
		-- Musique
		Music_Change = false
		PlayMusic("Sounds/Musiques/M_FouillerChambre.ogg")
	end
end

function OnAnimationFinished(objectName)
	if ETAT_DAY =="D5" then
		if objectName == "hac1" then
			AnimationSetToEnd("hac1",false)
			JEAN_DOOR_OPENED_D5 = true
			SetMarker("cs\\Warp_0071.wp" , 0 , 0) 
		end
	end
end

function OnWarpObjectHit(objectName)

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

	if objectName == "3D\\cs\\Warp_0071.wp" then
		if ETAT_DAY == "D5" then
			if JEAN_DOOR_OPENED_D5 then
				Music_Change = false
				ChangeWarp("3D\\cs\\Warp_0071.wp")
			end
		elseif ETAT_DAY == "D4" then
			if TOOK_MAP_FRAGMENT_D4 and not TALK_JEAN_D4 then
				ChangeWarp("3D\\cs\\Warp_0071.wp")
			elseif TALK_JEAN_D4 then
				DrawText("Ma3171","Ma3171.ogg",0) -- Ce n'est pas le moment
			end 
		end
	end

	if objectName == "3D\\cs\\Warp_0068.wp" then 
		if DEAD_GUARD_PASSAGE_0072_D3 and not DEAD_GUARD_MOVED_D3 then
			DrawText("Ma2514","Ma2514.ogg",0) -- Ce n'est pas le moment. Je dois m'occuper du garde.
		else
			ChangeWarp(objectName)
		end
	end

--DAY4
	if ETAT_DAY == "D4" then 
		if objectName == "hac1" then
			if not TALK_TO_QUEEN_D4 then
				if Selected("B_clef") then 
				       DrawText("Ma3097","Ma3097.ogg",0) -- Il a dû changer la serrure.
				else 
					DrawText("Ma1706","Ma1706.ogg",0) -- C'est fermé à clef.
				end
			end
			if TALK_JEAN_D4 then
				DrawText("Ma3171","Ma3171.ogg",0) -- Ce n'est pas le moment
			end
		end
	end 

--DAY5
	if ETAT_DAY == "D5" then 
		if objectName == "hac1" then
			if not JEAN_DOOR_OPENED_D5 then
				if Selected("B_clef") then 
				       DrawText("Ma3097","Ma3097.ogg",0) -- Il a dû changer la serrure.
				elseif Selected("C_clef_chavigny2") then
					SetMarker("hac1",-1,0)
					StartAnimation("hac1",1,false)
				else 
					DrawText("Ma1706","Ma1706.ogg",0) -- C'est fermé à clef.
				end
			end

		end
	end 
end


function OnDocumentClosed(documentId)

	if documentId == "EndPart1" then
		StopSound("Sounds/SFX/M_Cine008.ogg")
		-- RETOUR MENU
		FinishGame()
	end

end
