local export = {}

local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("de")

local function switchaux(aux,h,s,hs)
	if aux == "h" or aux == "haben" then return h
	elseif aux == "s" or aux == "sein" then return s
	elseif aux == "hs" or aux == "sh" then return hs
	end
end

local function link(text)
	return text and m_links.full_link({lang = lang, term = text}) or "—"
end

local function tablelink(text)
	if type(text) == "table" then
		return link(text[1]) .. " / " .. link(text[2])
	else
		return link(text)
	end
end

local function prefixlink(insep,text,sep)
	if not sep then sep = '' end
	if type(text) == "table" then
		return link(insep..text[1]..' '..sep) .. " / " .. link(insep..text[2]..' '..sep)
	else
		return link(insep..text..' '..sep)
	end
end

local function header(form) 
	local forms = {
		auxiliary = 'Hilfsverb',
		infinitive = 'Infinitiv',
		present = 'Präsens',
		preterite = 'Präteritum',
		perfect = 'Perfekt',
		pluperfect = 'Plusquamperfekt',
		indicative = 'Indikativ', 
		subjunctive = 'Konjunktiv',
		subjunctive_i = 'Konjunktiv I (Konjunktiv Präsens)',
		subjunctive_ii = 'Konjunktiv II (Konjunktiv Präteritum)',
		present_participle = 'Partizip I (Partizip Präsens)',
		past_participle = 'Partizip II (Partizip Perfekt)',
		imperative = 'Imperativ',
		future_i = 'Futur I',
		future_ii = 'Futur II'
	}
	forms['i'] = forms['subjunctive_i']
	forms['ii'] = forms['subjunctive_ii']
	return '<span title="' .. forms[form] .. '">' .. string.gsub(form, '_', ' ') .. '</span>'
end

function export.maketable(sep_prefix,insep_prefix,conj,aux,impersonal,from_stems)
	local text = ''
	local start = ''
	local finish = ''
	if impersonal then
		start = '<s><span style="color:grey">'
		finish = '</span></s>'
	end
	if sep_prefix ~= "" then
		local prefix = sep_prefix .. insep_prefix
		if insep_prefix ~= "" then
			pp = prefix .. conj["pp"]
		elseif not from_stems then
			pp = sep_prefix .. "ge" .. conj["pp"]
		else
			pp = prefix .. conj["pp"]
		end
		text = text .. '\n<div class="NavFrame" style="">'
		text = text .. '\n<div class="NavHead" style="" >การผันรูปของ \'\'\'' .. prefix .. conj["inf"] .. '\'\'\'</div>'
		text = text .. '\n<div class="NavContent">'
		text = text .. '\n{| border="1px solid #000000" style="border-collapse:collapse; background:#fafafa; text-align:center; width:100%" class="inflection-table"'
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | ' .. header('infinitive')
		text = text .. '\n| colspan="4" | ' .. prefix .. conj["inf"]
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | ' .. header('present_participle')
		text = text .. '\n| colspan="4" | ' .. link(prefix .. conj["prp"])
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | ' .. header('past_participle')
		text = text .. '\n| colspan="4" | ' .. link(pp)
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | zu-infinitive'
		text = text .. '\n| colspan="4" | ' .. link(sep_prefix .. "zu" .. insep_prefix .. conj["inf"])
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | ' .. header('auxiliary')
		text = text .. '\n| colspan="4" | ' .. link(switchaux(aux,"haben","sein",link("haben") .. " or " .. link("sein")))
		text = text .. '\n|-'
		text = text .. '\n| style="background:#a0ade3" |'
		text = text .. '\n! colspan="2" style="background:#a0ade3" | ' .. header('indicative')
		text = text .. '\n| style="background:#a0ade3" |'
		text = text .. '\n! colspan="2" style="background:#a0ade3" | '.. header('subjunctive')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#c0cfe4; width:7em" | ' .. header('present')
		text = text .. '\n| ich ' .. start .. prefixlink(insep_prefix, conj["1s_pres_indc"], sep_prefix) .. finish
		text = text .. '\n| wir ' .. start .. prefixlink(insep_prefix, conj["1p_pres_indc"], sep_prefix) .. finish
		text = text .. '\n! rowspan="3" style="background:#c0cfe4; width:7em" | ' .. header('i')
		text = text .. '\n| ich ' .. start .. prefixlink(insep_prefix, conj["1s_pres_subj"], sep_prefix) .. finish
		text = text .. '\n| wir ' .. start .. prefixlink(insep_prefix, conj["1p_pres_subj"], sep_prefix) .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. prefixlink(insep_prefix, conj["2s_pres_indc"], sep_prefix) .. finish
		text = text .. '\n| ihr ' .. start .. prefixlink(insep_prefix, conj["2p_pres_indc"], sep_prefix) .. finish
		text = text .. '\n| du ' .. start .. prefixlink(insep_prefix, conj["2s_pres_subj"], sep_prefix) .. finish
		text = text .. '\n| ihr ' .. start .. prefixlink(insep_prefix, conj["2p_pres_subj"], sep_prefix) .. finish
		text = text .. '\n|-'
		text = text .. '\n| er ' .. prefixlink(insep_prefix, conj["3s_pres_indc"], sep_prefix)
		text = text .. '\n| sie ' .. start .. prefixlink(insep_prefix, conj["3p_pres_indc"], sep_prefix) .. finish
		text = text .. '\n| er ' .. prefixlink(insep_prefix, conj["3s_pres_subj"], sep_prefix)
		text = text .. '\n| sie ' .. start .. prefixlink(insep_prefix, conj["3p_pres_subj"], sep_prefix) .. finish
		text = text .. '\n|-'
		text = text .. '\n| colspan="6" style="background:#d5d5d5; height: .25em" | '
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#c0cfe4" | ' .. header('preterite')
		text = text .. '\n| ich ' .. start .. prefixlink(insep_prefix,conj["1s_pret_indc"],sep_prefix) .. finish
		text = text .. '\n| wir ' .. start .. prefixlink(insep_prefix,conj["1p_pret_indc"],sep_prefix) .. finish
		text = text .. '\n! rowspan="3" style="background:#c0cfe4" | ' .. header('ii')
		text = text .. '\n| ich ' .. start .. prefixlink(insep_prefix,conj["1s_pret_subj"],sep_prefix) .. finish
		text = text .. '\n| wir ' .. start .. prefixlink(insep_prefix,conj["1p_pret_subj"],sep_prefix) .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. prefixlink(insep_prefix,conj["2s_pret_indc"],sep_prefix) .. finish
		text = text .. '\n| ihr ' .. start .. prefixlink(insep_prefix,conj["2p_pret_indc"],sep_prefix) .. finish
		text = text .. '\n| du ' .. start .. prefixlink(insep_prefix,conj["2s_pret_subj"],sep_prefix) .. finish
		text = text .. '\n| ihr ' .. start .. prefixlink(insep_prefix,conj["2p_pret_subj"],sep_prefix) .. finish
		text = text .. '\n|-'
		text = text .. '\n| er ' .. prefixlink(insep_prefix,conj["3s_pret_indc"],sep_prefix)
		text = text .. '\n| sie ' .. start .. prefixlink(insep_prefix,conj["3p_pret_indc"],sep_prefix) .. finish
		text = text .. '\n| er ' .. prefixlink(insep_prefix,conj["3s_pret_subj"],sep_prefix)
		text = text .. '\n| sie ' .. start .. prefixlink(insep_prefix,conj["3p_pret_subj"],sep_prefix) .. finish
		text = text .. '\n|-'
		text = text .. '\n| colspan="6" style="background:#d5d5d5; height: .25em" | '
		text = text .. '\n|-'
		text = text .. '\n! style="background:#c0cfe4" | ' .. header('imperative')
		text = text .. '\n| '
		if type(conj["2s_imp"]) == "table" then
			text = text ..  start .. link(insep_prefix .. conj["2s_imp"][1] .. " " .. sep_prefix) .. finish
			text = text .. " (du)<br />"
			text = text ..  start .. link(insep_prefix .. conj["2s_imp"][2] .. " " .. sep_prefix) .. finish
		elseif conj["2s_imp"] == "-" then
			text = text .. "— (du)"
		else
			text = text .. start .. prefixlink(insep_prefix, conj["2s_imp"], sep_prefix) .. finish
		end
		text = text .. ' (du)\n| ' .. ((conj["2p_imp"] == "-") and '—' or (start .. link(insep_prefix .. conj["2p_imp"] .. " " .. sep_prefix .. finish) .. ' (ihr)'))
		text = text .. '\n| colspan="3" style="background:#e0e0e0" |'
		text = text .. '\n|}'
		text = text .. '\n</div></div>'
		text = text .. '\n<div class="NavFrame" style="">'
		text = text .. '\n<div class="NavHead" style="" >รูป subordinate clause ของ \'\'\'' .. prefix .. conj["inf"] .. '\'\'\'</div>'
		text = text .. '\n<div class="NavContent">'
		text = text .. '\n{| border="1px solid #000000" style="border-collapse:collapse; background:#fafafa; text-align:center; width:100%" class="inflection-table"'
		text = text .. '\n|-'
		text = text .. '\n| style="background:#a0ade3" |'
		text = text .. '\n! colspan="2" style="background:#a0ade3" | ' .. header('indicative')
		text = text .. '\n| style="background:#a0ade3" |'
		text = text .. '\n! colspan="2" style="background:#a0ade3" | ' .. header('subjunctive')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#c0cfe4; width:7em" | present'
		text = text .. '\n| dass ich ' .. start .. prefixlink(prefix, conj["1s_pres_indc"]) .. finish
		text = text .. '\n| dass wir ' .. start .. prefixlink(prefix, conj["1p_pres_indc"]) .. finish
		text = text .. '\n! rowspan="3" style="background:#c0cfe4; width:7em" | i '
		text = text .. '\n| dass ich ' .. start .. prefixlink(prefix, conj["1s_pres_subj"]) .. finish
		text = text .. '\n| dass wir ' .. start .. prefixlink(prefix, conj["1p_pres_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| dass du ' .. start .. prefixlink(prefix, conj["2s_pres_indc"]) .. finish
		text = text .. '\n| dass ihr ' .. start .. prefixlink(prefix, conj["2p_pres_indc"]) .. finish
		text = text .. '\n| dass du ' .. start .. prefixlink(prefix, conj["2s_pres_subj"]) .. finish
		text = text .. '\n| dass ihr ' .. start .. prefixlink(prefix, conj["2p_pres_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| dass er ' .. prefixlink(prefix, conj["3s_pres_indc"])
		text = text .. '\n| dass sie ' .. start .. prefixlink(prefix, conj["3p_pres_indc"]) .. finish
		text = text .. '\n| dass er ' .. prefixlink(prefix, conj["3s_pres_subj"])
		text = text .. '\n| dass sie ' .. start .. prefixlink(prefix, conj["3p_pres_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| colspan="6" style="background:#d5d5d5; height: .25em" | '
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#c0cfe4" | ' .. header('preterite')
		text = text .. '\n| dass ich ' .. start .. prefixlink(prefix,conj["1s_pret_indc"]) .. finish
		text = text .. '\n| dass wir ' .. start .. prefixlink(prefix,conj["1p_pret_indc"]) .. finish
		text = text .. '\n! rowspan="3" style="background:#c0cfe4" | ' .. header('ii')
		text = text .. '\n| dass ich ' .. start .. prefixlink(prefix,conj["1s_pret_subj"]) .. finish
		text = text .. '\n| dass wir ' .. start .. prefixlink(prefix,conj["1p_pret_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| dass du ' .. start .. prefixlink(prefix,conj["2s_pret_indc"]) .. finish
		text = text .. '\n| dass ihr ' .. start .. prefixlink(prefix,conj["2p_pret_indc"]) .. finish
		text = text .. '\n| dass du ' .. start .. prefixlink(prefix,conj["2s_pret_subj"]) .. finish
		text = text .. '\n| dass ihr ' .. start .. prefixlink(prefix,conj["2p_pret_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| dass er ' .. prefixlink(prefix,conj["3s_pret_indc"])
		text = text .. '\n| dass sie ' .. start .. prefixlink(prefix,conj["3p_pret_indc"]) .. finish
		text = text .. '\n| dass er ' .. prefixlink(prefix,conj["3s_pret_subj"])
		text = text .. '\n| dass sie ' .. start .. prefixlink(prefix,conj["3p_pret_subj"]) .. finish
		text = text .. '\n|}'
		text = text .. '\n</div></div>'
		text = text .. '\n<div class="NavFrame" style="">'
		text = text .. '\n<div class="NavHead" style="" >รูปประกอบของ \'\'\'' .. prefix .. conj["inf"] .. '\'\'\'</div>'
		text = text .. '\n<div class="NavContent">'
		text = text .. '\n{| border="1px solid #000000" style="border-collapse:collapse; background:#fafafa; text-align:center; width:100%" class="inflection-table"'
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#99cc99" | ' .. header('perfect')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#cfedcc; width:7em" | ' .. header('indicative')
		text = text .. '\n| ich ' .. start .. switchaux(aux,"habe","bin","habe " .. link(pp) .. finish .. " <br>ich " .. start .. "bin") .. ' ' .. link(pp) .. finish
		text = text .. '\n| wir ' .. start .. switchaux(aux,"haben","sind","haben " .. link(pp) .. finish .. " <br>wir " .. start .. "sind") .. ' ' .. link(pp) .. finish
		text = text .. '\n! rowspan="3" style="background:#cfedcc; width:7em" | ' .. header('subjunctive')
		text = text .. '\n| ich ' .. start .. switchaux(aux,"habe","sei","habe " .. link(pp) .. finish .. " <br>ich " .. start .. "sei") .. ' ' .. link(pp) .. finish
		text = text .. '\n| wir ' .. start .. switchaux(aux,"haben","seien","haben " .. link(pp) .. finish .. " <br>wir " .. start .. "seien") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. switchaux(aux,"hast","bist","hast " .. link(pp) .. finish .. " <br>du " .. start .. "bist") .. ' ' .. link(pp) .. finish
		text = text .. '\n| ihr ' .. start .. switchaux(aux,"habt","seid","habt " .. link(pp) .. finish .. " <br>ihr " .. start .. "seid") .. ' ' .. link(pp) .. finish
		text = text .. '\n| du ' .. start .. switchaux(aux,"habest","seist","habest " .. link(pp) .. finish .. " <br>du " .. start .. "seist") .. ' ' .. link(pp) .. finish
		text = text .. '\n| ihr ' .. start .. switchaux(aux,"habet","seiet","habet " .. link(pp) .. finish .. " <br>ihr " .. start .. "seiet") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n| er ' .. switchaux(aux,"hat","ist","hat " .. link(pp) .. " <br>er ist") .. ' ' .. link(pp)
		text = text .. '\n| sie ' .. start .. switchaux(aux,"haben","sind","haben " .. link(pp) .. " <br>sie sind") .. ' ' .. link(pp) .. finish
		text = text .. '\n| er ' .. switchaux(aux,"habe","sei","habe " .. link(pp) .. " <br>er sei") .. ' ' .. link(pp)
		text = text .. '\n| sie ' .. start .. switchaux(aux,"haben","seien","haben " .. link(pp) .. " <br>sie seien") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#99CC99" | ' ..header('pluperfect')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#cfedcc" | ' .. header('indicative')
		text = text .. '\n| ich ' .. start .. switchaux(aux,"hatte","war","hatte " .. link(pp) .. finish .. " <br>ich " .. start .. "war") .. ' ' .. link(pp) .. finish
		text = text .. '\n| wir ' .. start .. switchaux(aux,"hatten","waren","hatten " .. link(pp) .. finish .. " <br>wir " .. start .. "waren") .. ' ' .. link(pp) .. finish
		text = text .. '\n! rowspan="3" style="background:#cfedcc" | ' .. header('subjunctive')
		text = text .. '\n| ich ' .. start .. switchaux(aux,"hätte","wäre","hätte " .. link(pp) .. finish .. " <br>ich " .. start .. "wäre") .. ' ' .. link(pp) .. finish
		text = text .. '\n| wir ' .. start .. switchaux(aux,"hätten","wären","hätten " .. link(pp) .. finish .. " <br>wir " .. start .. "wären") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. switchaux(aux,"hattest","warst","hattest " .. link(pp) .. finish .. " <br>du " .. start .. "warst") .. ' ' .. link(pp) .. finish
		text = text .. '\n| ihr ' .. start .. switchaux(aux,"hattet","wart","hattet " .. link(pp) .. finish .. " <br>ihr " .. start .. "wart") .. ' ' .. link(pp) .. finish
		text = text .. '\n| du ' .. start .. switchaux(aux,"hättest","wärst","hättest " .. link(pp) .. finish .. " <br>du " .. start .. "wärst") .. ' ' .. link(pp) .. finish
		text = text .. '\n| ihr ' .. start .. switchaux(aux,"hättet","wärt","hättet " .. link(pp) .. finish .. " <br>ihr " .. start .. "wärt") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n| er ' .. switchaux(aux,"hatte","war","hatte " .. link(pp) .. " <br>er war") .. ' ' .. link(pp)
		text = text .. '\n| sie ' .. start .. switchaux(aux,"hatten","waren","hatten " .. link(pp) .. " <br>sie waren") .. ' ' .. link(pp) .. finish
		text = text .. '\n| er ' .. switchaux(aux,"hätte","wäre","hätte " .. link(pp) .. " <br>er wäre") .. ' ' .. link(pp)
		text = text .. '\n| sie ' .. start .. switchaux(aux,"hätten","wären","hätten " .. link(pp) .. " <br>sie wären") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#9999DF" | ' .. header('future_i')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('infinitive')
		text = text .. '\n| rowspan="3" colspan="2" | ' .. prefix .. conj["inf"] .. ' werden'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('subjunctive_i')
		text = text .. '\n| ich ' .. start .. 'werde ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n| wir ' .. start .. 'werden ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. 'werdest ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n| ihr ' .. start .. 'werdet ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n|-'
		text = text .. '\n| er werde ' .. prefix .. conj["inf"]
		text = text .. '\n| sie werden ' .. prefix .. conj["inf"]

		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#d5d5d5; height: .25em" |'
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('indicative')
		text = text .. '\n| ich ' .. start .. 'werde ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n| wir ' .. start .. 'werden ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('subjunctive_ii')
		text = text .. '\n| ich ' .. start .. 'würde ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n| wir ' .. start .. 'würden ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. 'wirst ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n| ihr ' .. start .. 'werdet ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n| du ' .. start .. 'würdest ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n| ihr ' .. start .. 'würdet ' .. prefix .. conj["inf"] .. finish
		text = text .. '\n|-'
		text = text .. '\n| er wird ' .. prefix .. conj["inf"]
		text = text .. '\n| sie werden ' .. prefix .. conj["inf"]
		text = text .. '\n| er würde ' .. prefix .. conj["inf"]
		text = text .. '\n| sie würden ' .. prefix .. conj["inf"]
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#9999DF" | ' .. header('future_ii')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('infinitive')
		text = text .. '\n| rowspan="3" colspan="2" | ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben werden <br>' .. link(pp) .. ' sein') .. ' werden'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('subjunctive_i')
		text = text .. '\n| ich ' .. start .. 'werde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ich werde ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n| wir ' .. start .. 'werden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> wir werden ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. 'werdest ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> du werdest ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n| ihr ' .. start .. 'werdet ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ihr werdet ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n|-'
		text = text .. '\n| er werde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> er werde ' .. link(pp) .. ' sein')
		text = text .. '\n| sie werden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> sie werden ' .. link(pp) .. ' sein')
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#d5d5d5; height: .25em" |'
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('indicative')
		text = text .. '\n| ich ' .. start .. 'werde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ich werde ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n| wir ' .. start .. 'werden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> wir werden ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('subjunctive_ii')
		text = text .. '\n| ich ' .. start .. 'würde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ich würde ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n| wir ' .. start .. 'würden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> wir würden ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. 'wirst ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> du wirst ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n| ihr ' .. start .. 'werdet ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ihr werdet ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n| du ' .. start .. 'würdest ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> du würdest ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n| ihr ' .. start .. 'würdet ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ihr würdet ' .. link(pp) .. ' sein') .. finish
		text = text .. '\n|-'
		text = text .. '\n| er wird ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> er wird ' .. link(pp) .. ' sein')
		text = text .. '\n| sie werden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> sie werden ' .. link(pp) .. ' sein')
		text = text .. '\n| er würde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> er würde ' .. link(pp) .. ' sein')
		text = text .. '\n| sie würden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> sie würden ' .. link(pp) .. ' sein')
		text = text .. '\n|}</div></div>'
	else
		if insep_prefix ~= "" then
			pp = insep_prefix .. conj["pp"]
			for name,form in pairs(conj) do
				if type(form) == "table" then
					for subname,subform in pairs(form) do
						conj[name][subname] = insep_prefix .. subform
					end
				else
					conj[name] = insep_prefix .. form
				end
			end
		elseif not from_stems then
			pp = "ge" .. conj["pp"]
		else
			pp = conj["pp"]
		end
		text = text .. '\n<div class="NavFrame" style="">'
		text = text .. '\n<div class="NavHead" style="" >การผันรูปของ \'\'\'' .. conj["inf"] .. '\'\'\'</div>'
		text = text .. '\n<div class="NavContent">'
		text = text .. '\n{| border="1px solid #000000" style="border-collapse:collapse; background:#fafafa; text-align:center; width:100%" class="inflection-table"'
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | ' .. header('infinitive')
		text = text .. '\n| colspan="4" | ' .. conj["inf"]
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | ' .. header('present_participle')
		text = text .. '\n| colspan="4" | ' .. link(conj["prp"])
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | ' .. header('past_participle')
		text = text .. '\n| colspan="4" | ' .. link(pp)
		text = text .. '\n|-'
		text = text .. '\n! colspan="2" style="background:#d0d0d0" | ' .. header('auxiliary')
		text = text .. '\n| colspan="4" | ' .. link(switchaux(aux,"haben","sein",link("haben") .. " or " .. link("sein")))
		text = text .. '\n|-'
		text = text .. '\n| style="background:#a0ade3" |'
		text = text .. '\n! colspan="2" style="background:#a0ade3" | ' .. header('indicative')
		text = text .. '\n| style="background:#a0ade3" |'
		text = text .. '\n! colspan="2" style="background:#a0ade3" | ' .. header('subjunctive')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#c0cfe4; width:7em" | ' .. header('present')
		text = text .. '\n| ich ' .. start .. tablelink(conj["1s_pres_indc"]) .. finish
		text = text .. '\n| wir ' .. start .. tablelink(conj["1p_pres_indc"]) .. finish
		text = text .. '\n! rowspan="3" style="background:#c0cfe4; width:7em" | ' .. header('i')
		text = text .. '\n| ich ' .. start .. tablelink(conj["1s_pres_subj"]) .. finish
		text = text .. '\n| wir ' .. start .. tablelink(conj["1p_pres_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. tablelink(conj["2s_pres_indc"]) .. finish
		text = text .. '\n| ihr ' .. start .. tablelink(conj["2p_pres_indc"]) .. finish
		text = text .. '\n| du ' .. start .. tablelink(conj["2s_pres_subj"]) .. finish
		text = text .. '\n| ihr ' .. start .. tablelink(conj["2p_pres_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| er ' .. tablelink(conj["3s_pres_indc"])
		text = text .. '\n| sie ' .. start .. tablelink(conj["3p_pres_indc"]) .. finish
		text = text .. '\n| er ' .. tablelink(conj["3s_pres_subj"])
		text = text .. '\n| sie ' .. start .. tablelink(conj["3p_pres_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| colspan="6" style="background:#d5d5d5; height: .25em" | '
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#c0cfe4" | ' .. header('preterite')
		text = text .. '\n| ich ' .. start .. tablelink(conj["1s_pret_indc"]) .. finish
		text = text .. '\n| wir ' .. start .. tablelink(conj["1p_pret_indc"]) .. finish
		text = text .. '\n! rowspan="3" style="background:#c0cfe4" | ' .. header('ii')
		text = text .. '\n| ich ' .. start .. tablelink(conj["1s_pret_subj"]) .. finish
		text = text .. '\n| wir ' .. start .. tablelink(conj["1p_pret_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. tablelink(conj["2s_pret_indc"]) .. finish
		text = text .. '\n| ihr ' .. start .. tablelink(conj["2p_pret_indc"]) .. finish
		text = text .. '\n| du ' .. start .. tablelink(conj["2s_pret_subj"]) .. finish
		text = text .. '\n| ihr ' .. start .. tablelink(conj["2p_pret_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| er ' .. tablelink(conj["3s_pret_indc"])
		text = text .. '\n| sie ' .. start .. tablelink(conj["3p_pret_indc"]) .. finish
		text = text .. '\n| er ' .. tablelink(conj["3s_pret_subj"])
		text = text .. '\n| sie ' .. start .. tablelink(conj["3p_pret_subj"]) .. finish
		text = text .. '\n|-'
		text = text .. '\n| colspan="6" style="background:#d5d5d5; height: .25em" | '
		text = text .. '\n|-'
		text = text .. '\n! style="background:#c0cfe4" | ' .. header('imperative')
		text = text .. '\n| '
		if type(conj["2s_imp"]) == "table" then
			text = text .. start .. link(conj["2s_imp"][1]) .. finish .. " (du)<br />" .. link(conj["2s_imp"][2]) .. finish
		else
			text = text .. start .. link(conj["2s_imp"]) .. finish
		end
		text = text .. ' (du)\n| ' .. start .. tablelink(conj["2p_imp"]) .. finish .. ' (ihr)'
		text = text .. '\n| colspan="3" style="background:#e0e0e0" |'
		text = text .. '\n|}'
		text = text .. '\n</div></div>'
		text = text .. '\n<div class="NavFrame" style="">'
		text = text .. '\n<div class="NavHead" style="" >รูปประกอบของ \'\'\'' .. conj["inf"] .. '\'\'\'</div>'
		text = text .. '\n<div class="NavContent">'
		text = text .. '\n{| border="1px solid #000000" style="border-collapse:collapse; background:#fafafa; text-align:center; width:100%" class="inflection-table"'
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#99cc99" | ' .. header('perfect')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#cfedcc; width:7em" | ' .. header('indicative')
		text = text .. '\n| ich ' .. start .. switchaux(aux,"habe","bin","habe " .. link(pp) .. finish .. " <br>ich " .. start .. "bin") .. ' ' .. link(pp) .. finish
		text = text .. '\n| wir ' .. start .. switchaux(aux,"haben","sind","haben " .. link(pp) .. finish .. " <br>wir " .. start .. "sind") .. ' ' .. link(pp) .. finish
		text = text .. '\n! rowspan="3" style="background:#cfedcc; width:7em" | ' .. header('subjunctive')
		text = text .. '\n| ich ' .. start .. switchaux(aux,"habe","sei","habe " .. link(pp) .. finish .. " <br>ich " .. start .. "sei") .. ' ' .. link(pp) .. finish
		text = text .. '\n| wir ' .. start .. switchaux(aux,"haben","seien","haben " .. link(pp) .. finish .. " <br>wir " .. start .. "seien") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. switchaux(aux,"hast","bist","hast " .. link(pp) .. finish .. " <br>du " .. start .. "bist") .. ' ' .. link(pp) .. finish
		text = text .. '\n| ihr ' .. start .. switchaux(aux,"habt","seid","habt " .. link(pp) .. finish .. " <br>ihr " .. start .. "seid") .. ' ' .. link(pp) .. finish
		text = text .. '\n| du ' .. start .. switchaux(aux,"habest","seist","habest " .. link(pp) .. finish .. " <br>du " .. start .. "seist") .. ' ' .. link(pp) .. finish
		text = text .. '\n| ihr ' .. start .. switchaux(aux,"habet","seiet","habet " .. link(pp) .. finish .. " <br>ihr " .. start .. "seiet") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n| er ' .. switchaux(aux,"hat","ist","hat " .. link(pp) .. " <br>er ist") .. ' ' .. link(pp)
		text = text .. '\n| sie ' .. start .. switchaux(aux,"haben","sind","haben " .. link(pp) .. " <br>sie sind") .. ' ' .. link(pp) .. finish
		text = text .. '\n| er ' .. switchaux(aux,"habe","sei","habe " .. link(pp) .. " <br>er sei") .. ' ' .. link(pp)
		text = text .. '\n| sie ' .. start .. switchaux(aux,"haben","seien","haben " .. link(pp) .. " <br>sie seien") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#99CC99" | ' .. header('pluperfect')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#cfedcc" | ' .. header('indicative')
		text = text .. '\n| ich ' .. start .. switchaux(aux,"hatte","war","hatte " .. link(pp) .. finish .. " <br>ich" .. start .. " war") .. ' ' .. link(pp) .. finish
		text = text .. '\n| wir ' .. start .. switchaux(aux,"hatten","waren","hatten " .. link(pp) .. finish .. " <br>wir" .. start .. " waren") .. ' ' .. link(pp) .. finish
		text = text .. '\n! rowspan="3" style="background:#cfedcc" | subjunctive'
		text = text .. '\n| ich ' .. start .. switchaux(aux,"hätte","wäre","hätte " .. link(pp) .. finish .. " <br>ich" .. start .. " wäre") .. ' ' .. link(pp) .. finish
		text = text .. '\n| wir ' .. start .. switchaux(aux,"hätten","wären","hätten " .. link(pp) .. finish .. " <br>wir" .. start .. " wären") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. switchaux(aux,"hattest","warst","hattest " .. link(pp) .. finish .. " <br>du" .. start .. " warst") .. ' ' .. link(pp) .. finish
		text = text .. '\n| ihr ' .. start .. switchaux(aux,"hattet","wart","hattet " .. link(pp) .. finish .. " <br>ihr" .. start .. " wart") .. ' ' .. link(pp) .. finish
		text = text .. '\n| du ' .. start .. switchaux(aux,"hättest","wärst","hättest " .. link(pp) .. finish .. " <br>du" .. start .. " wärst") .. ' ' .. link(pp) .. finish
		text = text .. '\n| ihr ' .. start .. switchaux(aux,"hättet","wärt","hättet " .. link(pp) .. finish .. " <br>ihr" .. start .. " wärt") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n| er ' .. switchaux(aux,"hatte","war","hatte " .. link(pp) .. " <br>er war") .. ' ' .. link(pp)
		text = text .. '\n| sie ' .. start .. switchaux(aux,"hatten","waren","hatten " .. link(pp) .. " <br>sie waren") .. ' ' .. link(pp) .. finish
		text = text .. '\n| er ' .. switchaux(aux,"hätte","wäre","hätte " .. link(pp) .. " <br>er wäre") .. ' ' .. link(pp)
		text = text .. '\n| sie ' .. start .. switchaux(aux,"hätten","wären","hätten " .. link(pp) .. " <br>sie wären") .. ' ' .. link(pp) .. finish
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#9999DF" | ' .. header('future_i')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('infinitive')
		text = text .. '\n| rowspan="3" colspan="2" | ' .. conj["inf"] .. ' werden'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('subjunctive_i')
		text = text .. '\n| ich ' .. start .. 'werde ' .. conj["inf"]
		text = text .. '\n| wir ' .. start .. 'werden ' .. conj["inf"]
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. 'werdest ' .. conj["inf"]
		text = text .. '\n| ihr ' .. start .. 'werdet ' .. conj["inf"]
		text = text .. '\n|-'
		text = text .. '\n| er werde ' .. conj["inf"]
		text = text .. '\n| sie werden ' .. conj["inf"]

		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#d5d5d5; height: .25em" |'
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('indicative')
		text = text .. '\n| ich ' .. start .. 'werde ' .. conj["inf"]
		text = text .. '\n| wir ' .. start .. 'werden ' .. conj["inf"]
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('subjunctive_ii')
		text = text .. '\n| ich ' .. start .. 'würde ' .. conj["inf"]
		text = text .. '\n| wir ' .. start .. 'würden ' .. conj["inf"]
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. 'wirst ' .. conj["inf"]
		text = text .. '\n| ihr ' .. start .. 'werdet ' .. conj["inf"]
		text = text .. '\n| du ' .. start .. 'würdest ' .. conj["inf"]
		text = text .. '\n| ihr ' .. start .. 'würdet ' .. conj["inf"]
		text = text .. '\n|-'
		text = text .. '\n| er wird ' .. conj["inf"]
		text = text .. '\n| sie werden ' .. conj["inf"]
		text = text .. '\n| er würde ' .. conj["inf"]
		text = text .. '\n| sie würden ' .. conj["inf"]
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#9999DF" | ' .. header('future_ii')
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('infinitive')
		text = text .. '\n| rowspan="3" colspan="2" | ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben werden <br>' .. link(pp) .. ' sein') .. ' werden'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('subjunctive_i')
		text = text .. '\n| ich ' .. start .. 'werde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ich ' .. start .. 'werde ' .. link(pp) .. ' sein')
		text = text .. '\n| wir ' .. start .. 'werden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> wir ' .. start .. 'werden ' .. link(pp) .. ' sein')
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. 'werdest ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> du ' .. start .. 'werdest ' .. link(pp) .. ' sein')
		text = text .. '\n| ihr ' .. start .. 'werdet ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ihr ' .. start .. 'werdet ' .. link(pp) .. ' sein')
		text = text .. '\n|-'
		text = text .. '\n| er werde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> er werde ' .. link(pp) .. ' sein')
		text = text .. '\n| sie werden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> sie werden ' .. link(pp) .. ' sein')
		text = text .. '\n|-'
		text = text .. '\n! colspan="6" style="background:#d5d5d5; height: .25em" |'
		text = text .. '\n|-'
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' ..header('indicative')
		text = text .. '\n| ich ' .. start .. 'werde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ich ' .. start .. 'werde ' .. link(pp) .. ' sein')
		text = text .. '\n| wir ' .. start .. 'werden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> wir ' .. start .. 'werden ' .. link(pp) .. ' sein')
		text = text .. '\n! rowspan="3" style="background:#ccccff" | ' .. header('subjunctive_ii')
		text = text .. '\n| ich ' .. start .. 'würde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ich ' .. start .. 'würde ' .. link(pp) .. ' sein')
		text = text .. '\n| wir ' .. start .. 'würden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> wir ' .. start .. 'würden ' .. link(pp) .. ' sein')
		text = text .. '\n|-'
		text = text .. '\n| du ' .. start .. 'wirst ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> du ' .. start .. 'wirst ' .. link(pp) .. ' sein')
		text = text .. '\n| ihr ' .. start .. 'werdet ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ihr ' .. start .. 'werdet ' .. link(pp) .. ' sein')
		text = text .. '\n| du ' .. start .. 'würdest ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> du ' .. start .. 'würdest ' .. link(pp) .. ' sein')
		text = text .. '\n| ihr ' .. start .. 'würdet ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> ihr ' .. start .. 'würdet ' .. link(pp) .. ' sein')
		text = text .. '\n|-'
		text = text .. '\n| er wird ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> er wird ' .. link(pp) .. ' sein')
		text = text .. '\n| sie werden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> sie werden ' .. link(pp) .. ' sein')
		text = text .. '\n| er würde ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> er würde ' .. link(pp) .. ' sein')
		text = text .. '\n| sie würden ' .. link(pp) .. ' ' .. switchaux(aux,'haben','sein','haben <br> sie würden ' .. link(pp) .. ' sein')
		text = text .. '\n|}</div></div>'
	end 
	return text
end

return export