function OnWarpEnter()
	SetMarker("Pi Ramses\\Maison de Paser\\Warp_0006.wp",0,0)
	SetMarker("Pi Ramses\\Maison de Paser\\Warp_0007.wp",0,0)
	SetMarker("Pi Ramses\\Maison de Paser\\Warp_0005.wp",0,0)
	SetMarker("PAP1",4,0)
	StartAnimationPart("PAP1",300,329,-1,true)
	
	StartAnimation("L3P1",-1)
	StartAnimationPart("L4P1",0,10,-1,true) 
	StartAnimation("L7P1",-1)
	
	if not Tool_DoorRoom_Opened_piM_008 then
		AnimationSetToStart("P3P1")
	else
		AnimationSetToEnd("P3P1")
	end

	if SMOKE_ACTIVATED then
		StartAnimationPart("L4P1",20,40,-1,true)
		 if GUARD_CAPTURED_MAYA and not MAYA_BEATED then
			StartAnimation("TOp3",-1)
			StartAnimation("G2P3",-1)
		end
	else
		if GUARD_CAPTURED_MAYA then
			StartAnimationPart("L4P1",0,10,-1,true)
			StartAnimation("TOp2",-1)
			StartAnimationPart("G2P1", 151, 180, -1, true)
		else
			StartAnimationPart("L4P1",0,10,-1,true)
		end
	end
	
	TALK_TO_PASER_01 = true
	if Khaem_on_Countryyard and not MAYA_BEATED then
		if SMOKE_ACTIVATED then
			StartAnimationPart("TOP3",0,30,-1,true)
			StartAnimationPart("G2P3",0,30,-1,true)
		end
	end

	if MAYA_BEATED then
		AnimationSetToStart("FIP1",true)
		SetMarker("FIP1",4,0)
	end

	if not PASER_UNCONSCIOUS then
		Paser_Sit_pt_0008 = false
		StartAnimationPart("PAP1",0,90,-1,true)
	else
		if not PASER_HARMED then
			StartAnimationPart("PAP1",270,290,-1,true)
		else -- used figurine
			if not MAYA_BEATED then
				StartAnimationPart("PAP1",301,320,-1,true)
			else
				StartAnimationPart("PAP1",270,290,-1,true)
			end
		end
	end
end

function OnMovieFinished(movieid)
	if movieid == "Videos/GC_C15_Montage.ogv" then
		StartAnimationPart("G2P1",90, 119, -1, true)
		StartAnimationPart("TOp1",0,10,-1,true)
		SetMarker("Pi Ramses\\Maison de Paser\\Warp_0006.wp",-1,0)
		SetMarker("Pi Ramses\\Maison de Paser\\Warp_0007.wp",-1,0)
		SetMarker("Pi Ramses\\Maison de Paser\\Warp_0005.wp",-1,0)
		LookAt(228,013)
		DrawText("SOLD1263","SOLD1263.ogg")
		DrawText("MAIA1264","MAIA1264.ogg")
		DrawText("SOLD1265","SOLD1265.ogg")
		DrawText("MAIA1266","MAIA1266.ogg")
		DrawText("SOLD1267","SOLD1267.ogg")
		DrawText("MAIA1268","MAIA1268.ogg")
		DrawText("MAIA1269","MAIA1269.ogg")
		DrawText("SOLD1270","SOLD1270.ogg")
		DrawText("MAIA1271","MAIA1271.ogg")
		DrawText("SOLD1272","SOLD1272.ogg")
		DrawText("MAIA1273","MAIA1273.ogg")
		DrawText("MAIA1275","MAIA1275.ogg")
		DrawText("TOUY1276","TOUY1276.ogg")
		DrawText("MAIA1277","MAIA1277.ogg")
	end
	
	if (movieid == "Videos/GC_C22_Montage.ogv") then
		-- VIDEO de FIN
		--PlayMovie("Videos/fin_Part3.ogv", "fin_Part3.ogg")
		--
		ShowDocument("FinPartie")
    end
end

function OnDocumentClosed(documentId)

	if documentId == "FinPartie" then
		--RETOUR HOME APRES FIN
		FinishGame()
		--
	end
end 

function OnWarpLeave()
end

function OnAnimationFinished(objectName)
	if objectName=="PAP1" then
		SetMarker("PAP1",-1,0)
		if MAYA_BEATED and not PASER_UNCONSCIOUS then
			PASER_UNCONSCIOUS = true -- if the game is saved, we want the player to be back in a previous state
			SetMarker("PAP1", -1, 0)
			StartAnimationPart("PAP1",190,200,-1,true)
			DrawText("PASE1482","PASE1482.ogg")
			DrawText("PASE1483","PASE1483.ogg")
			DrawText("MAIA1484","MAIA1484.ogg")
			DrawText("PASE1485","PASE1485.ogg")
			DrawText("MAIA1486","MAIA1486.ogg")
		end
	end
	
	if objectName=="FIP1" then
		DrawText("MAIA1496","MAIA1496.ogg")
		DrawText("MAIA1497","MAIA1497.ogg")
		AnimationSetToEnd("FIP1", false)
	end
end

function OnDialogFinished(dialogName)
	if dialogName=="MAIA1235" then
		PlayMovie("Videos/GC_C15_Montage.ogv", "Videos/cine15.ogg")
	end
	if dialogName=="MAIA1275" then
		StartAnimationPart("TOp1",55,70,-1,true)
	end	
	if dialogName=="TOUY1276" then
		StartAnimationPart("TOp1",0,50,-1,true)
	end
	if dialogName=="MAIA1277" then
		SetMarker("Pi Ramses\\Maison de Paser\\Warp_0006.wp",0,0)
		SetMarker("Pi Ramses\\Maison de Paser\\Warp_0007.wp",0,0)
		SetMarker("Pi Ramses\\Maison de Paser\\Warp_0005.wp",0,0)
	end

	if dialogName=="PASE1483" or dialogName=="PASE1485" then -- paser awaken
		StartAnimationPart("PAP1",160,170,-1,true)
	end
	if dialogName=="MAIA1484" then
		StartAnimationPart("PAP1",190,200,-1,true)
	end

	if dialogName=="MAIA1497" then -- thoughts about the link between the curse and Seth's knife
		PASER_UNCONSCIOUS = false
		SetMarker("PAP1",-1,0)
		StartAnimationPart("PAP1",360,419,1,true)
	end
	if dialogName=="MAIA1481" then -- break the curse using the knife
		StartAnimation("FIP1",1)
	end
	if dialogName=="MAIA1486" then -- final cutscene		
		PlayMovie("Videos/GC_C22_Montage.ogv", "Videos/cine22.ogg")
	end


	-- Animate the guard, stops talking
	if dialogName=="SOLD1287"
	or dialogName=="SOLD1263" 
	or dialogName=="SOLD1286" 
	or dialogName=="SOLD1285" 
	or dialogName=="SOLD1265" 
	or dialogName=="SOLD1267" 
	or dialogName=="SOLD1270" 
	or dialogName=="SOLD1272"
	then
		StartAnimationPart("G2P1", 151, 180, -1, true)
	end

	-- Animate the guard, starts talking
	if dialogName=="MAIA1264" 
	or dialogName=="MAIA1266" 
	or dialogName=="MAIA1269" 
	or dialogName=="MAIA1271"
	then
		StartAnimationPart("G2P1",90, 119, -1, true)
	end
end

function OnWarpObjectHit(objectName)
	if objectName=="3D\\Pi Ramses\\Maison de Paser\\Warp_0007.wp" then
		ChangeWarp(objectName)
    end

	if objectName=="3D\\Pi Ramses\\Maison de Paser\\Warp_0006.wp" then
		if not SMOKE_ACTIVATED then
			StartAnimationPart("G2P1",90, 119, -1, true)
			DrawText("SOLD1287","SOLD1287.ogg")
		else
			ChangeWarp(objectName)
		end
    end

    if objectName=="3D\\Pi Ramses\\Maison de Paser\\Warp_0005.wp" then
		if not SMOKE_ACTIVATED then
			StartAnimationPart("G2P1",90, 119, -1, true)
			DrawText("SOLD1286","SOLD1286.ogg")
		else
			ChangeWarp(objectName)
		end
    end
	
	
	---------
	-- Objects
	---------
	if objectName=="FIP1" then
		if Selected("J_Couteau_etrange") then
			Paser_Sit_pt_0008 = false
			SetMarker("FIP1", -1, 0)
			DrawText("MAIA1481","MAIA1481.ogg")
		elseif Selected("J_Oeil") then
			DrawText("MAIA1500","MAIA1500.ogg")
		else
			DrawText("MAIA1498","MAIA1498.ogg")
		end
	end

	if objectName == "PAP1" then
		if SMOKE_ACTIVATED then
			DrawText("MAIA1298","MAIA1298.ogg")
		elseif GUARD_CAPTURED_MAYA then
			StartAnimationPart("G2P1",90, 119, -1, true)
			DrawText("SOLD1285","SOLD1285.ogg")
		elseif PASER_UNCONSCIOUS and not Selected("J_figurine_cuite") then
			DrawText("MAIA0282","MAIA0282.ogg")
		elseif PASER_UNCONSCIOUS  and Selected("J_figurine_cuite") then
			O_J_figurine_cuite = true
			GUARD_CAPTURED_MAYA = true
			MAYA_BETRAYED = true
			PASER_HARMED = true
			RemoveFromBag()
			DjerStandIn_piU_012 = false
			Khaem_on_Countryyard = true
			DrawText("MAIA1235","MAIA1235.ogg")
		end
	end
end
