require "scripts/style"

local gCurscreen = 1;

function ShowArrowButtons( show )
	SetWindowVisible("leftbutton",show)
	SetWindowVisible("rightbutton",show)
end

function UpdateArrows()
	if(gCurscreen > 1) then
		SetWindowVisible("leftbutton",true)
	else
		SetWindowVisible("leftbutton",false)
	end
	if(gCurscreen < 9) then
		SetWindowVisible("rightbutton",true)
	else
		SetWindowVisible("rightbutton",false)
	end
end

function SetCurrentCFPage(pagenum)
	icon = pagenum - 1
	SetPage(icon)
end

CasefileText = {
	parent=DefaultStyle,
	font = {
		standardFont,
		34,
		BlackColor
	},
	x=550,
	y=168,
	w=318,
	h=420,
	align=kHAlignLeft+kVAlignTop,
};

MakeDialog
{
name="casefile",
CaseFileWindow{

	x=0,y=0,w=1024,h=768,
	rows=gRows,			
	columns=gColumns,
	
	SetStyle(CasefileText),
	Text{
		name = "case1",
		label = "casefile|1",
		},

	SetStyle(ButtonStyle),
	Button{
		name="leftbutton",
		graphics={"ui/journal_menu/arrow_in.png","ui/journal_menu/arrow_out.png","ui/journal_menu/arrow_out.png"},
		x=kCenter-350,
		y=kCenter+220,
		command = function()
			if(gCurscreen > 1) then
				if(IsAccessible(gCurscreen - 1)) then
					gCurscreen = gCurscreen - 1
					UpdateArrows()
					SetCurrentCFPage(gCurscreen)
					SetLabel("case1",GetString("casefile|"..gCurscreen));
					SetWindowVisible("cleft",false)
					if(GetString("casefile|"..gCurscreen.."b") ~= "#####") then
						SetWindowVisible("cright",true)
					else
						SetWindowVisible("cright",false)
					end
				end
			end	
		end,
		},
	Button{
		name="rightbutton",
		graphics={"ui/journal_menu/arrow_down.png","ui/journal_menu/arrow_up.png","ui/journal_menu/arrow_up.png"},
		x=kCenter+350,
		y=kCenter+220,
		command = function()
			if(gCurscreen < 9) then
				if(IsAccessible(gCurscreen + 1)) then
					gCurscreen = gCurscreen + 1
					UpdateArrows()
					SetCurrentCFPage(gCurscreen)
					SetLabel("case1",GetString("casefile|"..gCurscreen))
					SetWindowVisible("cleft",false)
					if(GetString("casefile|"..gCurscreen.."b") ~= "#####") then
						SetWindowVisible("cright",true)
					else
						SetWindowVisible("cright",false)
					end
				end
			end
		end,
		},
	Button{
		name="cleft",
		graphics={"ui/journal_menu/arrow_in.png","ui/journal_menu/arrow_out.png","ui/journal_menu/arrow_out.png"},
		x=kCenter+100,
		y=kCenter+170,
		command = function()
			if(GetString("casefile|"..gCurscreen) ~= "#####") then
				SetLabel("case1",GetString("casefile|"..gCurscreen));
				SetWindowVisible("cleft",false)
				SetWindowVisible("cright",true)
			end	
		end,
		},
	Button{
		name="cright",
		graphics={"ui/journal_menu/arrow_down.png","ui/journal_menu/arrow_up.png","ui/journal_menu/arrow_up.png"},
		x=kCenter+300,
		y=kCenter+170,
		command = function()
			if(GetString("casefile|"..gCurscreen.."b") ~= "#####") then
				SetLabel("case1",GetString("casefile|"..gCurscreen.."b"));
				SetWindowVisible("cright",false)
				SetWindowVisible("cleft",true)
			end	
		end,
		},

	},--CaseFileWindow
}

SetCurrentCFPage(1);
SetLabel("case1",GetString("casefile|1"));
SetWindowVisible("cright",true);
SetWindowVisible("cleft",false);
ShowArrowButtons(false);
