function OnWarpEnter() 
	D4_InW178 = true

	if PuzzleLibrary then
		SetMarker("cs\\Warp_0080.wp" , 0 , 0) 
	end
	SetMarker("cs\\Warp_0159.wp" , 0 , 0) 

	if Sidh and not PuzzleLibrary then
		SetMarker("lzc1",4,0)
	end
	Music_Change = false

---------------------------------------------------------------------------------- Runes
	if not Runes then
--		StartAnimationPart("l1c1",0,1,-1,true)
--		StartAnimationPart("l2c1",0,1,-1,true)
--		StartAnimationPart("l3c1",0,1,-1,true)
--		StartAnimationPart("l4c1",0,1,-1,true)
		StartAnimationPart("loc1",51,52,-1,true)
		StartAnimationPart("lpc1",52,53,-1,true)
		StartAnimationPart("lqc1",53,54,-1,true)
		StartAnimationPart("lrc1",54,55,-1,true)
		StartAnimationPart("lsc1",55,56,-1,true)
		StartAnimationPart("ltc1",56,57,-1,true)
		StartAnimationPart("luc1",57,58,-1,true)
		StartAnimationPart("lvc1",58,59,-1,true)
		StartAnimationPart("lwc1",59,60,-1,true)
		StartAnimationPart("lxc1",60,61,-1,true)
		StartAnimationPart("lyc1",61,62,-1,true)
		StartAnimationPart("lzc1",62,63,-1,true)
	end
---------------------------------------------------------------------------------- Taquin
	if not PuzzleLibrary then
		StartAnimationPart("lac1",1,2,-1,true)

		StartAnimationPart("lbc1",3,4,-1,true)

		StartAnimationPart("lcc1",7,8,-1,true)

		StartAnimationPart("ldc1",9,10,-1,true)

		StartAnimationPart("lec1",12,13,-1,true)

		StartAnimationPart("lfc1",15,16,-1,true)

		StartAnimationPart("lgc1",21,22,-1,true)

		StartAnimationPart("lhc1",23,24,-1,true)

		StartAnimationPart("lic1",26,27,-1,true)

		StartAnimationPart("ljc1",30,31,-1,true)

		StartAnimationPart("lkc1",36,37,-1,true)

		StartAnimationPart("llc1",41,42,-1,true)

		StartAnimationPart("lmc1",45,46,-1,true)

		StartAnimationPart("lnc1",49,50,-1,true)
	else
		StartAnimationPart("lac1",0,1,-1,true)

		StartAnimationPart("lbc1",4,5,-1,true)

		StartAnimationPart("lcc1",5,6,-1,true)

		StartAnimationPart("ldc1",9,10,-1,true)

		StartAnimationPart("lec1",14,15,-1,true)

		StartAnimationPart("lfc1",17,18,-1,true)

		StartAnimationPart("lgc1",20,21,-1,true)

		StartAnimationPart("lhc1",22,23,-1,true)

		StartAnimationPart("lic1",27,28,-1,true)

		StartAnimationPart("ljc1",31,32,-1,true)

		StartAnimationPart("lkc1",33,34,-1,true)

		StartAnimationPart("llc1",38,39,-1,true)

		StartAnimationPart("lmc1",46,47,-1,true)

		StartAnimationPart("lnc1",50,51,-1,true)
	end
---------------------------------------------------------------------------------- 


	if ETAT_DAY == "D4" then 
		-- portes de l'armoire
		StartAnimationPart("fbc1",1,2,-1,true)
		if not AMP_BOOK_TAKEN_D4 then
			--- AMP
			PutObject("fnc1",true)
			SetMarker("fnc1",2,0)
		end
		if AMP_BOOK_TAKEN_D4 then
			if not BOOK_PLACED then
				SetMarker("BOOK_PLACE", 4, 0)
			else
				if not BOOK_OPENED then
					AnimationSetToStart("fmc1",true)
					SetMarker("fmc1",4,0)
				elseif BOOK_OPENED and not NOTE_TAKEN then
					StartAnimationPart("fmc1",1,2,-1,true)
					SetMarker("fmc1",2,0)
				elseif BOOK_OPENED and NOTE_TAKEN then
					StartAnimationPart("fmc1",2,3,-1,true)
				end
			end
		end

	end 
	if ETAT_DAY == "D5" then 

	end 
end

function OnDialogFinished(dialogName)
	if dialogName == "Ma2724" then
		ChangeWarp("3D\\cs\\Warp_0058.wp")
		ESCAPE_FROM_CHAVIGNY = true
		MOVED_BOOKS = false
		OPENED_HIDDEN_ROOM = false
	end
end

function OnWarpLeave()
	D4_InW178 = false
	--[[if Music_Change then
		-- Musique
		Music_Change = false
		PlayMusic("Sounds/Musiques/M_souterrain.ogg")
	end]]
end

function OnWarpObjectHit(objectName)

	if objectName == "3D\\cs\\Warp_0080.wp" then 
		if DRESS_CESAR then
			ChangeWarp(objectName)
			--Music_Change = true
			PlayMusic("Sounds/Musiques/M_souterrain.ogg")
		else
			DrawText("Ma2789","Ma2789.ogg",0) -- Ma robe va me gêner.
		end
	end

	if objectName == "3D\\cs\\Warp_0159.wp" then 
		if ObjectCount("E_amp4_livre") < 1 then
			ChangeWarp(objectName)
		else
			if not PuzzleLibrary then
				DrawText("Ma0220","Ma0220.ogg",0) -- Pas encore !
			end
		end
	end

	if objectName == "lzc1" then
		ShowPuzzle(8)
	end

--Fonctionne parfaitement. appelle OnLibraryPuzzleAnswered()
--PuzzleLibrary Id: 8

--DAY4
	if ETAT_DAY == "D4" then 

		--- AMP
		if objectName == "fnc1" then
			if not AMP_BOOK_TAKEN_D4 then
				AMP_BOOK_TAKEN_D4 = true
				SetMarker("fnc1",-1,0)
				AddToBag("E_amp4_livre")
				RemoveObject("fnc1")
				DrawText("Ma2718","Ma2718.ogg",0) -- Le livre 2 de L'Astronomia Magna !
				SetMarker("BOOK_PLACE",4,0)
			end
		elseif objectName == "3D\\BOOK_PLACE" then
			if AMP_BOOK_TAKEN_D4 then
				RemoveFromBag("E_amp4_livre")
				PlaySound("Sounds/SFX/N_OuvertureCommode.ogg",1)
				BOOK_PLACED = true
				-- AMP sur l'écritoire
				AnimationSetToStart("fmc1",true)
				SetMarker("fmc1",4,0)
				SetMarker("BOOK_PLACE",-1,0)
			end

		-- portes de l'armoire
		elseif objectName == "fbc1" then

		-- objet dans l'armoire
		elseif objectName == "fcc1" then

		elseif objectName == "fdc1" then

		-- AMP sur l'écritoire
		elseif objectName == "fmc1" then
			if not BOOK_OPENED then
					StartAnimationPart("fmc1",1,2,-1,true)
					BOOK_OPENED = true
					PlaySound("Sounds/SFX/N_OuvrirLivre.ogg",1)
					DrawText("Ma2719","Ma2719.ogg",0) -- Je savais bien que mon père avait raison : le message de Philibert ne concernait pas qu'un seul livre.
					SetMarker("fmc1",2,0)
			elseif BOOK_OPENED and not NOTE_TAKEN then
--					StartAnimationPart("fmc1",2,3,-1,true)
					AnimationSetToEnd("fmc1")
					SetMarker("fmc1",-1,0)
					AddToBag("C_papier_phillibert2")
					NOTE_TAKEN = true
					SetDiaryPage(17, "Page17")
					PlaySound("Sounds/SFX/J_Surprise.ogg",1)
					LookAt(176,007)
					DrawText("Ch2723","Ch2723.ogg",3) -- Il y a quelqu'un ?
					DrawText("Ma2724","Ma2724.ogg",0) -- Autant ne pas traîner ici, c'est inutile que tout le monde découvre cet endroit.
					JEAN_AT_LIBRARY_D4 = true
					ESCAPE_FROM_CHAVIGNY = true
					MOVED_BOOKS = false 
					OPENED_HIDDEN_ROOM = false 
			end
		elseif objectName == "lac1" then

		elseif objectName == "lcc1" then

		elseif objectName == "lec1" then

		elseif objectName == "lfc1" then

		elseif objectName == "lgc1" then

		elseif objectName == "lic1" then

		elseif objectName == "ljc1" then

		elseif objectName == "lkc1" then

		elseif objectName == "llc1" then

		elseif objectName == "lmc1" then

		elseif objectName == "lnc1" then

		elseif objectName == "loc1" then

		elseif objectName == "lpc1" then

		elseif objectName == "lqc1" then

		elseif objectName == "lrc1" then

		elseif objectName == "lsc1" then

		elseif objectName == "ltc1" then

		elseif objectName == "luc1" then

		elseif objectName == "lvc1" then

		elseif objectName == "lwc1" then

		elseif objectName == "lxc1" then

		elseif objectName == "lyc1" then

		elseif objectName == "lzc1" then

		end
	end 

--DAY5
	if ETAT_DAY == "D5" then 

	end 
end

function OnLibraryPuzzleAnswered()

	SetMarker("cs\\Warp_0080.wp" , 0 , 0) 
	PuzzleLibrary = true
	SetMarker("lzc1",-1,0)

	StartAnimationPart("lac1",0,1,-1,true)

	StartAnimationPart("lbc1",4,5,-1,true)

	StartAnimationPart("lcc1",5,6,-1,true)

	StartAnimationPart("ldc1",9,10,-1,true)

	StartAnimationPart("lec1",14,15,-1,true)

	StartAnimationPart("lfc1",17,18,-1,true)

	StartAnimationPart("lgc1",20,21,-1,true)

	StartAnimationPart("lhc1",22,23,-1,true)

	StartAnimationPart("lic1",27,28,-1,true)

	StartAnimationPart("ljc1",31,32,-1,true)

	StartAnimationPart("lkc1",33,34,-1,true)

	StartAnimationPart("llc1",38,39,-1,true)

	StartAnimationPart("lmc1",46,47,-1,true)

	StartAnimationPart("lnc1",50,51,-1,true)

end
