function OnWarpEnter() 
	SetMarker("cs\\Warp_0070.wp" , 0 , 0) 
	Music_Change = false

--DAY3
	if ETAT_DAY == "D3" then
	
------------------------------------------------------------------------------ AMP
		if not AmpOpen_0071_D3 then
			AnimationSetToStart("hfc1")
			SetMarker("hfc1",4,0)
		elseif AmpOpen_0071_D3 and not O_papier_philibert_0071 then
			StartAnimationPart("hfc1",2,3,-1,true)
			SetMarker("hfc1",2,0)
		else
			StartAnimationPart("hfc1",3,4,-1,true)
		end
------------------------------------------------------------------------------ 

		if DrawOpen_0071_D3 then
			AnimationSetToEnd("hdc1",false)
			SetMarker("INVESTIGATE_DESK",4,0)
			-- Cache sous le cuir du secrétaire
			if not LeatherCutW71 then
				AnimationSetToStart("hkc1")
--			elseif LeatherCutW71 and not QuatrainFoundW71 then
--				StarAnimationPart("hkc1",1,2,-1,false)
			elseif QuatrainFoundW71 and not ThemeW71 then
				AnimationSetToEnd("hkc1")
			elseif not DrawerThemeW71 and not ThemeW71 then
				AnimationSetToStart("hec1",false)
			elseif DrawerThemeW71 and not ThemeW71 then
				StartAnimationPart("hec1",0,1,-1,false)
			elseif ThemeW71 and not QuatrainFoundW71  then
				AnimationSetToEnd("hec1",false)
			elseif ThemeW71 and QuatrainFoundW71  then
				AnimationSetToStart("hdc1",true)
			end
		else
			AnimationSetToStart("hdc1",true)
			SetMarker("hdc1",4,0)
		end

		if JEAN_STAND_IN_ROOM_0071_D3 then
			StartAnimationPart("hcc1",0,30,-1,false)
			SetMarker("hcc1",4,0)
		end
	end 

--DAY4
	if ETAT_DAY == "D4" then 
		AnimationSetToStart("hdc1")
		StartAnimationPart("hbc1",0,30,-1,true)
		SetMarker("hbc1",4,0)
	end 

end

function OnAnimationFinished(objectName)
	if objectName == "hdc1" then
		SetMarker("hdc1",-1,0)
		DrawOpen_0071_D3 = true
--		STAR_CHART_TAKEN_D3 = true
--		PARCHMENT_TAKEN_D3 = true
		AnimationSetToEnd("hdc1",false)
		SetMarker("INVESTIGATE_DESK",4,0)
		AnimationSetToStart("hkc1")
		AnimationSetToStart("hec1",false)
--		if O_papier_philibert_0071 then
--			if DRESS_CESAR then
--			DrawText("Ch2447","Ch2447.ogg",3)
--			elseif DRESS_MADELEINE then
--				DrawText("Ch2455","Ch2455.ogg",3)
--			end
--		end
	end
	
	if objectName == "hfc1" then
		SetMarker("hfc1",2,0)
		DrawText("Ma2286","Ma2286.ogg",0) -- Sacré Philibert !
		AmpOpen_0071_D3 = true
	end
end

function OnDialogFinished(dialogName)

	if ETAT_DAY == "D3" then
		if dialogName == "Ch2447"  or dialogName == "Ch2455" then
			LookAt(26,7)
			StartAnimationPart("hcc1",0,30,-1,false)
			ChavignyInW71 = true
			JEAN_DOOR_OPENED_D3 = false
			AskSeparation()
		end
		if dialogName == "Ce2484" or dialogName == "Ce2490" or dialogName == "Ma2454" or dialogName == "Ma2468"  then
			JEAN_STAND_IN_ROOM_0071_D3 = false
			DEAD_GUARD_PASSAGE_0072_D3 = true
			GUARD_ON_PASSAGE_0072_D3 = false
			ChangeWarp("3D\\cs\\Warp_0070.wp")
		end

		if dialogName == "Ch2473" or dialogName == "Ch2475" or dialogName == "Ch2477" or dialogName == "Ch2479" 
		or dialogName == "Ch2481" or dialogName == "Ch2483" or dialogName == "Ch2486" or dialogName == "Ch2489" 
		or dialogName == "Ch2450" or dialogName == "Ch2453" or dialogName == "Ch2457" or dialogName == "Ch2459" 
		or dialogName == "Ch2461" or dialogName == "Ch2463" or dialogName == "Ch2465" or dialogName=="Ch2467" then
			StartAnimationPart("hcc1",0,30,-1,false)
		end
		if dialogName == "Ce2472" or dialogName == "Ce2474" or dialogName == "Ce2476" or dialogName == "Ce2478" or dialogName == "Ce2480" or dialogName == "Ce2482" or dialogName == "Ce2485" or dialogName == "Ce2488" then
			StartAnimationPart("hcc1",30,60,-1,false)
		end
		if dialogName == "Ma2449" or dialogName == "Ma2451" or dialogName == "Ma2456" or dialogName == "Ma2458" or dialogName == "Ma2460" or dialogName == "Ma2462" or dialogName == "Ma2464" or dialogName == "Ma2466" then
			StartAnimationPart("hcc1",30,60,-1,false)
		end
		if dialogName == "Ma2284" then
			StartAnimationPart("hfc1",0,3,1,true)
			PlaySound("Sounds/SFX/N_OuvrirLivre.ogg",1)
		end
	end

	if ETAT_DAY == "D4" then
		if dialogName == "Ch2653" or dialogName == "Ch2666" or dialogName == "Ch2667" or dialogName == "Ch2657" then
			LookAt(358,16)
			DrawText("Ma2656","Ma2656.ogg",0)
		end
		if dialogName == "Ma2656" then
			ChangeWarp("3D\\cs\\Warp_0070.wp")
		end
		if dialogName == "Ch2647" or dialogName == "Ch2663" or dialogName == "Ch2666" then
			StartAnimationPart("hbc1",0,30,-1,false)
		end
		if dialogName == "Ma2649" or dialogName == "Ce2662" or dialogName == "Ce2664" or dialogName == "Ma2651"  then
			StartAnimationPart("hbc1",30,60,-1,false)
		end
		
	end
end

function AskSeparation()
	if ETAT_DAY == "D3" then	
		if DRESS_CESAR then
			PushAnswer("Ce2471")
			PushAnswer("Ce2485")	
		elseif DRESS_MADELEINE then
			PushAnswer("Ma2449") -- La porte était ouverte, j'ai pensé que je pouvais t'attendre ici.
			PushAnswer("Ma2456") -- Si tu n'étais pas si cachottier, je ne serais pas obligée de le faire.
		end
	end
end

function OnAnswered(textId)
	if ETAT_DAY == "D3" then
		if textId == "Ce2471"  then
			DrawText("Ce2472","Ce2472.ogg",1)
			DrawText("Ch2473","Ch2473.ogg",3)
			DrawText("Ce2474","Ce2474.ogg",1)
			DrawText("Ch2475","Ch2475.ogg",3)
			DrawText("Ce2476","Ce2476.ogg",1)
			DrawText("Ch2477","Ch2477.ogg",3)
			DrawText("Ce2478","Ce2478.ogg",1)
			DrawText("Ch2479","Ch2479.ogg",3)
			DrawText("Ce2480","Ce2480.ogg",1)
			DrawText("Ch2481","Ch2481.ogg",3)
			DrawText("Ce2482","Ce2482.ogg",1)
			DrawText("Ch2483","Ch2483.ogg",3)
			DrawText("Ce2484","Ce2484.ogg",1)
			
		end
		if textId == "Ce2485" then
			DrawText("Ce2485","Ce2485.ogg",1)
			DrawText("Ch2486","Ch2486.ogg",3)
			DrawText("Ce2487","Ce2487.ogg",1)
			DrawText("Ce2488","Ce2488.ogg",1)
			DrawText("Ch2489","Ch2489.ogg",3)
			DrawText("Ce2490","Ce2490.ogg",1)
		end
		if textId == "Ma2449" then
			DrawText("Ma2449","Ma2449.ogg",0) -- La porte était ouverte, j'ai pensé que je pouvais t'attendre ici.
			DrawText("Ch2450","Ch2450.ogg",3)
			DrawText("Ma2451","Ma2451.ogg",0)
			DrawText("Ch2452","Ch2452.ogg",3)
			DrawText("Ch2453","Ch2453.ogg",3)
			DrawText("Ma2454","Ma2454.ogg",0)
		end
		if textId == "Ma2456" then
			DrawText("Ma2456","Ma2456.ogg",0)
			DrawText("Ch2457","Ch2457.ogg",3)
			DrawText("Ma2458","Ma2458.ogg",0)
			DrawText("Ch2459","Ch2459.ogg",3)
			DrawText("Ma2460","Ma2460.ogg",0)
			DrawText("Ch2461","Ch2461.ogg",3)
			DrawText("Ma2462","Ma2462.ogg",0)
			DrawText("Ch2463","Ch2463.ogg",3)
			DrawText("Ma2464","Ma2464.ogg",0)
			DrawText("Ch2465","Ch2465.ogg",3)
			DrawText("Ma2466","Ma2466.ogg",0)
			DrawText("Ch2467","Ch2467.ogg",3)
			DrawText("Ma2468","Ma2468.ogg",0)
		end
	end
end

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

function OnWarpObjectHit(objectName)

	if objectName == "3D\\cs\\Warp_0070.wp" then 
		if ETAT_DAY == "D3" then
--			Music_Change = true
--			if not DrawerW71 and not StampW71 and not QuatrainW71 and not O_papier_philibert_0071 and not STAR_CHART_TAKEN_D3 and not PARCHMENT_TAKEN_D3 and not W71_D3_Fini then
				DrawText("Ma2292","Ma2292.ogg",0) -- Je n'en ai pas encore terminé avec les affaires de Chavigny.
--			else
--				ChangeWarp(objectName)
--			end
		else
			ChangeWarp(objectName)
		end
	end

--DAY3 
	if ETAT_DAY == "D3" then 
		if objectName == "hbc1" then

		elseif objectName == "hcc1" then

		elseif objectName == "hdc1" then
			if not DrawOpen_0071_D3 then
				SetMarker("hdc1",-1)
				PlaySound("Sounds/SFX/E_ArmoireOuverture.ogg",1)
				AnimationSetToStart("hec1",true)
				AnimationSetToStart("hkc1",true)
				RemoveObject("hdc1")
				StartAnimation("hdc1",1)
			end

		elseif objectName == "hec1" then

		elseif objectName == "hfc1" then
			if not AmpOpen_0071_D3  then
				SetMarker("hfc1",-1,0)
				DrawText("Ma2284","Ma2284.ogg",0) -- L'Aonomia Magna de Paracelse… A.M.P. ! Et si le message de Philibert faisait référence à cet ouvrage !
			end
			if AmpOpen_0071_D3 and not O_papier_philibert_0071 then
				SetMarker("hfc1",-1,0)
				AddToBag("C_papier_philibert1")
				O_papier_philibert_0071 = true
				RemoveFromBag("C_papier_philibert1")
				StartAnimationPart("hfc1",3,4,-1,true)
				if LookAtTomb then
					SetDiaryPage(14, "Page14_03")
				elseif Tomb and not LookAtTomb then
					SetDiaryPage(14, "Page14_02")
				else
					SetDiaryPage(14, "Page14_01")
				end

				if ThemeW71 and QuatrainFoundW71 then
					
					if DRESS_CESAR then
						DrawText("Ch2447","Ch2447.ogg",3)
					elseif DRESS_MADELEINE then
						DrawText("Ch2455","Ch2455.ogg",3)
					end
					
				end
			end

		elseif objectName == "hkc1" then

		end

		if objectName == "3D\\INVESTIGATE_DESK" then
			if not DrawerThemeW71 and not LeatherCutW71 then
				ShowToolBox("W71_00")
			elseif not DrawerThemeW71 and LeatherCutW71 and not QuatrainFoundW71 then
				ShowToolBox("W71_01")
			elseif not DrawerThemeW71 and QuatrainFoundW71 then
				ShowToolBox("W71_02")
			elseif DrawerThemeW71 and not ThemeW71 and not LeatherCutW71 then
				ShowToolBox("W71_03")
			elseif DrawerThemeW71 and not ThemeW71 and LeatherCutW71 and not QuatrainFoundW71  then
				ShowToolBox("W71_04")
			elseif DrawerThemeW71 and not ThemeW71 and QuatrainFoundW71  then
				ShowToolBox("W71_05")
			elseif ThemeW71 and not LeatherCutW71  then
				ShowToolBox("W71_06")
			elseif ThemeW71 and LeatherCutW71 and not QuatrainFoundW71  then
				ShowToolBox("W71_07")
			elseif ThemeW71 and QuatrainFoundW71 then
				DrawText("Ma2727","Ma2727.ogg",0) -- Il n'y a plus rien à trouver dans le secrétaire, mais Jean-Aimé a peut-être laissé traîner d'autres choses intéressantes.
				W71_D3_Fini = true
				JEAN_AT_LIBRARY_0055_D3 = false
					if O_papier_philibert_0071 then
						if DRESS_CESAR then
							DrawText("Ch2447","Ch2447.ogg",3) -- César, qu'est-ce que tu fais là ?!
							W71_D3_Cesar = true
						elseif DRESS_MADELEINE then
							DrawText("Ch2455","Ch2455.ogg",3) -- Madeleine !
							W71_D3_Madeleine = true
						end
					end
			end
		end
		
	end

--DAY4 
	if ETAT_DAY == "D4" then 
		if objectName == "hbc1" then
			if DRESS_CESAR then
				TALK_JEAN_D4 = true
				StartAnimationPart("hbc1",30,60,-1)
				DrawText("Ch2647","Ch2647.ogg",3) -- Tiens ! Qu'est-ce qui me vaut l'honneur de ta visite ?
				DrawText("Ce2661","Ce2661.ogg",1) -- Une question, Jean-Aimé, je dois absolument savoir qui a eu connaissance de ta version du quatrain.
				DrawText("Ce2662","Ce2662.ogg",1) -- Quelqu'un s'en inspire pour tuer. Or, d'après la reine, peu de gens le connaissait.
				DrawText("Ch2663","Ch2663.ogg",3) -- Tu veux dire qu'elle me soupçonne ?  Et je suppose que c'est à toi et à tes brillantes déductions que je le dois !
				DrawText("Ce2664","Ce2664.ogg",1) -- Si tu n'es pas coupable, aide-moi à trouver le meurtrier !<
				DrawText("Ch2665","Ch2665.ogg",3) -- Mais comment ?  Quelqu'un a pu fouiller mes affaires et y trouver le quatrain. 
					if W71_D3_Cesar then
						DrawText("Ch2666","Ch2666.ogg",3) -- Il n'y a pas que toi qui soit capable d'effraction !
					else
						DrawText("Ch2667","Ch2667.ogg",3) -- Il n'y a pas que ta soeur qui soit capable d'effraction !
					end
				
			elseif DRESS_MADELEINE then
				TALK_JEAN_D4 = true
				StartAnimationPart("hbc1",30,60,-1)
				DrawText("Ch2647","Ch2647.ogg",3) -- Tiens ! Qu'est-ce qui me vaut l'honneur de ta visite ?
				DrawText("Ma2648","Ma2648.ogg",0) -- Une question, Jean-Aimé, je dois absolument savoir qui a eu connaissance de ta version du quatrain.
				DrawText("Ma2649","Ma2649.ogg",0) -- Quelqu'un s'en inspire pour tuer. Or, d'après la reine, peu de gens le connaissait.
				DrawText("Ch2650","Ch2650.ogg",3) -- Tu veux dire qu'elle me soupçonne ?  Et je suppose que c'est à toi et à tes brillantes déductions que je le dois !
				DrawText("Ma2651","Ma2651.ogg",0) -- Si tu n'es pas coupable, aide-moi à trouver le meurtrier !
				DrawText("Ch2652","Ch2652.ogg",3) -- Mais comment ? Quelqu'un a pu fouiller mes affaires et y trouver le quatrain. 
					if W71_D3_Madeleine then
						DrawText("Ch2653","Ch2653.ogg",3) -- Il n'y a pas que toi qui soit capable d'effraction !
					else
						DrawText("Ch2657","Ch2657.ogg",3) -- Il n'y a pas que ton frère qui soit capable d'effraction !
					end
			end

		end
	end
end

function OnShowedDocumentButtonValidated(page, buttonName)	
PrintDebugMessage("OnShowedDocumentButtonValidated("..page..", "..buttonName..")\n")

	if page == "ChoixCostume_zoomed_0"  then
		if buttonName == "button0" then
			DRESS_MONK = false		
			DRESS_CESAR = false
			DRESS_MADELEINE = true
			HideDocument()
		elseif buttonName == "button1" then
			DRESS_MONK = false		
			DRESS_CESAR = true
			DRESS_MADELEINE = false
			HideDocument()
		end
		if not BeenInW71D3 then
			BeenInW71D3 = true
			DrawText("Ma2291","Ma2291.ogg",0)
		end		
	else
		ShowDocument("ChoixCostume")
	end	
end
