
.namespace Book

-- Ce script le livre
function OnEnable()
	LeftInterface_book.SetFrame(2)
	
end

function OnUpdate(dt)

	if Book_parent.GetFrame() == 8 then
	 Book_suite.Enabled = false
	end
	
	if Book_parent.GetFrame() == 0 then
	 Book_avant.Enabled = false
	end

	if Book_parent.GetFrame() ~= 8 then
	 Book_suite.Enabled = true
	end
	if Book_parent.GetFrame() ~= 0 then
	 Book_avant.Enabled = true
	end

end

function OnDisable()
LeftInterface_book.SetFrame(0)
end

function OnWbpMouseLUp()
	
	-- Bouton livre
	if self.Name == "LeftInterface_book_hotspot" and SampleLevel.IsEqual("Page_0",true) then
		SetVariables("CurrentGamePhase","Document")
		
		-- Active le livre
		Book.Enabled = true
		Book_parent.Enabled = true
		local lang = DebugOptions.curlanguage 

		Book_parent.Image="media/common/graph/interface/book/Page_0_"..lang..".png|media/common/graph/interface/book/Page_1_"..lang..".png|media/common/graph/interface/book/Page_2_"..lang..".png|media/common/graph/interface/book/Page_3_"..lang..".png|media/common/graph/interface/book/Page_4_"..lang..".png|media/common/graph/interface/book/Page_5_"..lang..".png|media/common/graph/interface/book/Page_6_"..lang..".png|media/common/graph/interface/book/Page_7_"..lang..".png|media/common/graph/interface/book/Page_8_"..lang..".png"
	end
	if self.Name == "Book_Quit_area" then
		Book.Enabled = false
		SetVariables("CurrentGamePhase","SearchSite")
		PlaySoundEffect("int_bookclose")
	end
	
	if self.Name == "Book_Previous_page" then
		if Book_parent.GetFrame() == 0 then
		Book_avant.Enabled = false
			return
		end
		Book_parent.SetFrame(Book_parent.GetFrame() - 1)
		PlaySoundEffect("int_bookleft")
		if SampleLevel.IsEqual("Page_"..Book_parent.GetFrame()+1,true) then
			Book_suite.Color.a = 255
		end		
	end

	
	if self.Name == "Book_Next_page" then
	 if Book_parent.GetFrame() == 8 then
	 Book_suite.Enabled = false
	return
	end 
		if SampleLevel.IsEqual("Page_"..Book_parent.GetFrame()+1,true) then
			Book_parent.SetFrame(Book_parent.GetFrame() + 1)
			PlaySoundEffect("int_bookright")
			if SampleLevel.IsEqual("Page_"..Book_parent.GetFrame()+1,false) then
				Book_suite.Color.a = 90
			end
		end
	end
end
	