--Name: Bank-Script
--Author: kevink98
--Date: 15.06.2016
--Version: 0.9

--Versionen: nothing
	
--Keine Änderung ohne meine Erlaubnis!
--No modification without my permission!

Bank = {};
Bank_directory = g_currentModDirectory;


print("Bank-Extension v0.9 loaded! Support on Marhu.net");
--g_currentMission.environment.currentDay

function Bank:appStore ()
	local appStore = {};
		appStore.version = 0.9;
		appStore.titel = "Bank";
		appStore.author = "kevink98";
		appStore.icon = createImageOverlay(FarmingTablet_directory.."hudsAll/huds_Appstore/shop_Bank.dds");
		appStore.price = 2500;
		appStore.description = {};
		appStore.description.z1 = "Mit dieser App können Sie Ihre Bankgeschäfte erledigen.";
		appStore.description.z2 = "Egal, ob Sie einen Kredit beantragen wollen oder Ihr erspartes Geld anlegen wollen,"
		appStore.description.z3 = "mit dieser App ist das kein Problem. Überzeugen Sie sich selber."
	return appStore;
end;

function Bank:loadBank ()
		
	--Anzeige Tage
	Bank.days = {};
	Bank.days[0] = "Sonntag";
	Bank.days[1] = "Montag";
	Bank.days[2] = "Dienstag";
	Bank.days[3] = "Mittwoch";
	Bank.days[4] = "Donnerstag";
	Bank.days[5] = "Freitag";
	Bank.days[6] = "Samstag";
	
	Bank.startpage = false;
	
	--Kredite Window
	
	Bank.kredit1 = {};
	Bank.kredit1.window = false;
	
	Bank.kredit1.show1 = false;
	Bank.kredit1.show2 = false;
	Bank.kredit1.show3 = false;
	
	Bank.kredit2 = {};
	Bank.kredit2.window = false;
	
	Bank.kredit2.show1 = false;
	Bank.kredit2.show2 = false;
	Bank.kredit2.show3 = false;
	Bank.kredit2.show4 = false;
	Bank.kredit2.show5 = false;
	
	Bank.kredit3 = {};
	Bank.kredit3.window = false;
	
	Bank.kredit3.show1 = false;
	Bank.kredit3.show2 = false;
	Bank.kredit3.show3 = false;
	Bank.kredit3.show4 = false;
	Bank.kredit3.show5 = false;
	Bank.kredit3.show6 = false;
	Bank.kredit3.show7 = false;
	
	Bank.kreditbewilligt = {};
	Bank.kreditbewilligt.window = false;
	h = 0;
	g = 0;
	
	Bank.anlegen = {}
	Bank.anlegen.angelegt = false;
	Bank.anlegen.gewinn = 0;
	Bank.anlegen.profit = 0;
	Bank.anlegen.show1 = false;
	Bank.anlegen.show2 = false;
	Bank.anlegen.show3 = false;
	Bank.anlegen.show4 = false;
	Bank.anlegen.show5 = false;
	Bank.anlegen.show6 = false;
	Bank.anlegen.show7 = false;
	Bank.anlegen.tagLauf = "";
	Bank.anlegen.tagLaufTag = 1;
	
end;

function Bank:loadXml(xml)
	g_currentMission.FarmingTablet.Bank = {};
	g_currentMission.FarmingTablet.Bank.Kredit1 = {};
	g_currentMission.FarmingTablet.Bank.Kredit1.active = getXMLBool(xml, "FarmingTablet.Bank.Kredit1.active");
	if g_currentMission.FarmingTablet.Bank.Kredit1.active then
		g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = getXMLInt(xml, "FarmingTablet.Bank.Kredit1.kredithoehe");
		g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay = getXMLInt(xml, "FarmingTablet.Bank.Kredit1.zinsenPerDay");
		g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = getXMLInt(xml, "FarmingTablet.Bank.Kredit1.laufzeit");
		g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt = getXMLInt(xml, "FarmingTablet.Bank.Kredit1.insgesamt");
		g_currentMission.FarmingTablet.Bank.Kredit1.tag = getXMLInt(xml, "FarmingTablet.Bank.Kredit1.tag");
		g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = getXMLInt(xml, "FarmingTablet.Bank.Kredit1.ueberzogen");
	else
		g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = 0;
		g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay = 0;
		g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = 1;
		g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt = 0;
		g_currentMission.FarmingTablet.Bank.Kredit1.tag = 0;
		g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = 0;
	end;
	g_currentMission.FarmingTablet.Bank.Kredit2 = {};
	g_currentMission.FarmingTablet.Bank.Kredit2.active = getXMLBool(xml, "FarmingTablet.Bank.Kredit2.active");
	if g_currentMission.FarmingTablet.Bank.Kredit2.active then
		g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = getXMLInt(xml, "FarmingTablet.Bank.Kredit2.kredithoehe");
		g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay = getXMLInt(xml, "FarmingTablet.Bank.Kredit2.zinsenPerDay");
		g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = getXMLInt(xml, "FarmingTablet.Bank.Kredit2.laufzeit");
		g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt = getXMLInt(xml, "FarmingTablet.Bank.Kredit2.insgesamt");
		g_currentMission.FarmingTablet.Bank.Kredit2.tag = getXMLInt(xml, "FarmingTablet.Bank.Kredit2.tag");
		g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = getXMLInt(xml, "FarmingTablet.Bank.Kredit2.ueberzogen");
	else
		g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = 50000;
		g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay = 0;
		g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = 1;
		g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt = 0;
		g_currentMission.FarmingTablet.Bank.Kredit2.tag = 0;
		g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 0;
	end;
	g_currentMission.FarmingTablet.Bank.Kredit3 = {};
	g_currentMission.FarmingTablet.Bank.Kredit3.active = getXMLBool(xml, "FarmingTablet.Bank.Kredit3.active");
	if g_currentMission.FarmingTablet.Bank.Kredit3.active then
		g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = getXMLInt(xml, "FarmingTablet.Bank.Kredit3.kredithoehe");
		g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay = getXMLInt(xml, "FarmingTablet.Bank.Kredit3.zinsenPerDay");
		g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = getXMLInt(xml, "FarmingTablet.Bank.Kredit3.laufzeit");
		g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt = getXMLInt(xml, "FarmingTablet.Bank.Kredit3.insgesamt");
		g_currentMission.FarmingTablet.Bank.Kredit3.tag = getXMLInt(xml, "FarmingTablet.Bank.Kredit3.tag");
		g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = getXMLInt(xml, "FarmingTablet.Bank.Kredit3.ueberzogen");
	else
		g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = 250000;
		g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay = 0;
		g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = 1;
		g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt = 0;
		g_currentMission.FarmingTablet.Bank.Kredit3.tag = 0;
		g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 0;
	end;
	g_currentMission.FarmingTablet.Bank.Anlegen = {};
	g_currentMission.FarmingTablet.Bank.Anlegen.on = getXMLBool(xml, "FarmingTablet.Bank.Anlegen.active");
	if g_currentMission.FarmingTablet.Bank.Anlegen.on then 
		g_currentMission.FarmingTablet.Bank.Anlegen.money = getXMLInt(xml, "FarmingTablet.Bank.Anlegen.money");
		g_currentMission.FarmingTablet.Bank.Anlegen.tage = getXMLInt(xml, "FarmingTablet.Bank.Anlegen.tage");
		g_currentMission.FarmingTablet.Bank.Anlegen.tag = getXMLInt(xml, "FarmingTablet.Bank.Anlegen.tag");
	else
		g_currentMission.FarmingTablet.Bank.Anlegen.money = 5000;
		g_currentMission.FarmingTablet.Bank.Anlegen.tage = 1;
		g_currentMission.FarmingTablet.Bank.Anlegen.tag = 0;
	end;
end;

function Bank:loadXmlFirst()
	g_currentMission.FarmingTablet.Bank = {};
	g_currentMission.FarmingTablet.Bank.Kredit1 = {};
	g_currentMission.FarmingTablet.Bank.Kredit1.active = false;
	g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = 0;
	g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay = 0;
	g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = 1;
	g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt = 0;
	g_currentMission.FarmingTablet.Bank.Kredit1.tag = 0;
	g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = 0;
	g_currentMission.FarmingTablet.Bank.Kredit2 = {};
	g_currentMission.FarmingTablet.Bank.Kredit2.active = false;
	g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = 50000;
	g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay = 0;
	g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = 1;
	g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt = 0;
	g_currentMission.FarmingTablet.Bank.Kredit2.tag = 0;
	g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 0;
	g_currentMission.FarmingTablet.Bank.Kredit3 = {};
	g_currentMission.FarmingTablet.Bank.Kredit3.active = false;
	g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = 250000;
	g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay = 0;
	g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = 1;
	g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt = 0;
	g_currentMission.FarmingTablet.Bank.Kredit3.tag = 0;
	g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 0;
	g_currentMission.FarmingTablet.Bank.Anlegen = {};
	g_currentMission.FarmingTablet.Bank.Anlegen.on = false;
	g_currentMission.FarmingTablet.Bank.Anlegen.money = 5000;
	g_currentMission.FarmingTablet.Bank.Anlegen.tage = 1;
	g_currentMission.FarmingTablet.Bank.Anlegen.tag = 0;
	
end;
function Bank:saveXml(xml)
	setXMLInt(xml, "FarmingTablet.Bank.Kredit1.kredithoehe", g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit1.zinsenPerDay", g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit1.laufzeit", g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit1.insgesamt", g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit1.tag", g_currentMission.FarmingTablet.Bank.Kredit1.tag);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit1.ueberzogen", g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen);
	setXMLBool(xml, "FarmingTablet.Bank.Kredit1.active", g_currentMission.FarmingTablet.Bank.Kredit1.active);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit2.kredithoehe", g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit2.zinsenPerDay", g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit2.laufzeit", g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit2.insgesamt", g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit2.tag", g_currentMission.FarmingTablet.Bank.Kredit2.tag);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit2.ueberzogen", g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen);
	setXMLBool(xml, "FarmingTablet.Bank.Kredit2.active", g_currentMission.FarmingTablet.Bank.Kredit2.active);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit3.kredithoehe", g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit3.zinsenPerDay", g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit3.laufzeit", g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit3.insgesamt", g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit3.tag", g_currentMission.FarmingTablet.Bank.Kredit3.tag);
	setXMLInt(xml, "FarmingTablet.Bank.Kredit3.ueberzogen", g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen);
	setXMLBool(xml, "FarmingTablet.Bank.Kredit3.active", g_currentMission.FarmingTablet.Bank.Kredit3.active);
	setXMLBool(xml, "FarmingTablet.Bank.Anlegen.active", g_currentMission.FarmingTablet.Bank.Anlegen.on);
	setXMLInt(xml, "FarmingTablet.Bank.Anlegen.money", g_currentMission.FarmingTablet.Bank.Kredit3.money);
	setXMLInt(xml, "FarmingTablet.Bank.Anlegen.tage", g_currentMission.FarmingTablet.Bank.Kredit3.tage);
	setXMLInt(xml, "FarmingTablet.Bank.Anlegen.tag", g_currentMission.FarmingTablet.Bank.Kredit3.tag);
end;

function Bank:StartscreenAppBank (posX, posY, isDown, button)
	local id = g_currentMission:findUserIdByConnection(connection);
	
	if Bank.kredit1.window == false and Bank.kredit2.window == false and Bank.kredit3.window == false then
		if g_currentMission.FarmingTablet.Bank.Kredit1.active == false and g_currentMission.FarmingTablet.Bank.Kredit2.active == false and g_currentMission.FarmingTablet.Bank.Kredit3.active == false then
			if posX > 0.091 and posX < 0.356 and posY > 0.516 and posY < 0.697 and isDown and button == 1 then
				Bank.kredit1.window = true;
				Bank.kredit2.window = false;
				Bank.kredit3.window = false;
			elseif posX > 0.370 and posX < 0.634 and posY > 0.516 and posY < 0.697 and isDown and button == 1 then
				Bank.kredit1.window = false;
				Bank.kredit2.window = true;
				Bank.kredit3.window = false;
			elseif posX > 0.647 and posX < 0.911 and posY > 0.516 and posY < 0.697 and isDown and button == 1 then
				Bank.kredit1.window = false;
				Bank.kredit2.window = false;
				Bank.kredit3.window = true;
			elseif	posX > 0.875 and posX < 0.902 and posY > 0.771 and posY < 0.812 and isDown and button == 1 then
				FarmingTablet.kz.app1 = false;
				Bank.kredit1.window = false;
				Bank.kredit2.window = false;
				Bank.kredit3.window = false;
			end;
		elseif g_currentMission.FarmingTablet.Bank.Kredit1.active == true and g_currentMission.FarmingTablet.Bank.Kredit2.active == false and g_currentMission.FarmingTablet.Bank.Kredit3.active == false then
			if	posX > 0.1 and posX < 0.901 and posY > 0.524 and posY < 0.558 and isDown and button == 1 then
				local money = g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe*-1;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				g_currentMission.FarmingTablet.Bank.Kredit1.active = false;
				g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = 0;
				g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = 1;
				g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = 0;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			end;
		elseif g_currentMission.FarmingTablet.Bank.Kredit2.active == true and g_currentMission.FarmingTablet.Bank.Kredit1.active == false and g_currentMission.FarmingTablet.Bank.Kredit3.active == false then
			if	posX > 0.1 and posX < 0.901 and posY > 0.524 and posY < 0.558 and isDown and button == 1 then
				local money = g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe*-1;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				g_currentMission.FarmingTablet.Bank.Kredit2.active = false;
				g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = 0;
				g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = 0;
				g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 0;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			end;
		elseif g_currentMission.FarmingTablet.Bank.Kredit3.active == true and g_currentMission.FarmingTablet.Bank.Kredit2.active == false and g_currentMission.FarmingTablet.Bank.Kredit1.active == false then
			if	posX > 0.1 and posX < 0.901 and posY > 0.524 and posY < 0.558 and isDown and button == 1 then
				local money = g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe*-1;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				g_currentMission.FarmingTablet.Bank.Kredit3.active = false;
				g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = 0;
				g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = 0;
				g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 0;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			end;
		end;
		if posX > 0.875 and posX < 0.902 and posY > 0.771 and posY < 0.812 and isDown and button == 1 then
			FarmingTablet.kz.app1 = false;
			Bank.kredit1.window = false;
			Bank.kredit2.window = false;
			Bank.kredit3.window = false;
		end;
	end;
	
	if Bank.kredit1.window == false and Bank.kredit2.window == false and Bank.kredit3.window == false and g_currentMission.FarmingTablet.Bank.Anlegen.on == false then
		if	posX > 0.629 and posX < 0.658 and posY > 0.407 and posY < 0.454 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Anlegen.money = g_currentMission.FarmingTablet.Bank.Anlegen.money - 5000;
			if g_currentMission.FarmingTablet.Bank.Anlegen.money < 0 then
				g_currentMission.FarmingTablet.Bank.Anlegen.money = 0;
			end;
		elseif posX > 0.843 and posX < 0.863 and posY > 0.407 and posY < 0.454 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Anlegen.money = g_currentMission.FarmingTablet.Bank.Anlegen.money + 5000;
		elseif posX > 0.629 and posX < 0.658 and posY > 0.318 and posY < 0.365 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Anlegen.tage = g_currentMission.FarmingTablet.Bank.Anlegen.tage - 1;
			if g_currentMission.FarmingTablet.Bank.Anlegen.tage < 1 then
				g_currentMission.FarmingTablet.Bank.Anlegen.tage = 1;
			end;
		elseif posX > 0.843 and posX < 0.863 and posY > 0.318 and posY < 0.365 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Anlegen.tage = g_currentMission.FarmingTablet.Bank.Anlegen.tage + 1;
			if g_currentMission.FarmingTablet.Bank.Anlegen.tage > 7 then
				g_currentMission.FarmingTablet.Bank.Anlegen.tage = 7;
			end;
		elseif posX > 0.616 and posX < 0.879 and posY > 0.228 and posY < 0.304 and isDown and button == 1 then
			if g_currentMission.FarmingTablet.Bank.Anlegen.money ~= 0 and g_currentMission.FarmingTablet.Bank.Anlegen.tage ~= 0 and g_currentMission.missionStats.money >= g_currentMission.FarmingTablet.Bank.Anlegen.money then
				local money = (g_currentMission.FarmingTablet.Bank.Anlegen.money-500)*-1;
				if g_currentMission.missionStats.money > money then
					if g_server ~= nil then
						g_currentMission:addMoney(money, id, "other");
					else
						g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
						MoneyEvent:sendEvent(g_currentMission.missionStats.money);
					end;
				end;
				g_currentMission.FarmingTablet.Bank.Anlegen.on = true;
				g_currentMission.FarmingTablet.Bank.Anlegen.tag = g_currentMission.environment.currentDay;
				Bank.anlegen.angelegt = true;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			end;
		end;
	end;
	
	if Bank.kredit1.window then
		if	posX > 0.628 and posX < 0.66 and posY > 0.435 and posY < 0.483 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe - 5000;
			if g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe < 0 then
				g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = 0;
			end;
		elseif	posX > 0.833 and posX < 0.863 and posY > 0.435 and posY < 0.483 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe + 5000;
			if g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe >= 50000 then
				g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = 50000;
			end;
		elseif	posX > 0.628 and posX < 0.66 and posY > 0.351 and posY < 0.394 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit - 1;
			if g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit < 0 then
				g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = 0;
			end;
		elseif	posX > 0.833 and posX < 0.863 and posY > 0.351 and posY < 0.394 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit + 1;
			if g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit >= 7 then
				g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = 7;
			end;
		elseif	posX > 0.616 and posX < 0.879 and posY > 0.228 and posY < 0.337 and isDown and button == 1 then
			if g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit ~= 0 and g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe ~= 0 then
				Bank.kreditbewilligt.window = true;
				Bank.kredit1.window = false;
				g_currentMission.FarmingTablet.Bank.Kredit1.active = true;
				g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = 0;
				g_currentMission.FarmingTablet.Bank.Kredit1.tag = g_currentMission.environment.currentDay;
				local money =  g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe - 500;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent();
			end;
		elseif	posX > 0.875 and posX < 0.902 and posY > 0.771 and posY < 0.812 and isDown and button == 1 then
			Bank.kredit1.window = false;
			Bank.kredit2.window = false;
			Bank.kredit3.window = false;
			g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = 0;
			g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = 1;
			BankEvent:sendEvent();
		end;
	end;
	if Bank.kredit2.window then
		if	posX > 0.628 and posX < 0.66 and posY > 0.435 and posY < 0.483 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe - 5000;
			if g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe < 50000 then
				g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = 50000;
			end;
		elseif	posX > 0.833 and posX < 0.863 and posY > 0.435 and posY < 0.483 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe + 5000;
			if g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe >= 250000 then
				g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = 250000;
			end;
		elseif	posX > 0.628 and posX < 0.66 and posY > 0.351 and posY < 0.394 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit - 1;
			if g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit < 0 then
				g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = 0;
			end;
		elseif	posX > 0.833 and posX < 0.863 and posY > 0.351 and posY < 0.394 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit + 1;
			if g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit >= 7 then
				g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = 7;
			end;
		elseif	posX > 0.616 and posX < 0.879 and posY > 0.228 and posY < 0.337 and isDown and button == 1 then
			if g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit ~= 0 and g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe ~= 0 then
				Bank.kreditbewilligt.window = true;
				Bank.kredit2.window = false;
				g_currentMission.FarmingTablet.Bank.Kredit2.active = true;
				g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 0;
				g_currentMission.FarmingTablet.Bank.Kredit2.tag = g_currentMission.environment.currentDay;
				local money =  g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe - 500;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent();
			end;
		elseif	posX > 0.875 and posX < 0.902 and posY > 0.771 and posY < 0.812 and isDown and button == 1 then
			Bank.kredit1.window = false;
			Bank.kredit2.window = false;
			Bank.kredit3.window = false;
			g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = 50000;
			g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = 1;
		end;
	end;
	if Bank.kredit3.window then
		if	posX > 0.628 and posX < 0.66 and posY > 0.435 and posY < 0.483 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe - 5000;
			if g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe < 250000 then
				g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = 250000;
			end;
		elseif	posX > 0.833 and posX < 0.863 and posY > 0.435 and posY < 0.483 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe + 5000;
			if g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe >= 1000000 then
				g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = 1000000;
			end;
		elseif	posX > 0.628 and posX < 0.66 and posY > 0.351 and posY < 0.394 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit - 1;
			if g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit < 0 then
				g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = 0;
			end;
		elseif	posX > 0.833 and posX < 0.863 and posY > 0.351 and posY < 0.394 and isDown and button == 1 then
			g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit + 1;
			if g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit >= 7 then
				g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = 7;
			end;
		elseif	posX > 0.616 and posX < 0.879 and posY > 0.228 and posY < 0.337 and isDown and button == 1 then
			if g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit ~= 0 and g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe ~= 0 then
				Bank.kreditbewilligt.window = true;
				Bank.kredit3.window = false;
				g_currentMission.FarmingTablet.Bank.Kredit3.active = true;
				g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 0;
				g_currentMission.FarmingTablet.Bank.Kredit3.tag = g_currentMission.environment.currentDay;
				local money =  g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe - 500;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent();
			end;
		elseif	posX > 0.875 and posX < 0.902 and posY > 0.771 and posY < 0.812 and isDown and button == 1 then
			Bank.kredit1.window = false;
			Bank.kredit2.window = false;
			Bank.kredit3.window = false;
			g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = 250000;
			g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = 1;
		end;
	end;
	
end;

function Bank:updateBank (dt) 

	if g_currentMission.environment.currentHour < 10 then
		Bank.uhr1 = tostring("0"..g_currentMission.environment.currentHour);
	else
		Bank.uhr1 = tostring(g_currentMission.environment.currentHour);
	end;
	if g_currentMission.environment.currentMinute < 10 then
		Bank.uhr2 = tostring("0"..g_currentMission.environment.currentMinute);
	else
		Bank.uhr2 = tostring(g_currentMission.environment.currentMinute);
	end;
		
	if g_currentMission.FarmingTablet.Bank.Anlegen.on then
		if (g_currentMission.FarmingTablet.Bank.Anlegen.tag + g_currentMission.FarmingTablet.Bank.Anlegen.tage) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 then
			g_currentMission.missionStats.money = g_currentMission.missionStats.money + (g_currentMission.FarmingTablet.Bank.Anlegen.money * 0.03) + g_currentMission.FarmingTablet.Bank.Anlegen.money;
			local money = (g_currentMission.FarmingTablet.Bank.Anlegen.money * 0.03) + g_currentMission.FarmingTablet.Bank.Anlegen.money;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.FarmingTablet.Bank.Anlegen.on = false;
			g_currentMission.FarmingTablet.Bank.Anlegen.money = 0;
			g_currentMission.FarmingTablet.Bank.Anlegen.tag = g_currentMission.environment.currentDay;
			g_currentMission.FarmingTablet.Bank.Anlegen.tage = 1;
			BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
		else
			if (g_currentMission.FarmingTablet.Bank.Anlegen.tag +1) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and Bank.anlegen.show1 == false then
				Bank.anlegen.show1 = true;
				local money = g_currentMission.FarmingTablet.Bank.Anlegen.money * 0.03;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			elseif (g_currentMission.FarmingTablet.Bank.Anlegen.tag +2) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and Bank.anlegen.show2 == false then
				Bank.anlegen.show2 = true;
				local money = g_currentMission.FarmingTablet.Bank.Anlegen.money * 0.03;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			elseif (g_currentMission.FarmingTablet.Bank.Anlegen.tag +3) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and Bank.anlegen.show3 == false then
				Bank.anlegen.show3 = true;
				local money = g_currentMission.FarmingTablet.Bank.Anlegen.money * 0.03;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			elseif (g_currentMission.FarmingTablet.Bank.Anlegen.tag +4) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and Bank.anlegen.show4 == false then
				Bank.anlegen.show4 = true;
				local money = g_currentMission.FarmingTablet.Bank.Anlegen.money * 0.03;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			elseif (g_currentMission.FarmingTablet.Bank.Anlegen.tag +5) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and Bank.anlegen.show5 == false then
				Bank.anlegen.show5 = true;
				local money = g_currentMission.FarmingTablet.Bank.Anlegen.money * 0.03;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			elseif (g_currentMission.FarmingTablet.Bank.Anlegen.tag +6) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and Bank.anlegen.show6 == false then
				Bank.anlegen.show6 = true;
				local money = g_currentMission.FarmingTablet.Bank.Anlegen.money * 0.03;
				if g_server ~= nil then
					g_currentMission:addMoney(money, id, "other");
				else
					g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
					MoneyEvent:sendEvent(g_currentMission.missionStats.money);
				end;
				BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
			end;
		end;
	end;
	Bank.anlegen.gewinn = g_currentMission.FarmingTablet.Bank.Anlegen.money*0.03*g_currentMission.FarmingTablet.Bank.Anlegen.tage;
	Bank.anlegen.profit = Bank.anlegen.gewinn/g_currentMission.FarmingTablet.Bank.Anlegen.tage;
	Bank.anlegen.tagLauf = Bank.days[math.mod(string.format("%.f", g_currentMission.FarmingTablet.Bank.Anlegen.tag)+g_currentMission.FarmingTablet.Bank.Anlegen.tage, 7)];
	Bank.anlegen.tagLaufTag = string.format("%.f", g_currentMission.FarmingTablet.Bank.Anlegen.tag+g_currentMission.FarmingTablet.Bank.Anlegen.tage);
	
	--Kredit1 berechnung:
	
	g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay = g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe * 0.025;
	g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt = g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe+(g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay*g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit)+500;
	g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay = g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe * 0.02;
	g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt = g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe+(g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay*g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit)+500;
	g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay = g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe * 0.015;
	g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt = g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe+(g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay*g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit)+500;
	
	local id = g_currentMission:findUserIdByConnection(connection);	
	
	if g_currentMission.FarmingTablet.Bank.Kredit1.active then
		if g_currentMission.FarmingTablet.Bank.Kredit1.tag + g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen == 0 and Bank.kredit1.show1 == false then
			g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = 1;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe* 0.07)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe * 0.07).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);
			
			Bank.kredit1.show1 = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit1.tag+(g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit+1) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen == 1 and Bank.kredit1.show2 == false then
			g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = 2;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe* 0.07)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money + money);
			end;
			
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 2. Mal überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe * 0.07).."€ Überziehnungszinsen gezahlt! Letzte Möglichkeit bis morgen 12.00 Uhr!"),0,false);
			
			Bank.kredit1.show2  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit1.tag+(g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit+1) < g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen == 2 and Bank.kredit1.show3 == false then
			local money = (10000 + g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe)*-1;
			
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Strafe von 10.000€ gezahlt. Zudem wurde der Kredit ("..g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe.."€) von Ihrem Konto abgehoben! "),0,false);
			Bank.kredit1.show3 = true;
			g_currentMission.FarmingTablet.Bank.Kredit1.active = false;
			g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = 0;
			g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = 0;
			g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = 0;
			BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
		end;
	elseif g_currentMission.FarmingTablet.Bank.Kredit2.active then
		if g_currentMission.FarmingTablet.Bank.Kredit2.tag+g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen == 0 and Bank.kredit2.show1 == false then
			g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 1;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe* 0.05)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe * 0.08).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);

			Bank.kredit2.show1 = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit2.tag+(g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit+1) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen == 1 and Bank.kredit2.show2 == false then
			g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 2;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe* 0.05)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 2. Mal überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe * 0.08).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);

			Bank.kredit2.show2  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit2.tag+(g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit+2) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen == 2 and Bank.kredit2.show3 == false then
			g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 3;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe* 0.05)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 3. Mal überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe * 0.10).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);

			Bank.kredit2.show3  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit2.tag+(g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit+3) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen == 3 and Bank.kredit2.show4 == false then
			g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 3;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe* 0.05)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 4. Mal überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe * 0.10).."€ Überziehnungszinsen gezahlt! Letzte Möglichkeit bis morgen 12.00 Uhr!"),0,false);

			Bank.kredit2.show4  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit2.tag+(g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit+3) < g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen == 3 and Bank.kredit2.show5 == false then
			local money = (g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe+10000)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Strafe von 10.000€ gezahlt. Zudem wurde der Kredit ("..g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe.."€) von Ihrem Konto abgehoben! "),0,false);
			Bank.kredit2.show4 = true;
			g_currentMission.FarmingTablet.Bank.Kredit2.active = false;
			g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = 50000;
			g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = 0;
			g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = 0;
			BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
		end;
	elseif g_currentMission.FarmingTablet.Bank.Kredit3.active then
		if g_currentMission.FarmingTablet.Bank.Kredit3.tag+g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen == 0 and Bank.kredit3.show1 == false then
			g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 1;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe* 0.03)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe * 0.03).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);

			Bank.kredit3.show1 = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit3.tag+(g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit+1) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen == 1 and Bank.kredit3.show2 == false then
			g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 2;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe* 0.03)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 2. Mal überzogen! Sie zahlen ab sofort ein Überziehnungszins von 5% "..(g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe * 0.03).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);

			Bank.kredit3.show2  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit3.tag+(g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit+2) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen == 2 and Bank.kredit3.show3 == false then
			g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 3;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe* 0.05)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 3. Mal überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe * 0.05).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);

			Bank.kredit3.show3  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit3.tag+(g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit+3) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen == 3 and Bank.kredit3.show4 == false then
			g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 4;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe* 0.05)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 4. Mal überzogen! Sie zahlen ab sofort ein Überziehnungszins von 9% "..(g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe * 0.05).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);

			Bank.kredit3.show4  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit3.tag+(g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit+4) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen == 4 and Bank.kredit3.show5 == false then
			g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 5;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe* 0.09)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 5. Mal überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe * 0.09).."€ Überziehnungszinsen gezahlt! Zahlen Sie bis morgen 12.00 Uhr ihren Kredit vollständig zurück!"),0,false);

			g_currentMission.FarmingTablet.Bank.Kredit3.show5  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit3.tag+(g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit+5) == g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen == 5 and Bank.kredit3.show6 == false then
			g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 5;
			local money = (g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe* 0.09)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Sie haben Ihren Kredit zum 6. Mal überzogen! "..(g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe * 0.09).."€ Überziehnungszinsen gezahlt! Letzte Möglichkeit bis morgen 12.00 Uhr!"),0,false);

			Bank.kredit3.show6  = true;
		elseif g_currentMission.FarmingTablet.Bank.Kredit3.tag+(g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit+5) < g_currentMission.environment.currentDay and g_currentMission.environment.currentHour == 12 and g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen == 5 and Bank.kredit3.show7 == false then
			local money = (g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe+10000)*-1;
			if g_server ~= nil then
				g_currentMission:addMoney(money, id, "other");
			else
				g_currentMission.missionStats.money = g_currentMission.missionStats.money + money;
				MoneyEvent:sendEvent(g_currentMission.missionStats.money);
			end;
			g_currentMission.inGameMessage:showMessage(tostring("Kredit überzogen!"),tostring("Strafe von 10.000€ gezahlt. Zudem wurde der Kredit ("..g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe.."€) von Ihrem Konto abgehoben! "),0,false);
			Bank.kredit3.show7 = true;
			g_currentMission.FarmingTablet.Bank.Kredit3.active = false;
			g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = 250000;
			g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = 1;
			g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = 0;
			BankEvent:sendEvent(g_currentMission.FarmingTablet.Bank);
		end;
	end;
end;

function Bank:drawBank ()
	renderOverlay(FarmingTablet.overlay.background2, 0.01, 0.01, 1, 1.5);
	renderOverlay(FarmingTablet.overlay.background, 0.01, 0.01, 1, 1.5);
	--renderOverlay(FarmingTablet.overlay.speichern, 0.868, 0.766, 0.032, 0.04);
	if Bank.kreditbewilligt.window == false then
		renderOverlay(FarmingTablet.overlay.abbrechen, 0.868, 0.766, 0.04, 0.05);
	end;
	setTextColor(1,1,1,1);
	renderText(0.795, 0.833, 0.03, tostring(Bank.uhr1..":"..Bank.uhr2));
	renderText(0.603, 0.833, 0.03, tostring(Bank.days[math.mod(string.format("%f", g_currentMission.environment.currentDay), 7)].."  ("..string.format("%.f", string.format("%f", g_currentMission.environment.currentDay))..". Tag)"));
	setTextColor(0,0,0,1);
	if Bank.kredit1.window == false and Bank.kredit2.window == false and Bank.kredit3.window == false and g_currentMission.FarmingTablet.Bank.Kredit1.active == false and g_currentMission.FarmingTablet.Bank.Kredit2.active == false and g_currentMission.FarmingTablet.Bank.Kredit3.active == false 
	and Bank.kreditbewilligt.window == false then
		renderOverlay(FarmingTablet.overlay.startpage, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.strich, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.prozent_1, 0.273, 0.618, 0.08, 0.08);
		renderOverlay(FarmingTablet.overlay.prozent_2, 0.556, 0.618, 0.08, 0.08);
		renderOverlay(FarmingTablet.overlay.prozent_3, 0.834, 0.618, 0.08, 0.08);
		setTextColor(1,1,1,1);
		renderText(0.093, 0.776, 0.032, tostring("Willkommen bei Ihrer Bauern-Bank!"));
		renderText(0.093, 0.776, 0.032, tostring("Willkommen bei Ihrer Bauern-Bank!"));
		setTextColor(0,0,0,1);
		renderText(0.091, 0.715, 0.03, tostring("Kredit aufnehmen:"));
		renderText(0.091, 0.448, 0.03, tostring("Geld anlegen:"));
		renderText(0.091, 0.715, 0.03, tostring("Kredit aufnehmen:"));
		renderText(0.091, 0.448, 0.03, tostring("Geld anlegen:"));
		renderText(0.142, 0.653, 0.03, tostring("Kredit 1"));
		renderText(0.142, 0.653, 0.03, tostring("Kredit 1"));
		renderText(0.102, 0.604, 0.025, tostring("Bis zu 50.000 €"));
		renderText(0.102, 0.561, 0.025, tostring("Laufzeit bis 1 Woche"));
		renderText(0.413, 0.653, 0.03, tostring("Kredit 2"));
		renderText(0.413, 0.653, 0.03, tostring("Kredit 2"));
		renderText(0.379, 0.604, 0.025, tostring("Von 50.000 € bis 250.000 €"));
		renderText(0.379, 0.561, 0.025, tostring("Laufzeit bis 2 Wochen"));
		renderText(0.690, 0.653, 0.03, tostring("Kredit 3"));
		renderText(0.690, 0.653, 0.03, tostring("Kredit 3"));
		renderText(0.652, 0.604, 0.025, tostring("Von 250.000€ bis 1.000.000 €"));
		renderText(0.652, 0.561, 0.025, tostring("Laufzeit bis 4 Wochen"));
		
	end;
	--Geld anlegen
	if Bank.kredit1.window == false and Bank.kredit2.window == false and Bank.kredit3.window == false and Bank.kreditbewilligt.window == false then
			renderText(0.102, 0.41, 0.025, tostring("Anlagehöhe: "..g_currentMission.FarmingTablet.Bank.Anlegen.money.."€"));
			renderText(0.102, 0.367, 0.025, tostring("Laufzeit: bis "..Bank.anlegen.tagLauf.." (Tag "..Bank.anlegen.tagLaufTag.."), 12.00 Uhr"));
			renderText(0.102, 0.324, 0.025, tostring("Zinsen: 3%")); 
			renderText(0.102, 0.281, 0.025, tostring("Täglicher Profit: "..Bank.anlegen.profit.."€"));
			renderText(0.102, 0.238, 0.025, tostring("Gewinn: "..Bank.anlegen.gewinn.."€"));
		if g_currentMission.FarmingTablet.Bank.Anlegen.on == false then
			renderOverlay(FarmingTablet.overlay.aufnehmen2, 0.01, 0.01, 1, 1.5);
			renderText(0.676, 0.453, 0.025, tostring("Anlagehöhe:")); 
			renderText(0.676, 0.371, 0.025, tostring("Tage:")); 
			renderText(0.676, 0.453, 0.025, tostring("Anlagehöhe:")); 
			renderText(0.676, 0.371, 0.025, tostring("Tage:")); 
			renderText(0.676, 0.413, 0.025, tostring(g_currentMission.FarmingTablet.Bank.Anlegen.money.."€")); 
			renderText(0.676, 0.331, 0.025, tostring(g_currentMission.FarmingTablet.Bank.Anlegen.tage.." Tage")); 
			renderText(0.676, 0.271, 0.03, tostring(g_currentMission.FarmingTablet.Bank.Anlegen.money.."€ für"));
			renderText(0.676, 0.24, 0.03, tostring(g_currentMission.FarmingTablet.Bank.Anlegen.tage.." Tage anlegen"));
			renderText(0.676, 0.271, 0.03, tostring(g_currentMission.FarmingTablet.Bank.Anlegen.money));
			renderText(0.676, 0.24, 0.03, tostring(g_currentMission.FarmingTablet.Bank.Anlegen.tage));
		end;
		if Bank.anlegen.angelegt then
			renderText(0.55, 0.448, 0.028, tostring("Bearbeitungsgebühr von 500€ gezahlt"));
			if g == 150 then
				Bank.anlegen.angelegt = false;
				g = 0;
			else 
				g = g+1;
			end;
		end;
	end;
	
	--Anzeige, wenn 1 Kredikt aktiv	
	if Bank.kredit1.window == false and Bank.kredit2.window == false and Bank.kredit3.window == false and Bank.kreditbewilligt.window == false and g_currentMission.FarmingTablet.Bank.Kredit1.active and g_currentMission.FarmingTablet.Bank.Kredit2.active == false and g_currentMission.FarmingTablet.Bank.Kredit3.active == false then
		renderOverlay(FarmingTablet.overlay.strich, 0.01, 0.01, 1, 1.5);
		renderText(0.091, 0.448, 0.03, tostring("Geld anlegen:"));
		renderText(0.091, 0.448, 0.03, tostring("Geld anlegen:"));
		renderText(0.091, 0.715, 0.03, tostring("Laufender Kredit:"));
		renderText(0.091, 0.715, 0.03, tostring("Laufender Kredit:"));
		renderText(0.099, 0.652, 0.025, tostring("Art des Kredites: Kredit 1 von "..g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe.."€"));
		renderText(0.099, 0.615, 0.025, tostring("Laufzeit: bis "..Bank.days[math.mod(string.format("%f", g_currentMission.FarmingTablet.Bank.Kredit1.tag)+g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit, 7)].." (Tag "..(string.format("%f", g_currentMission.FarmingTablet.Bank.Kredit1.tag)+g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit).."), 12.00 Uhr"));
		renderText(0.099, 0.578, 0.025, tostring("Zinsen/Tag (2.5%): "..g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay.."€"));
		renderText(0.099, 0.652, 0.025, tostring("Art des Kredites:"));
		renderText(0.099, 0.615, 0.025, tostring("Laufzeit:"));
		renderText(0.099, 0.578, 0.025, tostring("Zinsen/Tag (2.5%):"));
		
		renderText(0.509, 0.652, 0.025, tostring("Überziehungszeitraum: 2 Tage"));
		renderText(0.509, 0.615, 0.025, tostring("Überziehungszins: 7%/Tag"));
		renderText(0.509, 0.578, 0.025, tostring("Tage bisher überzogen: "..g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen));
		
		renderText(0.509, 0.652, 0.025, tostring("Überziehungszeitraum:"));
		renderText(0.509, 0.615, 0.025, tostring("Überziehungszins:"));
		renderText(0.509, 0.578, 0.025, tostring("Tage bisher überzogen:"));
		
		renderText(0.22, 0.527, 0.03, tostring("Kredit zurückzahlen ("..g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe.."€ muss auf dem Konto vorhanden sein.)"));
		if g_currentMission.FarmingTablet.Bank.Kredit1.active then
			renderOverlay(FarmingTablet.overlay.startpage2, 0.01, 0.01, 1, 1.5);
		
		end;
		
	elseif Bank.kredit1.window == false and Bank.kredit2.window == false and Bank.kredit3.window == false and Bank.kreditbewilligt.window == false and g_currentMission.FarmingTablet.Bank.Kredit1.active == false and g_currentMission.FarmingTablet.Bank.Kredit2.active and g_currentMission.FarmingTablet.Bank.Kredit3.active == false then
		renderOverlay(FarmingTablet.overlay.strich, 0.01, 0.01, 1, 1.5);
		renderText(0.091, 0.448, 0.03, tostring("Geld anlegen:"));
		renderText(0.091, 0.448, 0.03, tostring("Geld anlegen:"));
		renderText(0.091, 0.715, 0.03, tostring("Laufender Kredit:"));
		renderText(0.091, 0.715, 0.03, tostring("Laufender Kredit:"));
		renderText(0.099, 0.652, 0.025, tostring("Art des Kredites: Kredit 2 von "..g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe.."€"));
		renderText(0.099, 0.615, 0.025, tostring("Laufzeit: bis "..Bank.days[math.mod(string.format("%f", g_currentMission.FarmingTablet.Bank.Kredit2.tag)+g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit, 7)].." (Tag "..(string.format("%f", g_currentMission.FarmingTablet.Bank.Kredit2.tag)+g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit).."), 12.00 Uhr"));
		renderText(0.099, 0.578, 0.025, tostring("Zinsen/Tag (2.0%): "..g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay.."€"));
		renderText(0.099, 0.652, 0.025, tostring("Art des Kredites:"));
		renderText(0.099, 0.615, 0.025, tostring("Laufzeit:"));
		renderText(0.099, 0.578, 0.025, tostring("Zinsen/Tag (2.0%):"));
		
		renderText(0.509, 0.652, 0.025, tostring("Überziehungszeitraum: 4 Tage"));
		renderText(0.509, 0.652, 0.025, tostring("Überziehungszeitraum:"));
		renderText(0.509, 0.615, 0.025, tostring("Überziehungszins: 7%/Tag"));
		renderText(0.509, 0.615, 0.025, tostring("Überziehungszins:"));
		renderText(0.509, 0.578, 0.025, tostring("Tage bisher überzogen: "..g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen));
		renderText(0.509, 0.578, 0.025, tostring("Tage bisher überzogen:"));
		
		renderText(0.22, 0.527, 0.03, tostring("Kredit zurückzahlen ("..g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe.."€ muss auf dem Konto vorhanden sein.)"));
		if g_currentMission.FarmingTablet.Bank.Kredit2.active then
			renderOverlay(FarmingTablet.overlay.startpage2, 0.01, 0.01, 1, 1.5);
		
		end;
	elseif Bank.kredit1.window == false and Bank.kredit2.window == false and Bank.kredit3.window == false and Bank.kreditbewilligt.window == false and g_currentMission.FarmingTablet.Bank.Kredit1.active == false and g_currentMission.FarmingTablet.Bank.Kredit2.active == false and g_currentMission.FarmingTablet.Bank.Kredit3.active then
		renderOverlay(FarmingTablet.overlay.strich, 0.01, 0.01, 1, 1.5);
		renderText(0.091, 0.448, 0.03, tostring("Geld anlegen:"));
		renderText(0.091, 0.448, 0.03, tostring("Geld anlegen:"));
		renderText(0.091, 0.715, 0.03, tostring("Laufender Kredit:"));
		renderText(0.091, 0.715, 0.03, tostring("Laufender Kredit:"));
		renderText(0.099, 0.652, 0.025, tostring("Art des Kredites: Kredit 3 von "..g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe.."€"));
		renderText(0.099, 0.615, 0.025, tostring("Laufzeit: bis "..Bank.days[math.mod(string.format("%f", g_currentMission.FarmingTablet.Bank.Kredit3.tag)+g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit, 7)].." (Tag "..(string.format("%f", g_currentMission.FarmingTablet.Bank.Kredit3.tag)+g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit).."), 12.00 Uhr"));
		renderText(0.099, 0.578, 0.025, tostring("Zinsen/Tag (1.5%): "..g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay.."€"));
		renderText(0.099, 0.652, 0.025, tostring("Art des Kredites:"));
		renderText(0.099, 0.615, 0.025, tostring("Laufzeit:"));
		renderText(0.099, 0.578, 0.025, tostring("Zinsen/Tag (1.5%):"));
		
		renderText(0.509, 0.652, 0.025, tostring("Überziehungszeitraum: 6 Tage"));
		renderText(0.509, 0.615, 0.025, tostring("Überziehungszins: 7%/Tag"));
		renderText(0.509, 0.578, 0.025, tostring("Tage bisher überzogen: "..g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen));
		
		renderText(0.509, 0.652, 0.025, tostring("Überziehungszeitraum:"));
		renderText(0.509, 0.615, 0.025, tostring("Überziehungszins:"));
		renderText(0.509, 0.578, 0.025, tostring("Tage bisher überzogen:"));
		
		renderText(0.22, 0.527, 0.03, tostring("Kredit zurückzahlen ("..g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe.."€ muss auf dem Konto vorhanden sein.)"));
		if g_currentMission.FarmingTablet.Bank.Kredit3.active then
			renderOverlay(FarmingTablet.overlay.startpage2, 0.01, 0.01, 1, 1.5);
		
		end;
		
	end;
	
	
	if Bank.kredit1.window and Bank.kreditbewilligt.window == false then
		renderOverlay(FarmingTablet.overlay.aufnehmen, 0.01, 0.01, 1, 1.5);
		setTextColor(1,1,1,1);
		renderText(0.093, 0.776, 0.032, tostring("Sie haben Kredit 1 ausgewählt"));
		renderText(0.093, 0.776, 0.032, tostring("Sie haben Kredit 1 ausgewählt"));
		setTextColor(0,0,0,1);
		
		renderText(0.093, 0.718, 0.03, tostring("Kreditdetails:"));
		renderText(0.093, 0.718, 0.03, tostring("Kreditdetails:"));
		renderText(0.676, 0.298, 0.03, tostring("Kredit von "..g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe.."€ über"));
		renderText(0.676, 0.24, 0.03, tostring(g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit.." Tage aufnehmen"));
		renderText(0.68, 0.474, 0.03, tostring("Kredithöhe"));
		renderText(0.68, 0.401, 0.03, tostring("Laufzeit"));
		renderText(0.68, 0.474, 0.03, tostring("Kredithöhe"));
		renderText(0.68, 0.401, 0.03, tostring("Laufzeit"));
		renderText(0.093, 0.681, 0.025, tostring("Laufzeit: max. 1 Woche"));
		renderText(0.407, 0.681, 0.025, tostring("Überziehungszeitraum: 2 Tage"));
		renderText(0.093, 0.638, 0.025, tostring("Größe Kredit: max. 50.000€"));
		renderText(0.407, 0.638, 0.025, tostring("Überziehungszins: ".."7%".."/Tag"));
		renderText(0.093, 0.595, 0.025, tostring("Zinsen/Tag: 2.5%"));
		renderText(0.093, 0.552, 0.025, tostring("Bearbeitungsgebühr (einmalig): 500€"));
		renderText(0.093, 0.509, 0.025, tostring("----------------------------------------------------"));
		renderText(0.093, 0.45, 0.03, tostring("Neuer Kredit beantragen:"));
		renderText(0.093, 0.45, 0.03, tostring("Neuer Kredit beantragen:"));
		renderText(0.093, 0.413, 0.025, tostring("Höhe des Kredits: "..g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe.."€"));
		renderText(0.093, 0.370, 0.025, tostring("Tägliche Zinsen: "..g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay.."€"));
		renderText(0.093, 0.327, 0.025, tostring("Laufzeit des Kredites: "..g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit.." Tage"));
		renderText(0.093, 0.284, 0.025, tostring("Insgesamt: "..g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt.."€"));
		
		renderText(0.701, 0.444, 0.035, tostring(g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe.."€"));
		renderText(0.701, 0.351, 0.035, tostring(g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit.." Tag(e)"));
				
	elseif Bank.kredit2.window and Bank.kreditbewilligt.window == false then
		renderOverlay(FarmingTablet.overlay.aufnehmen, 0.01, 0.01, 1, 1.5);
		setTextColor(1,1,1,1);
		renderText(0.093, 0.776, 0.032, tostring("Sie haben Kredit 2 ausgewählt"));
		renderText(0.093, 0.776, 0.032, tostring("Sie haben Kredit 2 ausgewählt"));
		setTextColor(0,0,0,1);
		
		renderText(0.093, 0.718, 0.03, tostring("Kreditdetails:"));
		renderText(0.093, 0.718, 0.03, tostring("Kreditdetails:"));
		renderText(0.676, 0.298, 0.03, tostring("Kredit von "..g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe.."€ über"));
		renderText(0.676, 0.24, 0.03, tostring(g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit.." Tage aufnehmen"));
		renderText(0.68, 0.474, 0.03, tostring("Kredithöhe"));
		renderText(0.68, 0.401, 0.03, tostring("Laufzeit"));
		renderText(0.68, 0.474, 0.03, tostring("Kredithöhe"));
		renderText(0.68, 0.401, 0.03, tostring("Laufzeit"));
		renderText(0.093, 0.681, 0.025, tostring("Laufzeit: max. 2 Woche"));
		renderText(0.407, 0.681, 0.025, tostring("Überziehnungszeitraum: 4 Tage"));
		renderText(0.093, 0.638, 0.025, tostring("Größe Kredit: 50.000€ bis 250.000€"));
		renderText(0.407, 0.638, 0.025, tostring("Überziehnungszins: 8%/Tag 	"));
		renderText(0.093, 0.595, 0.025, tostring("Zinsen/Tag: 3.5%"));
		renderText(0.093, 0.552, 0.025, tostring("Bearbeitungsgebühr (einmalig): 500€"));
		renderText(0.093, 0.509, 0.025, tostring("----------------------------------------------------"));
		renderText(0.093, 0.45, 0.03, tostring("Neuer Kredit beantragen:"));
		renderText(0.093, 0.45, 0.03, tostring("Neuer Kredit beantragen:"));
		renderText(0.093, 0.413, 0.025, tostring("Höhe des Kredits: "..g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe.."€"));
		renderText(0.093, 0.370, 0.025, tostring("Tägliche Zinsen: "..g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay.."€"));
		renderText(0.093, 0.327, 0.025, tostring("Laufzeit des Kredites: "..g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit.." Tage"));
		renderText(0.093, 0.284, 0.025, tostring("Insgesamt: "..g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt.."€"));
		
		renderText(0.701, 0.444, 0.035, tostring(g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe.."€"));
		renderText(0.701, 0.351, 0.035, tostring(g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit.." Tag(e)"));
	elseif Bank.kredit3.window and Bank.kreditbewilligt.window == false then
		renderOverlay(FarmingTablet.overlay.aufnehmen, 0.01, 0.01, 1, 1.5);
		setTextColor(1,1,1,1);
		renderText(0.093, 0.776, 0.032, tostring("Sie haben Kredit 3 ausgewählt"));
		renderText(0.093, 0.776, 0.032, tostring("Sie haben Kredit 3 ausgewählt"));
		setTextColor(0,0,0,1);
		
		renderText(0.093, 0.718, 0.03, tostring("Kreditdetails:"));
		renderText(0.093, 0.718, 0.03, tostring("Kreditdetails:"));
		renderText(0.676, 0.298, 0.03, tostring("Kredit von "..g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe.."€ über"));
		renderText(0.676, 0.24, 0.03, tostring(g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit.." Tage aufnehmen"));
		renderText(0.68, 0.474, 0.03, tostring("Kredithöhe"));
		renderText(0.68, 0.401, 0.03, tostring("Laufzeit"));
		renderText(0.68, 0.474, 0.03, tostring("Kredithöhe"));
		renderText(0.68, 0.401, 0.03, tostring("Laufzeit"));
		renderText(0.093, 0.681, 0.025, tostring("Laufzeit: max. 2 Woche"));
		renderText(0.407, 0.681, 0.025, tostring("Überziehnungszeitraum: 6 Tage"));
		renderText(0.093, 0.638, 0.025, tostring("Größe Kredit: 250.000€ bis 1.000.000€"));
		renderText(0.407, 0.638, 0.025, tostring("Überziehnungszins: 8%/Tag 	"));
		renderText(0.093, 0.595, 0.025, tostring("Zinsen/Tag: 5.0%"));
		renderText(0.093, 0.552, 0.025, tostring("Bearbeitungsgebühr (einmalig): 500€"));
		renderText(0.093, 0.509, 0.025, tostring("----------------------------------------------------"));
		renderText(0.093, 0.45, 0.03, tostring("Neuer Kredit beantragen:"));
		renderText(0.093, 0.45, 0.03, tostring("Neuer Kredit beantragen:"));
		renderText(0.093, 0.413, 0.025, tostring("Höhe des Kredits: "..g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe.."€"));
		renderText(0.093, 0.370, 0.025, tostring("Tägliche Zinsen: "..g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay.."€"));
		renderText(0.093, 0.327, 0.025, tostring("Laufzeit des Kredites: "..g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit.." Tage"));
		renderText(0.093, 0.284, 0.025, tostring("Insgesamt: "..g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt.."€"));
		
		renderText(0.701, 0.444, 0.035, tostring(g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe.."€"));
		renderText(0.701, 0.351, 0.035, tostring(g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit.." Tag(e)"));
	end;
	
	if Bank.kreditbewilligt.window then
		renderOverlay(FarmingTablet.overlay.kreditbewilligt, 0.125, 0.35, 0.25, 0.3);
		renderText(0.44, 0.604, 0.032, tostring("Bearbeitungsgebühr von 500€ wurde abgezogen!"));
		renderText(0.44, 0.524, 0.032, tostring("Die Zinsen werden jeden Tag um 12.00 Uhr eingezogen."));
		renderText(0.44, 0.49, 0.032, tostring("Am letzten Tag kann man den Kredit bis 12.00 Uhr"));
		renderText(0.44, 0.45, 0.032, tostring("zurückzahlen, ab dann wird der Kredit überzogen."));
		if h == 120 then
			Bank.kreditbewilligt.window = false;
			h = 0;
		else
			h = h+1;
		end;
	end;
	
end;




function Bank:mouseEventBank(posX, posY, isDown, isUp, button) end;
function Bank:deleteBank() end;
 
 
 
 
 
 
 