leavewindow_cb = function (self)
	blank_detail()
end

mousemove_cb = 	function (self, l, c)
-- this is passed the box (self)  for char mode.
-- ignore c.
-- if this is a dungeon self.box.ach == nil

	if (self == nil) then
		print ("box_mousemove_cb2: self == nil, WTF?")
		return
	end

	if (l == 0) then
		blank_detail()
		return
	end

-- we have previously added .dat to the box, this is the data file that looks up to Ach

	if self.dat == nil then
		detail_name.title = "box.dat is nil"
		return
	end


	if (self.dat.id == nil) then
		print ("box_mousemove_cb2: self.dat.id == nil")
		return
	end

	local ach = self.dat.id[l]

	if (ach == nil) then
		blank_detail()
		detail_name.title = "box_mousemove_cb2: No Achievement Number for line: " .. tostring(l)		-- Normal on Group 2 and Pub panel with empty spaces
		return
	end

	if (Ach_Detail[ach] == nil) then
		detail_name.title = "No Achievement in Ach_Detail for: " .. ach
		return
	end


	detail_desc.title = Ach_Detail[ach].description

	if (self.ach == nil) then
		-- Dungeon, no completion info
		detail_name.title = "(ID: " .. ach .. ")  "  ..  Ach_Detail[ach].name
		return
	end

	--character mode, but char hasn't completed it.
	if (self.ach[ach] == nil) then
		detail_name.title = "(ID: " .. ach .. ")  "  ..  Ach_Detail[ach].name
		return
	end


	--by default, has completed it, add date.
	detail_name.title = "(ID: " .. ach .. ")  "  .. L.Completed .. os.date(dateformat,self.ach[ach].time) .. "   " .. Ach_Detail[ach].name

end



make_a_tab = function(playerID, dung_t,Account_t, mebox_s,dat_t)	-- Called per char on me[" "]



	me[mebox_s] = {}
	me[mebox_s].box = iup.matrixex {READONLY="YES",numcol=1, numlin=#dat_t.id, widthdef=120}
	-- We put a lot of stuff under box as that is what gets passed to the mouse callbacks
	me[mebox_s].box.dat = dat_t
	me[mebox_s].box.mousemove_cb = mousemove_cb
	me[mebox_s].box.leavewindow_cb = leavewindow_cb



	me[mebox_s].box.name= mebox_s
	me[mebox_s].box.ach = thischar.ach		-- not on dung boxes

	iup.SetAttribute(me[mebox_s].box,  "BGCOLOR" , BG_Colour_Not_Complete)

	--set lines Heading
	me[mebox_s].box:setcell(0,0, L.Achievements )
	iup.SetAttribute(me[mebox_s].box,  "WIDTH0", 180)	-- Width of Achievement

	--Load Lines
	for line, Ach in ipairs (dat_t.id) do  -- Load text
	if (Ach_Detail[Ach] == nil) then
	        print(mebox_s)
			print("Achievement " .. Ach .. " has no record in Ach_Detail")
		else
			me[mebox_s].box:setcell(line,0,Ach_Detail[Ach].name)
		end
	end

	me[mebox_s].tab = iup.vbox {	["tabtitle"] =L.box[mebox_s],
									--	iup.label{title=L.PubLab,expand="HORIZONTAL"},
										me[mebox_s].box,
										iup.fill{}
									}

	iup.Append(me.data_tabs,me[mebox_s].tab)


	--Make Dungeon box, but only one
	-- a table for each dungeon to which we add characters

	if dung_t[mebox_s] == nil then
		--create and initialise to none for all player_IDs
		dung_t[mebox_s] = {}

		dung_t[mebox_s].keys = {}

	-- Set to none for all chars.


		for line, _ in ipairs(dat_t.id) do
			dung_t[mebox_s].keys[line] = {}
			for _,playerID in ipairs(Account_t.AllplayerIDs) do
			--print("Key: " .. key .. ", playerID: " .. playerID)
			dung_t[mebox_s].keys[line][playerID] = false
			end
		end

		---
		dung_t[mebox_s].box = iup.matrixex {READONLY="YES", numcol=#Account_t.AllplayerIDs,  numlin=#dat_t.id, widthdef=120}
		dung_t[mebox_s].box.dat = dat_t
		dung_t[mebox_s].box.mousemove_cb = mousemove_cb
		dung_t[mebox_s].box.leavewindow_cb = leavewindow_cb

		dung_t[mebox_s].box.name= mebox_s		-- when we are in the box with the mouse CB its possible to see who we are.

		iup.SetAttribute(dung_t[mebox_s].box,  "BGCOLOR" , BG_Colour_Not_Complete)

		--set lines Heading
		dung_t[mebox_s].box:setcell(0,0, L.Achievements )
		iup.SetAttribute(dung_t[mebox_s].box,  "WIDTH0", 180)

		--Load Lines (Dungeon Ach names)
		for line,Ach in ipairs(dat_t.id) do
			-- print("Dungeon Mode  Line: "..  line.. "  " .. "Ach: ".. Ach)
			dung_t[mebox_s].box:setcell(line, 0, Ach_Detail[Ach].name)
		end

		--Create Columns for Chars
		for col ,playerID in ipairs(Account_t.AllplayerIDs) do
			dung_t[mebox_s].box:setcell(0, col, playerNames[playerID])
		end

		--record it
		table.insert(Account_t.alldungeons,dung_t[mebox_s])

		if L.box[mebox_s] == nil then
			print("L.box[mebox_s] is nill")
		end
		-- how to display it
		dung_t[mebox_s].tab = iup.vbox {
				["tabtitle"] =L.box[mebox_s],
				dung_t[mebox_s].box,
				iup.fill{},
			}
		-- and record that
		iup.Append(Account_t.dung_tabs, dung_t[mebox_s].tab)
	end	-- unique dungeon creation
--
-- Ok that's the setup done, lets load the data for that "me"
-- Goes in to the me and also the dungeon by character

	for line, Ach in pairs (dat_t.id) do
		local bgcolour = "BGCOLOR" .. tostring(line) .. ":*"
		if thischar.ach[Ach] ~= nil then		-- yes I have it..
			iup.SetAttribute(me[mebox_s].box, bgcolour, BG_Colour_Complete)
			me[mebox_s].box:setcell(line,1, L.YesLabel)

			-- Add char to dungeon
			if dung_t[mebox_s].keys[line] == nil then	-- Add if needed
				dung_t[mebox_s].keys[line]  = {}
				print("Shouldn't be needed")
			end
			dung_t[mebox_s].keys[line][playerID] = true
		else
			iup.SetAttribute(me[mebox_s].box, bgcolour, BG_Colour_Not_Complete)
			me[mebox_s].box:setcell(line,1, L.NoLabel)
		end
	end

end