local indexeon       = {"phanerozoic","proterozoic","archean","hadean"};
local indexera       = {"cenozoic","mesozoic","paleozoic","neoproterozoic","mesoproterozoic","paleoproterozoic","neoarchean","mesoarchean","paleoarchean","eoarchean"};
local indexperiod    = {"quaternary","neogene","paleogene","cretaceous","jurassic","triassic","permian","carboniferous","devonian","silurian","ordovician","cambrian","ediacaran","cryogenian","tonian","stenian","ectasian","calymmian","statherian","orosirian","rhyacian","siderian","neoarcheannull","mesoarcheannull","paleoarcheannull","eoarcheannull"};
local indexsubperiod = {"pennsylvanian","mississippian"};
local indexepoch     = {"holocene","pleistocene","pliocene","miocene","oligocene","eocene","paleocene","uppercretaceous","lowercretaceous","upperjurassic","middlejurassic","lowerjurassic","uppertriassic","middletriassic","lowertriassic","lopingian","guadalupian","cisuralian","upperpennsylvanian","middlepennsylvanian","lowerpennsylvanian","uppermississippian","middlemississippian","lowermississippian","upperdevonian","middledevonian","lowerdevonian","pridoli","ludlow","wenlock","llandovery","upperordovician","middleordovician","lowerordovician","furongian","miaolingian","cambrianseries2","terreneuvian"};
local indexage       = {"meghalayan","northgrippian","greenlandian","tarantian","chibanian","calabrian","gelasian","piacenzian","zanclean","messinian","tortonian","serravallian","langhian","burdigalian","aquitanian","chattian","rupelian","priabonian","bartonian","lutetian","ypresian","thanetian","selandian","danian","maastrichtian","campanian","santonian","coniacian","turonian","cenomanian","albian","aptian","barremian","hauterivian","valanginian","berriasian","tithonian","kimmeridgian","oxfordian","callovian","bathonian","bajocian","aalenian","toarcian","pliensbachian","sinemurian","hettangian","rhaetian","norian","carnian","ladinian","anisian","olenekian","induan","changhsingian","wuchiapingian","capitanian","wordian","roadian","kungurian","artinskian","sakmarian","asselian","gzhelian","kasimovian","moscovian","bashkirian","serpukhovian","visean","tournaisian","famennian","frasnian","givetian","eifelian","emsian","pragian","lochkovian","pridolinull","ludfordian","gorstian","homerian","sheinwoodian","telychian","aeronian","rhuddanian","hirnantian","katian","sandbian","darriwilian","dapingian","floian","tremadocian","cambrianstage10","jiangshanian","paibian","guzhangian","drumian","wuliuan","cambrianstage4","cambrianstage3","cambrianstage2","fortunian"};

local chart =            { Titel="Erdzeitalter",          Farbe="FFFFFF", Beginn="4600",   Zeilen="110", level="chart", parent="",      children={"phanerozoic","proterozoic","archean","hadean"} }
local supereons = {
	{key="precambrian",         Titel="Präkambrium",              Farbe="F701B3", Beginn="2500",   Zeilen="15",  level="supereon", parent="chart", children={"proterozoic","archean","hadean"} },
};
local eons    = {
	{key="phanerozoic",         Titel="Phanerozoikum",            Farbe="A1D4E2", Beginn="541",    Zeilen="95",  level="eon",   parent="chart", children={"cenozoic","mesozoic","paleozoic"} },
	{key="proterozoic",         Titel="Proterozoikum",            Farbe="EA5B70", Beginn="2500",   Zeilen="10",  level="eon",   parent="chart", children={"neoproterozoic","mesoproterozoic","paleoproterozoic"} },
	{key="archean",             Titel="Archaikum",                Farbe="E72582", Beginn="4000",   Zeilen="4",   level="eon",   parent="chart", children={"neoarchean","mesoarchean","paleoarchean","eoarchean"} },
	{key="hadean",              Titel="Hadaikum",                 Farbe="B12A7E", Beginn="4600",   Zeilen="1",   level="eon",   parent="chart", children={} }
};

local eras    = {
	{key="cenozoic",            Titel="Känozoikum",               Farbe="F6EB3B", Beginn="66.0",   Zeilen="24",  level="era",    parent="phanerozoic",  children={"quaternary","neogene","paleogene"} },
	{key="mesozoic",            Titel="Mesozoikum",               Farbe="6CC0DB", Beginn="251.9",  Zeilen="23",  level="era",    parent="phanerozoic",  children={"cretaceous","jurassic","triassic"} },
	{key="paleozoic",           Titel="Paläozoikum",              Farbe="A3BC99", Beginn="541.0",  Zeilen="48",  level="era",    parent="phanerozoic",  children={"permian","carboniferous","devonian","silurian","ordovician","cambrian"} },

	{key="neoproterozoic",      Titel="Neoproterozoikum",         Farbe="FFB964", Beginn="1000",   Zeilen="3",   level="era",    parent="proterozoic",  children={"ediacaran","cryogenian","tonian"} },
	{key="mesoproterozoic",     Titel="Mesoproterozoikum",        Farbe="FFBB7E", Beginn="1600",   Zeilen="3",   level="era",    parent="proterozoic",  children={"stenian","ectasian","calymmian"} },
	{key="paleoproterozoic",    Titel="Paleoproterozoikum",       Farbe="FF6485", Beginn="2500",   Zeilen="4",   level="era",    parent="proterozoic",  children={"statherian","orosirian","rhyacian","siderian"} },

	{key="neoarchean",          Titel="Neoarchaikum",             Farbe="FEAFCB", Beginn="2800",   Zeilen="1",   level="era",    parent="archean",  children={"neoarcheannull"} },
	{key="mesoarchean",         Titel="Mesoarchaikum",            Farbe="FD86B8", Beginn="3200",   Zeilen="1",   level="era",    parent="archean",  children={"mesoarcheannull"} },
	{key="paleoarchean",        Titel="Paleoarchaikum",           Farbe="FC67B1", Beginn="3600",   Zeilen="1",   level="era",    parent="archean",  children={"paleoarcheannull"} },
	{key="eoarchean",           Titel="Eoarchaikum",              Farbe="E42F99", Beginn="4000",   Zeilen="1",   level="era",    parent="archean",  children={"eoarcheannull"} }
};

local periods = {
	{key="quaternary",          Titel="Quartär",                  Farbe="FFF49E", Beginn="2.588",  Zeilen="7",   level="period", parent="cenozoic",  children={"holocene","pleistocene"} },
	{key="tertiary",            Titel="Tertiär",                  Farbe="8CCD60", Beginn="66.00",  Zeilen="17",  Level="period", parent="cenozoic",  children={"pliocene","miocene","oligocene","eocene","paleocene"} },
	{key="neogene",             Titel="Neogen",                   Farbe="FFDB4B", Beginn="23.03",  Zeilen="8",   level="period", parent="cenozoic",  children={"pliocene","miocene"} },
	{key="paleogene",           Titel="Paläogen",                 Farbe="FFA76F", Beginn="66.00",  Zeilen="9",   level="period", parent="cenozoic",  children={"oligocene","eocene","paleocene"} },

	{key="cretaceous",          Titel="Kreide",                   Farbe="82CC73", Beginn="145.0",  Zeilen="12",  level="period", parent="mesozoic",  children={"uppercretaceous","lowercretaceous"} },
	{key="jurassic",            Titel="Jura",                     Farbe="1AC4EC", Beginn="201.3",  Zeilen="11",  level="period", parent="mesozoic",  children={"upperjurassic","middlejurassic","lowerjurassic"} },
	{key="triassic",            Titel="Trias",                    Farbe="824FA8", Beginn="251.9",  Zeilen="7",   level="period", parent="mesozoic",  children={"uppertriassic","middletriassic","lowertriassic"} },

	{key="permian",             Titel="Perm",                     Farbe="F95F44", Beginn="298.9",  Zeilen="9",   level="period", parent="paleozoic",  children={"lopingian","guadalupian","cisuralian"} },
	{key="carboniferous",       Titel="Karbon",                   Farbe="5FB6B5", Beginn="358.9",  Zeilen="7",   level="period", parent="paleozoic",  children={"pennsylvanian","mississippian"} },
	{key="devonian",            Titel="Devon",                    Farbe="D59C58", Beginn="419.2",  Zeilen="7",   level="period", parent="paleozoic",  children={"upperdevonian","middledevonian","lowerdevonian"} },
	{key="silurian",            Titel="Silur",                    Farbe="AFE3CD", Beginn="443.8",  Zeilen="8",   level="period", parent="paleozoic",  children={"pridoli","ludlow","wenlock","llandovery"} },
	{key="ordovician",          Titel="Ordovizium",               Farbe="00AF90", Beginn="485.4",  Zeilen="7",   level="period", parent="paleozoic",  children={"upperordovician","middleordovician","lowerordovician"} },
	{key="cambrian",            Titel="Kambrium",                 Farbe="83AF77", Beginn="541.0",  Zeilen="10",  level="period", parent="paleozoic",  children={"furongian","miaolingian","cambrianseries2","terreneuvian"} },

	{key="ediacaran",           Titel="Ediacarium",               Farbe="FFD789", Beginn="635",    Zeilen="1",   level="period", parent="neoproterozoic", children={} },
	{key="cryogenian",          Titel="Cryogenium",               Farbe="FFCD7C", Beginn="720",    Zeilen="1",   level="period", parent="neoproterozoic", children={} },
	{key="tonian",              Titel="Tonium",                   Farbe="FFC370", Beginn="1000",   Zeilen="1",   level="period", parent="neoproterozoic", children={} },

	{key="stenian",             Titel="Stenium",                  Farbe="FFDBAE", Beginn="1200",   Zeilen="1",   level="period", parent="mesoproterozoic",  children={} },
	{key="ectasian",            Titel="Ectasium",                 Farbe="FFD0A1", Beginn="1400",   Zeilen="1",   level="period", parent="mesoproterozoic",  children={} },
	{key="calymmian",           Titel="Calymmium",                Farbe="FFC694", Beginn="1600",   Zeilen="1",   level="period", parent="mesoproterozoic",  children={} },

	{key="statherian",          Titel="Statherium",               Farbe="FE90B5", Beginn="1800",   Zeilen="1",   level="period", parent="paleoproterozoic", children={} },
	{key="orosirian",           Titel="Orosirium",                Farbe="FE85A8", Beginn="2050",   Zeilen="1",   level="period", parent="paleoproterozoic", children={} },
	{key="rhyacian",            Titel="Rhyacium",                 Farbe="FF7A9C", Beginn="2300",   Zeilen="1",   level="period", parent="paleoproterozoic", children={} },
	{key="siderian",            Titel="Siderium",                 Farbe="FF6F90", Beginn="2500",   Zeilen="1",   level="period", parent="paleoproterozoic", children={} },

	{key="neoarcheannull",      Titel="Neoarchaikum (Periode)",   Farbe="FAA7C8", Beginn="2800",   Zeilen="1",   level="period", parent="neoarchean",   children={} },
	{key="mesoarcheannull",     Titel="Mesoarchaikum (Periode)",  Farbe="F881B5", Beginn="3200",   Zeilen="1",   level="period", parent="mesoarchean" , children={} },
	{key="paleoarcheannull",    Titel="Paleoarchaikum (Periode)", Farbe="F668B2", Beginn="3600",   Zeilen="1",   level="period", parent="paleoarchean", children={} },
	{key="eoarcheannull",       Titel="Eoarchaikum (Periode)",    Farbe="E61D8C", Beginn="4000",   Zeilen="1",   level="period", parent="eoarchean",    children={} }

	
};

local subperiods = {
	{key="pennsylvanian",       Titel="Pennsylvanium",            Farbe="93CCCC", Beginn="323.2",  Zeilen="4",   level="subper", parent="carboniferous", children={"upperpennsylvanian","middlepennsylvanian","lowerpennsylvanian"} },
	{key="mississippian",       Titel="Mississippium",            Farbe="67A385", Beginn="358.9",  Zeilen="3",   level="subper", parent="carboniferous", children={"uppermississippian","middlemississippian","lowermississippian"} }
};

local epochs  = {
	{key="holocene",            Titel="Holozän",                  Farbe="FFF3E6", Beginn="0.0117", Zeilen="3",   level="epoch",  parent="quaternary", children={"meghalayan","northgrippian","greenlandian"} },
	{key="pleistocene",         Titel="Pleistozän",               Farbe="FFEFC0", Beginn="2.588" , Zeilen="4",   level="epoch",  parent="quaternary", children={"tarantian","chibanian","calabrian","gelasian"} },

	{key="pliocene",            Titel="Pliozän",                  Farbe="FFF6B2", Beginn="5.333",  Zeilen="2",   level="epoch",  parent="neogene", children={"piacenzian","zanclean"} },
	{key="miocene",             Titel="Miozän",                   Farbe="FFEB3D", Beginn="23.03",  Zeilen="6",   level="epoch",  parent="neogene", children={"messinian","tortonian","serravallian","langhian","burdigalian","aquitanian"} },

	{key="oligocene",           Titel="Oligozän",                 Farbe="FFC694", Beginn="33.90",  Zeilen="2",   level="epoch",  parent="paleogene", children={"chattian","rupelian"} },
	{key="eocene",              Titel="Eozän",                    Farbe="FFBC87", Beginn="56.00",  Zeilen="4",   level="epoch",  parent="paleogene", children={"priabonian","bartonian","lutetian","ypresian"} },
	{key="paleocene",           Titel="Paleozän",                 Farbe="FFB17B", Beginn="66.00",  Zeilen="3",   level="epoch",  parent="paleogene", children={"thanetian","selandian","danian"} },

	{key="uppercretaceous",     Titel="Oberkreide",               Farbe="ABD671", Beginn="100.5",  Zeilen="6",   level="epoch",  parent="cretaceous", children={"maastrichtian","campanian","santonian","coniacian","turonian","cenomanian"} },
	{key="lowercretaceous",     Titel="Unterkreide",              Farbe="8FD07B", Beginn="145.0",  Zeilen="6",   level="epoch",  parent="cretaceous", children={"albian","aptian","barremian","hauterivian","valanginian","berriasian"} },

	{key="upperjurassic",       Titel="Oberjura",                 Farbe="A9E8FB", Beginn="163.5",  Zeilen="3",   level="epoch",  parent="jurassic", children={"tithonian","kimmeridgian","oxfordian"} },
	{key="middlejurassic",      Titel="Mitteljura",               Farbe="71D9EF", Beginn="174.1",  Zeilen="4",   level="epoch",  parent="jurassic", children={"callovian","bathonian","bajocian","aalenian"} },
	{key="lowerjurassic",       Titel="Unterjura",                Farbe="28C1F0", Beginn="201.3",  Zeilen="4",   level="epoch",  parent="jurassic", children={"toarcian","pliensbachian","sinemurian","hettangian"} },

	{key="uppertriassic",       Titel="Obertrias",                Farbe="BBA3D1", Beginn="237.0",  Zeilen="3",   level="epoch",  parent="triassic", children={"rhaetian","norian","carnian"} },
	{key="middletriassic",      Titel="Mitteltrias",              Farbe="B084C2", Beginn="247.2",  Zeilen="2",   level="epoch",  parent="triassic", children={"ladinian","anisian"} },
	{key="lowertriassic",       Titel="Untertrias",               Farbe="995BAE", Beginn="251.9",  Zeilen="2",   level="epoch",  parent="triassic", children={"olenekian","induan"} },

	{key="lopingian",           Titel="Lopingium",                Farbe="FFB5A6", Beginn="259.1",  Zeilen="2",   level="epoch",  parent="permian", children={"changhsingian","wuchiapingian"} },
	{key="guadalupian",         Titel="Guadalupium",              Farbe="FF8B75", Beginn="273.0",  Zeilen="3",   level="epoch",  parent="permian", children={"capitanian","wordian","roadian"} },
	{key="cisuralian",          Titel="Cisuralium",               Farbe="F8745F", Beginn="298.9",  Zeilen="4",   level="epoch",  parent="permian", children={"kungurian","artinskian","sakmarian","asselian"} },

	{key="upperpennsylvanian",  Titel="Oberpennsylvanium",        Farbe="BFD0BA", Beginn="307.0",  Zeilen="2",   level="epoch",  parent="pennsylvanian", children={"gzhelian","kasimovian"} },
	{key="middlepennsylvanian", Titel="Mittelpennsylvanium",      Farbe="A6C7B7", Beginn="315.2",  Zeilen="1",   level="epoch",  parent="pennsylvanian", children={"moscovian"} },
	{key="lowerpennsylvanian",  Titel="Unterpennsylvanium",       Farbe="8CBEB4", Beginn="323.2",  Zeilen="1",   level="epoch",  parent="pennsylvanian", children={"bashkirian"} },

	{key="uppermississippian",  Titel="Obermississippium",        Farbe="B3BE6C", Beginn="330.9",  Zeilen="1",   level="epoch",  parent="mississippian", children={"serpukhovian"} },
	{key="middlemississippian", Titel="Mittelmississippium",      Farbe="99B46C", Beginn="346.7",  Zeilen="1",   level="epoch",  parent="mississippian", children={"visean"} },
	{key="lowermississippian",  Titel="Untermississippium",       Farbe="80AB6C", Beginn="358.9",  Zeilen="1",   level="epoch",  parent="mississippian", children={"tournaisian"} },

	{key="upperdevonian",       Titel="Oberdevon",                Farbe="F6E1B2", Beginn="382.7",  Zeilen="2",   level="epoch",  parent="devonian", children={"famennian","frasnian"} },
	{key="middledevonian",      Titel="Mitteldevon",              Farbe="F9CB86", Beginn="393.3",  Zeilen="2",   level="epoch",  parent="devonian", children={"givetian","eifelian"} },
	{key="lowerdevonian",       Titel="Unterdevon",               Farbe="EDB46E", Beginn="419.2",  Zeilen="3",   level="epoch",  parent="devonian", children={"emsian","pragian","lochkovian"} },

	{key="pridoli",             Titel="Pridolium",                Farbe="E4F5EB", Beginn="423.0",  Zeilen="1",   level="epoch",  parent="silurian", children={"pridolinull"} },
	{key="ludlow",              Titel="Ludlow",                   Farbe="BBE8E0", Beginn="427.4",  Zeilen="2",   level="epoch",  parent="silurian", children={"ludfordian","gorstian"} },
	{key="wenlock",             Titel="Wenlock",                  Farbe="AEE4D6", Beginn="433.4",  Zeilen="2",   level="epoch",  parent="silurian", children={"homerian","sheinwoodian"} },
	{key="llandovery",          Titel="Llandovery",               Farbe="0FB58F", Beginn="443.8",  Zeilen="3",   level="epoch",  parent="silurian", children={"telychian","aeronian","rhuddanian"} },

	{key="upperordovician",     Titel="Oberordovizium",           Farbe="7AD2B1", Beginn="458.4",  Zeilen="3",   level="epoch",  parent="ordovician", children={"hirnantian","katian","sandbian"} },
	{key="middleordovician",    Titel="Mittelordovizium",         Farbe="44C3A0", Beginn="470.0",  Zeilen="2",   level="epoch",  parent="ordovician", children={"darriwilian","dapingian"} },
	{key="lowerordovician",     Titel="Unterordovizium",          Farbe="0FB58F", Beginn="485.4",  Zeilen="2",   level="epoch",  parent="ordovician", children={"floian","tremadocian"} },

	{key="furongian",           Titel="Furongium",                Farbe="B2E0B1", Beginn="497.0",  Zeilen="3",   level="epoch",  parent="cambrian", children={"cambrianstage10","jiangshanian","paibian"} },
	{key="miaolingian",         Titel="Miaolingium",              Farbe="A6D3A4", Beginn="509.0",  Zeilen="3",   level="epoch",  parent="cambrian", children={"guzhangian","drumian","wuliuan"} },
	{key="cambrianseries2",     Titel="Kambrium 2. Serie",        Farbe="99C797", Beginn="521.0",  Zeilen="2",   level="epoch",  parent="cambrian", children={"cambrianstage4","cambrianstage3"} },
	{key="terreneuvian",        Titel="Terreneuvium",             Farbe="8EBB8B", Beginn="541.0",  Zeilen="2",   level="epoch",  parent="cambrian", children={"cambrianstage2","fortunian"} }
};

local ages= {
	   {key="meghalayan",       Titel="Meghalayum",               Farbe="FFF4F0", Beginn="0.0042", Zeilen="1",   level="age",    parent="holocene", children={} },
	   {key="northgrippian",    Titel="Northgrippium",            Farbe="FEF6F3", Beginn="0.0083", Zeilen="1",   level="age",    parent="holocene", children={} },
	   {key="greenlandian",     Titel="Grönlandium",              Farbe="FDF5F2", Beginn="0.0117", Zeilen="1",   level="age",    parent="holocene", children={} },

	   {key="tarantian",        Titel="Oberpleistozän",           Farbe="FFF2DD", Beginn="0.126",  Zeilen="1",   level="age",    parent="pleistocene", children={} },
	   {key="chibanian",        Titel="Chibanium",                Farbe="FFF1D3", Beginn="0.781",  Zeilen="1",   level="age",    parent="pleistocene", children={} },
	   {key="calabrian",        Titel="Calabrium",                Farbe="FFF0CA", Beginn="1.800",  Zeilen="1",   level="age",    parent="pleistocene", children={} },
	   {key="gelasian",         Titel="Gelasium",                 Farbe="FFEEB7", Beginn="2.588",  Zeilen="1",   level="age",    parent="pleistocene", children={} },


	   {key="piacenzian",       Titel="Piacenzium",               Farbe="FFF9CF", Beginn="3.600",  Zeilen="1",   level="age",    parent="pliocene", children={} },
	   {key="zanclean",         Titel="Zancleum",                 Farbe="FFF8C5", Beginn="5.333",  Zeilen="1",   level="age",    parent="pliocene", children={} },

	   {key="messinian",        Titel="Messinium",                Farbe="FFF395", Beginn="7.246",  Zeilen="1",   level="age",    parent="miocene", children={} },
	   {key="tortonian",        Titel="Tortonium",                Farbe="FFF28B", Beginn="11.63",  Zeilen="1",   level="age",    parent="miocene", children={} },
	   {key="serravallian",     Titel="Serravallium",             Farbe="FFF181", Beginn="13.82",  Zeilen="1",   level="age",    parent="miocene", children={} },
	   {key="langhian",         Titel="Langhium",                 Farbe="FFF078", Beginn="15.97",  Zeilen="1",   level="age",    parent="miocene", children={} },
	   {key="burdigalian",      Titel="Burdigalium",              Farbe="FFEF6E", Beginn="20.44",  Zeilen="1",   level="age",    parent="miocene", children={} },
	   {key="aquitanian",       Titel="Aquitanium",               Farbe="FFEE64", Beginn="23.03",  Zeilen="1",   level="age",    parent="miocene", children={} },

	   {key="chattian",         Titel="Chattium",                 Farbe="FFE5BC", Beginn="27.82",  Zeilen="1",   level="age",    parent="oligocene", children={} },
	   {key="rupelian",         Titel="Rupelium",                 Farbe="FFDBAE", Beginn="33.90",  Zeilen="1",   level="age",    parent="oligocene", children={} },

	   {key="priabonian",       Titel="Priabonium",               Farbe="FFD2B3", Beginn="37.80",  Zeilen="1",   level="age",    parent="eocene", children={} },
	   {key="bartonian",        Titel="Bartonium",                Farbe="FFC8A5", Beginn="41.20",  Zeilen="1",   level="age",    parent="eocene", children={} },
	   {key="lutetian",         Titel="Lutetium",                 Farbe="FFBD98", Beginn="47.80",  Zeilen="1",   level="age",    parent="eocene", children={} },
	   {key="ypresian",         Titel="Ypresium",                 Farbe="FFB38C", Beginn="56.00",  Zeilen="1",   level="age",    parent="eocene", children={} },

	   {key="thanetian",        Titel="Thanetium",                Farbe="FFC58B", Beginn="59.20",  Zeilen="1",   level="age",    parent="paleocene", children={} },
	   {key="selandian",        Titel="Seelandium",               Farbe="FFC482", Beginn="61.60",  Zeilen="1",   level="age",    parent="paleocene", children={} },
	   {key="danian",           Titel="Danium",                   Farbe="FFBB7E", Beginn="66.00",  Zeilen="1",   level="age",    parent="paleocene", children={} },


	   {key="maastrichtian",    Titel="Maastrichtium",            Farbe="F9F1A8", Beginn="72.10",  Zeilen="1",   level="age",    parent="uppercretaceous", children={} },
	   {key="campanian",        Titel="Campanium",                Farbe="EBEC9E", Beginn="83.60",  Zeilen="1",   level="age",    parent="uppercretaceous", children={} },
	   {key="santonian",        Titel="Santonium",                Farbe="DFE895", Beginn="86.30",  Zeilen="1",   level="age",    parent="uppercretaceous", children={} },
	   {key="coniacian",        Titel="Coniacium",                Farbe="D2E38C", Beginn="89.80",  Zeilen="1",   level="age",    parent="uppercretaceous", children={} },
	   {key="turonian",         Titel="Turonium",                 Farbe="C5DF83", Beginn="93.90",  Zeilen="1",   level="age",    parent="uppercretaceous", children={} },
	   {key="cenomanian",       Titel="Cenomanium",               Farbe="B8DA7A", Beginn="100.5",  Zeilen="1",   level="age",    parent="uppercretaceous", children={} },

	   {key="albian",           Titel="Albium",                   Farbe="CEE7B1", Beginn="113.0",  Zeilen="1",   level="age",    parent="lowercretaceous", children={} },
	   {key="aptian",           Titel="Aptium",                   Farbe="C1E2A8", Beginn="125.0",  Zeilen="1",   level="age",    parent="lowercretaceous", children={} },
	   {key="barremian",        Titel="Barremium",                Farbe="B4DE9F", Beginn="129.4",  Zeilen="1",   level="age",    parent="lowercretaceous", children={} },
	   {key="hauterivian",      Titel="Hauterivium",              Farbe="A7D996", Beginn="132.9",  Zeilen="1",   level="age",    parent="lowercretaceous", children={} },
	   {key="valanginian",      Titel="Valanginium",              Farbe="9AD58D", Beginn="139.8",  Zeilen="1",   level="age",    parent="lowercretaceous", children={} },
	   {key="berriasian",       Titel="Berriasium",               Farbe="8ED184", Beginn="145.0",  Zeilen="1",   level="age",    parent="lowercretaceous", children={} },


	   {key="tithonian",        Titel="Tithonium",                Farbe="D4F3FD", Beginn="152.1",  Zeilen="1",   level="age",    parent="upperjurassic", children={} },
	   {key="kimmeridgian",     Titel="Kimmeridgium",             Farbe="C6EFFC", Beginn="157.3",  Zeilen="1",   level="age",    parent="upperjurassic", children={} },
	   {key="oxfordian",        Titel="Oxfordium",                Farbe="B7ECFC", Beginn="163.5",  Zeilen="1",   level="age",    parent="upperjurassic", children={} },

	   {key="callovian",        Titel="Callovium",                Farbe="B9EBF2", Beginn="166.1",  Zeilen="1",   level="age",    parent="middlejurassic", children={} },
	   {key="bathonian",        Titel="Bathonium",                Farbe="AAE7F2", Beginn="168.3",  Zeilen="1",   level="age",    parent="middlejurassic", children={} },
	   {key="bajocian",         Titel="Bajocium",                 Farbe="9CE3F1", Beginn="170.3",  Zeilen="1",   level="age",    parent="middlejurassic", children={} },
	   {key="aalenian",         Titel="Aalenium",                 Farbe="8DE0F0", Beginn="174.1",  Zeilen="1",   level="age",    parent="middlejurassic", children={} },

	   {key="toarcian",         Titel="Toarcium",                 Farbe="8DD8F4", Beginn="182.7",  Zeilen="1",   level="age",    parent="lowerjurassic", children={} },
	   {key="pliensbachian",    Titel="Pliensbachium",            Farbe="70D1F3", Beginn="190.8",  Zeilen="1",   level="age",    parent="lowerjurassic", children={} },
	   {key="sinemurian",       Titel="Sinemurium",               Farbe="54CBF1", Beginn="199.3",  Zeilen="1",   level="age",    parent="lowerjurassic", children={} },
	   {key="hettangian",       Titel="Hettangium",               Farbe="37C4F0", Beginn="201.3",  Zeilen="1",   level="age",    parent="lowerjurassic", children={} },


	   {key="rhaetian",         Titel="Rhaetium",                 Farbe="E3C8E2", Beginn="208.5",  Zeilen="1",   level="age",    parent="uppertriassic", children={} },
	   {key="norian",           Titel="Norian",                   Farbe="D5BBDD", Beginn="227.0",  Zeilen="1",   level="age",    parent="uppertriassic", children={} },
	   {key="carnian",          Titel="Carnium",                  Farbe="C8AFD7", Beginn="237.0",  Zeilen="1",   level="age",    parent="uppertriassic", children={} },

	   {key="ladinian",         Titel="Ladinium",                 Farbe="C99CCD", Beginn="242.0",  Zeilen="1",   level="age",    parent="middletriassic", children={} },
	   {key="anisian",          Titel="Anisium",                  Farbe="BC90C7", Beginn="247.2",  Zeilen="1",   level="age",    parent="middletriassic", children={} },

	   {key="olenekian",        Titel="Olenekium",                Farbe="B171B8", Beginn="251.2",  Zeilen="1",   level="age",    parent="lowertriassic", children={} },
	   {key="induan",           Titel="Induum",                   Farbe="A566B3", Beginn="251.9",  Zeilen="1",   level="age",    parent="lowertriassic", children={} },


	   {key="changhsingian",    Titel="Changhsingium",            Farbe="FFCAC0", Beginn="254.1",  Zeilen="1",   level="age",    parent="lopingian", children={} },
	   {key="wuchiapingian",    Titel="Wuchiapingium",            Farbe="FFC0B3", Beginn="259.1",  Zeilen="1",   level="age",    parent="lopingian", children={} },

	   {key="capitanian",       Titel="Capitanium",               Farbe="FFAA99", Beginn="265.1",  Zeilen="1",   level="age",    parent="guadalupian", children={} },
	   {key="wordian",          Titel="Wordium",                  Farbe="FFA08D", Beginn="268.8",  Zeilen="1",   level="age",    parent="guadalupian", children={} },
	   {key="roadian",          Titel="Roadium",                  Farbe="FF9581", Beginn="273.0",  Zeilen="1",   level="age",    parent="guadalupian", children={} },

	   {key="kungurian",        Titel="Kungurium",                Farbe="E99B8D", Beginn="283.5",  Zeilen="1",   level="age",    parent="cisuralian", children={} },
	   {key="artinskian",       Titel="Artinskium",               Farbe="EA9181", Beginn="290.1",  Zeilen="1",   level="age",    parent="cisuralian", children={} },
	   {key="sakmarian",        Titel="Sakmarium",                Farbe="EA8776", Beginn="295.0",  Zeilen="1",   level="age",    parent="cisuralian", children={} },
	   {key="asselian",         Titel="Asselium",                 Farbe="EB7D6B", Beginn="298.9",  Zeilen="1",   level="age",    parent="cisuralian", children={} },


	   {key="gzhelian",         Titel="Gzhelium",                 Farbe="C9DAD6", Beginn="303.7",  Zeilen="1",   level="age",    parent="upperpennsylvanian", children={} },
	   {key="kasimovian",       Titel="Kasimovium",               Farbe="BBD7D6", Beginn="307.0",  Zeilen="1",   level="age",    parent="upperpennsylvanian", children={} },
	   {key="moscovian",        Titel="Moskovium",                Farbe="AFD3CC", Beginn="315.2",  Zeilen="1",   level="age",    parent="middlepennsylvanian", children={} },
	   {key="bashkirian",       Titel="Bashkirium",               Farbe="93CCCC", Beginn="323.2",  Zeilen="1",   level="age",    parent="lowerpennsylvanian", children={} },

	   {key="serpukhovian",     Titel="Serpukhovium",             Farbe="C4C78A", Beginn="330.9",  Zeilen="1",   level="age",    parent="uppermississippian", children={} },
	   {key="visean",           Titel="Viseum",                   Farbe="A9C18B", Beginn="346.7",  Zeilen="1",   level="age",    parent="middlemississippian", children={} },
	   {key="tournaisian",      Titel="Tournaisium",              Farbe="8EBB8B", Beginn="358.9",  Zeilen="1",   level="age",    parent="lowermississippian", children={} },

	   {key="famennian",        Titel="Famennium",                Farbe="F4EDD3", Beginn="372.2",  Zeilen="1",   level="age",    parent="upperdevonian", children={} },
	   {key="frasnian",         Titel="Frasnium",                 Farbe="F6EBC0", Beginn="382.7",  Zeilen="1",   level="age",    parent="upperdevonian", children={} },

	   {key="givetian",         Titel="Givetium",                 Farbe="F8DFA0", Beginn="387.7",  Zeilen="1",   level="age",    parent="middledevonian", children={} },
	   {key="eifelian",         Titel="Eifelium",                 Farbe="F9D592", Beginn="393.3",  Zeilen="1",   level="age",    parent="middledevonian", children={} },

	   {key="emsian",           Titel="Emsium",                   Farbe="EBD193", Beginn="407.6",  Zeilen="1",   level="age",    parent="lowerdevonian", children={} },
	   {key="pragian",          Titel="Pragium",                  Farbe="ECC886", Beginn="410.8",  Zeilen="1",   level="age",    parent="lowerdevonian", children={} },
	   {key="lochkovian",       Titel="Lochkovium",               Farbe="ECBE7A", Beginn="419.2",  Zeilen="1",   level="age",    parent="lowerdevonian", children={} },

	   {key="pridolinull",      Titel="Pridoli (Epoche)",         Farbe="E4F5EB", Beginn="423.0",  Zeilen="1",   level="age",    parent="pridoli", children={} },

	   {key="ludfordian",       Titel="Ludfordium",               Farbe="D6F1EA", Beginn="425.6",  Zeilen="1",   level="age",    parent="ludlow", children={} },
	   {key="gorstian",         Titel="Gorstium",                 Farbe="C8EDE9", Beginn="427.4",  Zeilen="1",   level="age",    parent="ludlow", children={} },

	   {key="homerian",         Titel="Homerium",                 Farbe="C9ECE0", Beginn="430.5",  Zeilen="1",   level="age",    parent="wenlock", children={} },
	   {key="sheinwoodian",     Titel="Sheinwoodium",             Farbe="BCE7D6", Beginn="433.4",  Zeilen="1",   level="age",    parent="wenlock", children={} },

	   {key="telychian",        Titel="Telychium",                Farbe="BBE8E0", Beginn="438.5",  Zeilen="1",   level="age",    parent="llandovery", children={} },
	   {key="aeronian",         Titel="Aeronium",                 Farbe="AEE4D6", Beginn="440.8",  Zeilen="1",   level="age",    parent="llandovery", children={} },
	   {key="rhuddanian",       Titel="Rhuddanium",               Farbe="A0DFCC", Beginn="443.8",  Zeilen="1",   level="age",    parent="llandovery", children={} },

	   {key="hirnantian",       Titel="Hirnantium",               Farbe="A2DEC3", Beginn="445.2",  Zeilen="1",   level="age",    parent="upperordovician", children={} },
	   {key="katian",           Titel="Katium",                   Farbe="93DAC3", Beginn="453.0",  Zeilen="1",   level="age",    parent="upperordovician", children={} },
	   {key="sandbian",         Titel="Sandbium",                 Farbe="88D5B1", Beginn="458.4",  Zeilen="1",   level="age",    parent="upperordovician", children={} },

	   {key="darriwilian",      Titel="Darriwilium",              Farbe="6ACFBA", Beginn="467.3",  Zeilen="1",   level="age",    parent="middleordovician", children={} },
	   {key="dapingian",        Titel="Dapingium",                Farbe="5DCBB1", Beginn="470.0",  Zeilen="1",   level="age",    parent="middleordovician", children={} },

	   {key="floian",           Titel="Floium",                   Farbe="34C1A8", Beginn="477.7",  Zeilen="1",   level="age",    parent="lowerordovician", children={} },
	   {key="tremadocian",      Titel="Tremadocium",              Farbe="28BDA0", Beginn="485.4",  Zeilen="1",   level="age",    parent="lowerordovician", children={} },

	   {key="cambrianstage10",  Titel="Kambrium 10. Stufe",       Farbe="E6F3D7", Beginn="489.5",  Zeilen="1",   level="age",    parent="furongian", children={} },
	   {key="jiangshanian",     Titel="Jiangshanium",             Farbe="D9EECE", Beginn="494.0",  Zeilen="1",   level="age",    parent="furongian", children={} },
	   {key="paibian",          Titel="Paibium",                  Farbe="CCE9C4", Beginn="497.0",  Zeilen="1",   level="age",    parent="furongian", children={} },

	   {key="guzhangian",       Titel="Guzhangium",               Farbe="CCE0BF", Beginn="500.5",  Zeilen="1",   Level="age",    parent="miaolingian", children={} },
	   {key="drumian",          Titel="Drumium",                  Farbe="BFDCB6", Beginn="504.5",  Zeilen="1",   Level="age",    parent="miaolingian", children={} },
	   {key="wuliuan",          Titel="Wuliuum",                  Farbe="B2D7AD", Beginn="509.0",  Zeilen="1",   Level="age",    parent="miaolingian", children={} },

	   {key="cambrianstage4",   Titel="Kambrium 4. Stufe",        Farbe="B3CFA9", Beginn="514.0",  Zeilen="1",   Level="age",    parent="cambrianseries2", children={} },
	   {key="cambrianstage3",   Titel="Kambrium 3. Stufe",        Farbe="A6CBA0", Beginn="521.0",  Zeilen="1",   Level="age",    parent="cambrianseries2", children={} },

	   {key="cambrianstage2",   Titel="Kambrium 2. Stufe",     Farbe="A7C29C", Beginn="529.0",  Zeilen="1",   Level="age",    parent="terreneuvian", children={} },
	   {key="fortunian",        Titel="Fortunium",             Farbe="9ABF93", Beginn="541.0",  Zeilen="1",   Level="age",    parent="terreneuvian", children={} }
};

local function CallAnAge(Agename)
	local Age = ages[Agename];
	if not Age then return '<span class="error">Stufe ' .. Agename .. ' nicht gefunden!</span>\n' end
	local Text = string.format('****** Stufe: Name=%20s, Diagrammfarbe=%7s, Beginn=%7s mya, Ende=%7s mya\n', Age.Titel, Age.Farbe, Age.Beginn, Age.Ende) ;
	return Text;
end

local function CallAnEpoch(Epochname)
	local Epoch = epochs[Epochname];
	if not Epoch then return '<span class="error">Epoche ' .. Epochname .. ' nicht gefunden!</span>\n' end
	local Text = string.format('***** Epoche: Name=%20s, Diagrammfarbe=%7s, Beginn=%7s mya, Ende=%7s mya, Anzahl enthaltener Stufen=%2d\n', Epoch.Titel,Epoch.Farbe,Epoch.Beginn, Epoch.Ende, #Epoch.children) ;
	if #Epoch.children > 0 then
		for epochchildnr = 1, #Epoch.children do
			epochchildname = Epoch.children[epochchildnr];
			Text = Text .. CallAnAge(epochchildname);
		end
	end
	return Text;
end

local function CallASubPeriod(SubPeriodname)
	local SubPeriod = subperiods[SubPeriodname];
	if not SubPeriod then return '<span class="error">Unterperiode ' .. SubPeriodname .. ' nicht gefunden!</span>\n' end
	local Text = string.format('**** Unterperiode: Name=%15s, Diagrammfarbe=%7s, Beginn=%7s mya, Ende=%7s mya, Anzahl enthaltener Epochen=%2d\n', SubPeriod.Titel,SubPeriod.Farbe,SubPeriod.Beginn, SubPeriod.Ende, #SubPeriod.children) ;
	if #SubPeriod.children > 0 then
		for subperiodchildnr = 1, #SubPeriod.children do
			subperiodchildname = SubPeriod.children[subperiodchildnr];
			Text = Text .. CallAnEpoch(subperiodchildname)
		end
	end
	return Text;
end

local function CallAPeriod(Periodname)
	local Period = periods[Periodname];
	if not Period then return '<span class="error">Periode ' .. Periodname .. ' nicht gefunden!</span>\n' end
	local child = "";
	if Periodname == "carboniferous" then child = "Unterperioden:" else  child = "Epochen"; end
	local Text = string.format('*** Periode: Name=%21s, Diagrammfarbe=%7s, Beginn=%7s mya, Ende=%7s mya, Anzahl enthaltener %s=%2d\n', Period.Titel,Period.Farbe,Period.Beginn, Period.Ende, child, #Period.children) ;
	if #Period.children > 0 then
		for periodchildnr = 1, #Period.children do
			periodchildname = Period.children[periodchildnr];
			-- Hier Sonderfall Periodname == carboniferous
			if Periodname == "carboniferous" then
				Text = Text .. CallASubPeriod(periodchildname)
			else
				Text = Text .. CallAnEpoch(periodchildname)
			end
		end
	end
	return Text;
end

local function CallAnEra(Eraname)
	local Era = eras[Eraname];
	if not Era then return '<span class="error">Ära ' .. Eraname .. ' nicht gefunden!</span>\n' end
	local Text = string.format('**Ära: Name=%s, Diagrammfarbe=%s, Beginn=%s mya, Ende=%s mya, Anzahl enthaltener Perioden:%2d\n', Era.Titel,Era.Farbe,Era.Beginn, Era.Ende, #Era.children) ;
	if #Era.children > 0 then
		for erachild = 1, #Era.children do
			erachildname = Era.children[erachild];
			Text = Text .. CallAPeriod(erachildname);
		end
	end
	return Text;
end

local function CallAnEon(Eonname)
	local Eon  =  eons[Eonname];
	if not Eon then return '<span class="error">Äon ' .. Eonname .. ' nicht gefunden!</span>\n' end
	local Text = string.format('*Äon: Name= %s, Diagrammfarbe=%s, Beginn=%s mya, Ende=%s  mya, Anzahl enthaltener Ären:%2d\n', Eon.Titel,Eon.Farbe,Eon.Beginn, Eon.Ende, #Eon.children) ;
	if #Eon.children > 0 then
		for eonchild = 1, #Eon.children do
			eonchildname = Eon.children[eonchild];
			Text = Text .. CallAnEra(eonchildname);
		end
	end
	return Text;
end

local function CallChart()
	Text = "";
	if #chart.children > 0 then -- usually allways true, but 'keep the system'
		for chartchildnr = 1, #chart.children do
			chartchildname = chart.children[chartchildnr];
			Text = Text .. CallAnEon(chartchildname);
		end
	end
	return Text;
end


local function GetDataset(name)
	local key="";
	endtime = 0.0;
	for idx, value in ipairs(eons) do
		key = value["key"];
		if name == key then
			value["Ende"] = endtime;
			return "eon", value;
		end
		endtime = value["Beginn"];
	end

	endtime = 0.0;
	for idx, value in ipairs(eras) do
		key = value["key"];
		if name == key then
			value["Ende"] = endtime;
			return "era", value;
		end
		endtime = value["Beginn"];
	end

	endtime = 0.0;
	for idx, value in ipairs(periods) do
		key = value["key"];
		if name == key then
			value["Ende"] = endtime;
			return "period", value;
		end
		endtime = value["Beginn"];
	end

	endtime = 0.0;
	for idx, value in ipairs(subperiods) do
		key = value["key"];
		if name == key then
			value["Ende"] = endtime;
			return "subperiod", value;
		end
		endtime = value["Beginn"];
	end

	endtime = 0.0;
	for idx, value in ipairs(epochs) do
		key = value["key"];
		if name == key then
			value["Ende"] = endtime;
			return "epoch", value;
		end
		endtime = value["Beginn"];
	end

	endtime = 0.0;
	for idx, value in ipairs(ages) do
		key = value["key"];
		if name == key then
			return "age", value;
		end
		endtime = value["Beginn"];
	end
	return "none", "";
end

local Ics = {};

function Ics.GetAgeData(frame)
	local name = tostring(frame.args[1] or "");
	local Age = ages[name];
	if not Age then return '<span class="error">No Agedata available!</span>\n' end
	local Data = CallAnAge(name);
	return Data;
end

function Ics.GetEpochData(frame)
	local name = tostring(frame.args[1] or "");
	local Epoch = epochs[name];
	if not Epoch then return '<span class="error">No Epochdata available!</span>\n' end
	local Data = CallAnEpoch(name);
	return Data;
end

function Ics.GetSubPeriodData(frame)
	local name = tostring(frame.args[1] or "");
	local Epoch = subperiods[name];
	if not Epoch then return '<span class="error">No Subperioddata available!</span>\n' end
	local Data = CallASubPeriod(name);
	return Data;
end

function Ics.GetPeriodData(frame)
	local name = tostring(frame.args[1] or "");
	local Period = periods[name];
	if not Period then return '<span class="error">No Perioddata available!</span>\n' end
	local Data = CallAPeriod(name);
	return Data;
end

function Ics.GetEraData(frame)
	local name = tostring(frame.args[1] or "");
	local Era = eras[name];
	if not Era then return '<span class="error">No Eradata available!</span>\n' end
	local Data = CallAPeriod(name);
	return Data;
end

function Ics.GetEonData(frame)
	local aName = tostring(frame.args[1] or "");
	local Eon = eons[aName];
	if not Eon then
		return '"' .. aName .. '"\n' .. '<span class="error">No such Eondata available!</span>' end
	local Data = CallAnEon(aName);
	return Data;
   end

function Ics.GetChartData(frame)
	local Data = CallChart();
	return Data;
end

function Ics.GetData(frame)
	local aName = tostring(frame.args[1] or "");
	local anAttrib = tostring(frame.args[2] or "");
	local Level, tblSet = GetDataset(aName);
	if Level == "none" then
		return '<span class="error">Zeitalter nicht gefunden!</span>';
	end
	local aValue ="";
	if anAttrib == "titel" then
		aValue = tblSet["Titel"];
	elseif anAttrib == "farbe" then
		aValue = tblSet["Farbe"];
	elseif anAttrib == "beginn"
		then aValue = tblSet["Beginn"];
	elseif anAttrib == "ende" then
		aValue = tblSet["Ende"];
	else
		aValue = '<span class="error">Datenwert nicht gefunden!</span>';
	end
	return aValue;
end

return Ics