int slno;

int faceid = -1;

void InitInterface(string iniName)
{
	GetLanguageParameters(); // MAXIMUS 30.07.2006
	GameInterface.title = "titleSelectStoryline";

	SendMessage(&GameInterface,"ls",MSG_INTERFACE_INIT,iniName);
	CreateExitString();//MAXIMUS: standard exit-string for exit-button

	ref PChar = GetMainCharacter();

	slno = FindDefaultStoryline();

	CreateString(true, "StorylineTitle", GetStorylineTitle(slno), FONT_NORMAL, COLOR_NORMAL, 320, 84, SCRIPT_ALIGN_CENTER, 1.0);
	CreateString(true, "CharacterName", "", FONT_SEADOGS, COLOR_NORMAL, 124, 375, SCRIPT_ALIGN_CENTER, 0.9);
	CreateString(true, "ShipClass", "", FONT_NORMAL, COLOR_NORMAL, 460, 245, SCRIPT_ALIGN_LEFT, 1.0);
	CreateString(true, "ShipType", "", FONT_NORMAL, COLOR_NORMAL, 516, 350, SCRIPT_ALIGN_CENTER, 0.6);
	CreateString(true, "ShipName", "", FONT_SEADOGS, COLOR_NORMAL, 516, 375, SCRIPT_ALIGN_CENTER, 0.9);
	CreateString(true, "lblStartDate", TranslateString("", "Date") + ":", FONT_NORMAL, COLOR_NORMAL, 200, 240, SCRIPT_ALIGN_LEFT, 0.7);
	CreateString(true, "lblNation", TranslateString("", "Nation") + ":", FONT_NORMAL, COLOR_NORMAL, 330, 240, SCRIPT_ALIGN_LEFT, 0.7);
	CreateString(true, "StartDate", "", FONT_NORMAL, COLOR_NORMAL, 200, 260, SCRIPT_ALIGN_LEFT, 0.7);
	CreateString(true, "StartLocation", TranslateString("", "Initial location") + ": " + TranslateString("", "unknown"), FONT_NORMAL, COLOR_NORMAL, 200, 280, SCRIPT_ALIGN_LEFT, 0.7);
	CreateString(true, "LblDifficulty", TranslateString("", "Difficulty") + ":", FONT_NORMAL, COLOR_NORMAL, 200, 310, SCRIPT_ALIGN_LEFT, 0.7);
	CreateString(true, "Difficulty", "", FONT_NORMAL, COLOR_NORMAL, 360, 310, SCRIPT_ALIGN_CENTER, 0.7);
	CreateString(AUTO_SKILL_SYSTEM, "lblPlayerType", TranslateString("", "Character is") + ":", FONT_NORMAL, COLOR_NORMAL, 200, 344, SCRIPT_ALIGN_LEFT, 0.7);
	CreateString(AUTO_SKILL_SYSTEM, "PlayerType", "", FONT_NORMAL, COLOR_NORMAL, 360, 344, SCRIPT_ALIGN_CENTER, 0.7);
	SetNodeUsing("PLAYER_TYPE", AUTO_SKILL_SYSTEM);

	SetFormatedText("INFO_TEXT", GetStorylineDescription(slno));
	SendMessage(&GameInterface,"lsl",MSG_INTERFACE_MSG_TO_NODE,"INFO_TEXT",5);

	if (GetStorylinesQuantity() == 1) {
		SetNodeUsing("STORYLINE", false);
		SetNodeUsing("RAMKA", true);
		SetNodeUsing("BOX", true);
	}

	SetVariables();

	SetEventHandler("InterfaceBreak","ProcessCancelExit",0);
	SetEventHandler("exitCancel","ProcessCancelExit",0);
	SetEventHandler("ievnt_command","ProcCommand",0);
	SetEventHandler("IEvnt_MouseClick", "IProcMouseClick", 0);
	SetEventHandler("ChangeStorylineLeft", "DoStorylineChangeLeft", 0);
	SetEventHandler("ChangeStorylineRight", "DoStorylineChangeRight", 0);
	SetEventHandler("NodeOk","ProcessNodeOk",0);
	SetEventHandler("NodeCancel","ProcessNodeCancel",0);
	SetEventHandler("CharNameChange","ProcessCharNameChange",0);
	SetEventHandler("KB_End","WriteName",0);
	SetEventHandler("KB_Update", "UpdateName", 0);	
	SetEventHandler("ShipOk","ProcessShipOk",0);
	SetEventHandler("ShipCancel","ProcessShipCancel",0);
	SetEventHandler("ShipNameChange","ProcessShipNameChange",0);
	SetEventHandler("KB_End","WriteShipName",0);
	SetEventHandler("KB_Update", "UpdateShipName", 0);
	SetEventHandler("ChangeNationLeft", "DoChangeNationLeft", 0);
	SetEventHandler("ChangeNationRight", "DoChangeNationRight", 0);
	SetEventHandler("ChangeDifficultyLeft", "DoChangeDifficultyLeft", 0);
	SetEventHandler("ChangeDifficultyRight", "DoChangeDifficultyRight", 0);
	SetEventHandler("ChangePlayerTypeLeft", "DoChangePlayerTypeLeft", 0);
	SetEventHandler("ChangePlayerTypeRight", "DoChangePlayerTypeRight", 0);
	SetEventHandler("UpStep", "DoUpStep", 0);
	SetEventHandler("DownStep", "DoDownStep", 0);
}

void ProcessCancelExit()
{
	IDoExit(RC_INTERFACE_SELECT_STORYLINE_EXIT);
	if( !CheckAttribute(&InterfaceStates,"InstantExit") || sti(InterfaceStates.InstantExit)==false )
	{
		ReturnToMainMenu();
	}
}

void IDoExit(int exitCode)
{
	DeleteAttribute(GameInterface, "pictures.nationPicture");

	DelEventHandler("InterfaceBreak","ProcessCancelExit");
	DelEventHandler("exitCancel","ProcessCancelExit");
	DelEventHandler("ievnt_command","ProcCommand");
	DelEventHandler("IEvnt_MouseClick", "IProcMouseClick");
	DelEventHandler("ChangeStorylineLeft", "DoStorylineChangeLeft");
	DelEventHandler("ChangeStorylineRight", "DoStorylineChangeRight");
	DelEventHandler("NodeOk","ProcessNodeOk");
	DelEventHandler("NodeCancel","ProcessNodeCancel");
	DelEventHandler("CharNameChange","ProcessCharNameChange");
	DelEventHandler("KB_End","WriteName");
	DelEventHandler("KB_Update", "UpdateName");	
	DelEventHandler("ShipOk","ProcessShipOk");
	DelEventHandler("ShipCancel","ProcessShipCancel");
	DelEventHandler("ShipNameChange","ProcessShipNameChange");
	DelEventHandler("KB_End","WriteShipName");
	DelEventHandler("KB_Update", "UpdateShipName");
	DelEventHandler("ChangeNationRight", "DoChangeNationRight");
	DelEventHandler("ChangeDifficultyLeft", "DoChangeDifficultyLeft");
	DelEventHandler("ChangeDifficultyLeft", "DoChangeDifficultyLeft");
	DelEventHandler("ChangeDifficultyRight", "DoChangeDifficultyRight");
	DelEventHandler("ChangePlayerTypeLeft", "DoChangePlayerTypeLeft");
	DelEventHandler("ChangePlayerTypeRight", "DoChangePlayerTypeRight");
	DelEventHandler("UpStep", "DoUpStep");
	DelEventHandler("DownStep", "DoDownStep");

	interfaceResultCommand = exitCode;
	EndCancelInterface(true);
}

void ProcCommand()
{
	string comName = GetEventData();
	string nodName = GetEventData();

	switch (nodName) {
		case "CUSTOMIZE_BUTTON":
			if (comName == "activate" || comName == "click") {
				IDoExit(RC_INTERFACE_DO_CUSTOMIZATION);
			}
		break;

		case "START_GAME_BUTTON":
			if (comName == "activate" || comName == "click") {
				aref arstart = GetStorylineStartParams(slno);
				SetCurrentStoryline(slno);
				musicName = "";
				oldMusicName = "";
				ResetSoundScheme();
				StopSound(0,0);
				ReleaseSound(0);
				CharModel = arstart.model;
				int idx = GetModelIndex(CharModel);
				CharSex = Models[idx].sex;
				CharAni = Models[idx].ani;
				//CharNation = PERSONAL_NATION;
				CharStore = GetTownStoreIndex(GetTownIDFromLocID(arstart.port));
				if(CharSex=="woman") { CharCommerce = CharCommerce+1; CharSneak = CharSneak+1; }
				if (CheckAttribute(arstart, "ship"))
					CharShipType = arstart.ship;
				else
					CharShipType = SHIP_NOTUSED_TYPE_NAME;
				//CharDifficulty = curDifficulty;
				//CharPlayerType = curPlayerType;
				CharLocation = 0;
				SaveGameOptions();
				LaunchGame();
				IDoExit(RC_INTERFACE_SELECT_STORYLINE_EXIT);
			}
		break;
	}
}

void IProcMouseClick()
{
	string nodName = GetEventData();
	int btnCode = GetEventData();

	if (nodName == "STORYLINE") {
		if (btnCode == 0) Event("ChangeStorylineLeft");
		if (btnCode == 1) Event("ChangeStorylineRight");
	}

	if (nodName == "NATION_CHANGER") {
		if (btnCode == 0) Event("ChangeNationLeft");
		if (btnCode == 1) Event("ChangeNationRight");
	}

	if (nodName == "DIFFICULTY") {
		if (btnCode == 0) Event("ChangeDifficultyLeft");
		if (btnCode == 1) Event("ChangeDifficultyRight");
	}

	if (nodName == "PLAYER_TYPE") {
		if (btnCode == 0) Event("ChangePlayerTypeLeft");
		if (btnCode == 1) Event("ChangePlayerTypeRight");
	}
}

void DoStorylineChangeLeft()
{
	slno--;
	if (slno < 0) slno = GetStorylinesQuantity() - 1;
	GameInterface.strings.StorylineTitle = GetStorylineTitle(slno);
	SetFormatedText("INFO_TEXT", GetStorylineDescription(slno));
	SendMessage(&GameInterface,"lsl",MSG_INTERFACE_MSG_TO_NODE,"INFO_TEXT",5);
	SetVariables();
}

void DoStorylineChangeRight()
{
	slno++;
	if (slno >= GetStorylinesQuantity()) slno = 0;
	GameInterface.strings.StorylineTitle = GetStorylineTitle(slno);
	SetFormatedText("INFO_TEXT", GetStorylineDescription(slno));
	SendMessage(&GameInterface,"lsl",MSG_INTERFACE_MSG_TO_NODE,"INFO_TEXT",5);
	SetVariables();
}

void SetVariables()
{
	CharNation = PERSONAL_NATION;
	CharDifficulty = 1;
	CharPlayerType = 1;

	SetNewPicture("DEFAULT_CHARACTER", "interfaces\empty_face.tga");
	GameInterface.strings.CharacterName = "";
	GameInterface.strings.ShipClass = "";
	GameInterface.strings.ShipType = "";
	GameInterface.strings.ShipName = "";
	SetNewPicture("DEFAULT_SHIP_BACKGROUND", "interfaces\empty_sea.tga");
	SetNewFlagImage();
	GameInterface.strings.StartDate = TranslateString("", "unknown");
	GameInterface.strings.StartLocation = TranslateString("", "Initial location") + ": " + TranslateString("", "unknown");

	aref arstart = GetStorylineStartParams(slno);
	string id = "";
	int idx = -1;
	if (CheckAttribute(arstart, "model")) {
		id = arstart.model;
		idx = GetModelIndex(id);
		if (idx < 0) {
			id = "Blaze";
			idx = GetModelIndex(id);
		}
		faceid = sti(Models[idx].FaceId);
		if (CheckAttribute(arstart, "name") && CheckAttribute(arstart, "lastname")) {
			CharFirstName = arstart.name;
			CharOldFirstName = CharFirstName;
			CharLastName = arstart.lastname;
			CharOldLastName = CharLastName;
		} else {
			CharFirstName = "Nathaniel";
			CharOldFirstName = CharFirstName;
			CharLastName = "Hawk";
			CharOldLastName = CharLastName;
		}
		if (CheckAttribute(arstart, "middlename")) {
			CharMiddleName = arstart.middlename;
			CharOldMiddleName = CharMiddleName;
		} else {
			CharMiddleName = "";
			CharOldMiddleName = "";
		}
		if (faceid >= 0)
			SetNewPicture("DEFAULT_CHARACTER", "interfaces\portraits\128\face_" + faceid + ".tga");
		else
			SetNewPicture("DEFAULT_CHARACTER", "interfaces\empty_face.tga");
		GameInterface.strings.CharacterName = "";
		if (CharFirstName != "" || CharMiddleName != "" || CharLastName != "") {
			if (CharFirstName != "") GameInterface.strings.CharacterName = CharFirstName + " ";
			if (CharMiddleName != "") GameInterface.strings.CharacterName = GameInterface.strings.CharacterName + CharMiddleName + " ";
			if (CharLastName != "") GameInterface.strings.CharacterName = GameInterface.strings.CharacterName + CharLastName;
		}
	} else {
		SetNewPicture("DEFAULT_CHARACTER", "interfaces\empty_face.tga");
	}
	if (CheckAttribute(arstart, "ship")) {
		id = arstart.ship;
		idx = GetShipIndex(id);
		if (idx > -1) {
			if (CheckAttribute(arstart, "shipname")) {
				CharShipName = arstart.shipname;
				GameInterface.strings.ShipName = CharShipName;
			}
			CreateImage("DEFAULT_SHIP", GetShipTextureName(idx), GetShipPicName(idx), 452, 240, 580, 368);
			GameInterface.strings.ShipClass = ShipsTypes[idx].Class;
			GameInterface.strings.ShipType = TranslateString("", GetShipString(idx));
		}
	}

	if (CheckAttribute(arstart, "date.year")) {
		int year = GetDataYear();
		if (CheckAttribute(arstart, "date.year")) year = sti(arstart.date.year);
		int month = GetDataMonth();
		if (CheckAttribute(arstart, "date.month")) month = sti(arstart.date.month);
		int day = GetDataDay();
		if (CheckAttribute(arstart, "date.day")) day = sti(arstart.date.day);
		string time = GetStringTime(GetTime());
		if (CheckAttribute(arstart, "date.hour") && CheckAttribute(arstart, "date.min"))
			time = arstart.date.hour + ":" + arstart.date.min;
		GameInterface.strings.StartDate = GetStringDate(year, month, day)+ ", " + time + ": " + TranslateString("", GetPeriodName(GetPeriodFromYear(sti(arstart.date.year))));
	}
	if (CheckAttribute(arstart, "location")) {
		int lidx = FindLocation(arstart.location);
		if (lidx >= 0 && CheckAttribute(Locations[lidx], "id.label")) {
			Preprocessor_Add("town_name", FindTownName(GetTownIDFromLocID(arstart.location)));
			Preprocessor_Add("island_name", FindIslandName(FindIslandByLocation(arstart.location)));
			GameInterface.strings.StartLocation = TranslateString("", "Initial location") + ": " + PreprocessText(TranslateString("", Locations[FindLocation(arstart.location)].id.label));
			Preprocessor_Remove("island_name");
			Preprocessor_Remove("town_name");
		}
	}
	GameInterface.strings.Difficulty = TranslateString("", GetDifficultyNameFromListNumber(CharDifficulty));
	if (AUTO_SKILL_SYSTEM) GameInterface.strings.PlayerType = TranslateString("", GetPlayerTypeFromListNumber(CharPlayerType));
}

void SetNewFlagImage()
{
	string imageName = GetNationNameByType(CharNation);
	if (hasSubStr(imageName, "unknown") == true || imageName == "no nation" || imageName == "Catalonia") imageName = "PERSONAL_NATION";
	if (imageName == "Britain") imageName = "England";
	CreateImage("nationFlag", GetTextureImage(CharNation), imageName, 392, 230, 424, 262);
	GameInterface.pictures.nationPicture = CharNation;
	//SetNodeUsing("LOCA_CHANGER", bLocationChange(curNation));
}

string GetTextureImage(int curNation)
{
	string nationTexture = curNation;
	switch(curNation)
	{
		case ENGLAND: nationTexture = "NATIONS_2"; break;
		case FRANCE: nationTexture = "NATIONS_2"; break;
		case SPAIN: nationTexture = "NATIONS_1"; break;
		case PIRATE: nationTexture = "NATIONS_2"; break;
		case HOLLAND: nationTexture = "NATIONS_2"; break;
		case PORTUGAL: nationTexture = "NATIONS_1"; break;
		case PERSONAL_NATION: nationTexture = "SMALL_NATION_ICONS"; break;
		case CATALONIA: nationTexture = "SMALL_NATION_ICONS"; break;
		case NEUTRAL_NATION: nationTexture = "SMALL_NATION_ICONS"; break;
		case UNKNOWN_NATION: nationTexture = "SMALL_NATION_ICONS"; break;
		case BROKEN: nationTexture = "SMALL_NATION_ICONS"; break;
	}

	return nationTexture;
}

void DoChangeNationRight()
{
	if (CharNation <= MAX_NATIONS)
		CharNation++;
	else
		CharNation = PERSONAL_NATION;
	SetNewFlagImage();
}

void DoChangeNationLeft()
{
	if (CharNation > 0) {
		if (CharNation == PERSONAL_NATION) CharNation = MAX_NATIONS;
		CharNation--;
		SetNewFlagImage();
	}
}

void DoChangeDifficultyRight()
{
	if (CharDifficulty < 4)
		CharDifficulty++;
	else
		CharDifficulty = 4;
	GameInterface.strings.Difficulty = TranslateString("", GetDifficultyNameFromListNumber(CharDifficulty));
}

void DoChangeDifficultyLeft()
{
	if (CharDifficulty > 1)
		CharDifficulty--;
	else
		CharDifficulty = 1; 
	GameInterface.strings.Difficulty = TranslateString("", GetDifficultyNameFromListNumber(CharDifficulty));
}

string GetDifficultyNameFromListNumber(int inum)
{          
	string retstr;
	switch(inum)
	{
		case 1: retstr = "Apprentice"; break;
		case 2: retstr = "Journeyman"; break;
		case 3: retstr = "Adventurer"; break;
		case 4: retstr = "Swashbuckler"; break;
		retstr = "Unknown";
	}
	return retstr;
}

void DoChangePlayerTypeRight()
{
	if (CharPlayerType < 5)
		CharPlayerType++;
	else
		CharPlayerType = 5; 
	GameInterface.strings.PlayerType = TranslateString("", GetPlayerTypeFromListNumber(CharPlayerType));
}

void DoChangePlayerTypeLeft()
{
	if (CharPlayerType > 1)
		CharPlayerType--;
	else
		CharPlayerType = 1;
	GameInterface.strings.PlayerType = TranslateString("", GetPlayerTypeFromListNumber(CharPlayerType)); 
}

string GetPlayerTypeFromListNumber(int inum)
{          
	string retstr;
	switch(inum)
	{
		case 1: retstr = "Merchant"; break;
		case 2: retstr = "Military"; break;
		case 3: retstr = "Adventurer"; break;
		case 4: retstr = "Social climber"; break;
		case 5: retstr = "Corsair"; break;
		retstr = "Unknown";
	}
	return retstr;
}

void ProcessNodeOk()
{
	string nodName = GetEventData();
	if( CheckAttribute(&GameInterface,nodName+".strdata") )
	{
		string str = GameInterface.(nodName).strdata;
		SetMainCharacterName(str);
		GameInterface.strings.CharacterName = "";
		if (CharFirstName != "") GameInterface.strings.CharacterName = CharFirstName + " ";
		if (CharMiddleName != "") GameInterface.strings.CharacterName = GameInterface.strings.CharacterName + CharMiddleName + " ";
		if (CharLastName != "") GameInterface.strings.CharacterName = GameInterface.strings.CharacterName + CharLastName;
	}
	DeleteAttribute(&GameInterface,nodName+".strdata");
}

void ProcessNodeCancel()
{
	string nodName = GetEventData();
	DeleteAttribute(&GameInterface,nodName+".strdata");
	GameInterface.strings.CharacterName = "";
	if (CharFirstName != "") GameInterface.strings.CharacterName = CharFirstName + " ";
	if (CharMiddleName != "") GameInterface.strings.CharacterName = GameInterface.strings.CharacterName + CharMiddleName + " ";
	if (CharLastName != "") GameInterface.strings.CharacterName = GameInterface.strings.CharacterName + CharLastName;
	SetCurrentNode("BOX");
}

void ProcessCharNameChange()
{
	ChangeStringColor("CharacterName", COLOR_MONEY);
	SendMessage(&GameInterface,"lls", MSG_INTERFACE_LOCK_NODE, 1, "BOX1");
	SetCurrentNode("BOX1");
	KB_SetKeyboardMode(true);

	KeyboardString = "";
}

void UpdateName()
{
	if(GetCurrentNode() == "BOX1") GameInterface.strings.CharacterName = KeyboardString;
}

void WriteName()
{
	if(GetCurrentNode() == "BOX1")
	{
		if(KeyboardString != "")
		{
			SetMainCharacterName(KeyboardString);
			GameInterface.strings.CharacterName = KeyboardString;
		}
		else
		{
			GameInterface.strings.CharacterName = "";
			if (CharFirstName != "") GameInterface.strings.CharacterName = CharFirstName + " ";
			if (CharMiddleName != "") GameInterface.strings.CharacterName = GameInterface.strings.CharacterName + CharMiddleName + " ";
			if (CharLastName != "") GameInterface.strings.CharacterName = GameInterface.strings.CharacterName + CharLastName;
			ProcessNodeCancel();
		}
		SetNodeUsing("BOX",false);
	}
	ChangeStringColor("CharacterName", COLOR_NORMAL);
}

void ProcessShipOk()
{
	string nodName = GetEventData();
	if( CheckAttribute(&GameInterface,nodName+".strdata") )
	{
		string str = GameInterface.(nodName).strdata;
		CharShipName = str;
		GameInterface.strings.ShipName = CharShipName;
	}
	DeleteAttribute(&GameInterface,nodName+".strdata");
}

void ProcessShipCancel()
{
	string nodName = GetEventData();
	DeleteAttribute(&GameInterface,nodName+".strdata");
	aref arstart = GetStorylineStartParams(FindStoryline(GetStoryline(slno)));
	GameInterface.strings.ShipName = arstart.shipname;
	SetCurrentNode("BOX2");
}

void ProcessShipNameChange()
{
	ChangeStringColor("ShipName", COLOR_MONEY);
	SendMessage(&GameInterface,"lls", MSG_INTERFACE_LOCK_NODE, 1, "BOX2");
	SetCurrentNode("BOX2"); 
	KB_SetKeyboardMode(true);

	KeyboardString = "";
}

void UpdateShipName()
{
	if(GetCurrentNode() == "BOX2") GameInterface.strings.ShipName = KeyboardString;
}

void WriteShipName()
{
	if(GetCurrentNode()=="BOX2")
	{
		if(KeyboardString!="")
		{
			CharShipName = KeyboardString;
			GameInterface.strings.ShipName = KeyboardString;
		}
		else
		{
			aref arstart = GetStorylineStartParams(FindStoryline(GetStoryline(slno)));
			GameInterface.strings.ShipName = CharShipName;//GetShipNameFromListNumber(nCurSScrollNum);
			ProcessShipCancel();
		}
	}
	ChangeStringColor("ShipName", COLOR_NORMAL);
}

void DoUpStep()
{
	string tmp = NextUp(GetCurrentNode());
	SetCurrentNode(tmp);
}

void DoDownStep()
{
	string tmp = NextDown(GetCurrentNode());
	SetCurrentNode(tmp);
}

string NextUp(string curNode)
{
	switch (curNode)
	{
		case "STORYLINE":
			if (GetSelectable("START_GAME_BUTTON")) return "START_GAME_BUTTON"; else return NextUp("START_GAME_BUTTON");
		break;
		case "START_GAME_BUTTON":
			if (GetSelectable("CUSTOMIZE_BUTTON")) return "CUSTOMIZE_BUTTON"; else return NextUp("CUSTOMIZE_BUTTON");
		break;
		case "CUSTOMIZE_BUTTON":
			if (AUTO_SKILL_SYSTEM) {
				if (GetSelectable("PLAYER_TYPE")) return "PLAYER_TYPE"; else return NextUp("PLAYER_TYPE");
			} else {
				if (GetSelectable("DIFFICULTY")) return "DIFFICULTY"; else return NextUp("DIFFICULTY");
			}
		break;
		case "PLAYER_TYPE":
			if (GetSelectable("DIFFICULTY")) return "DIFFICULTY"; else return NextUp("DIFFICULTY");
		break;
		case "DIFFICULTY":
			if (GetSelectable("NATION_CHANGER")) return "NATION_CHANGER"; else return NextUp("NATION_CHANGER");
		break;
		case "NATION_CHANGER":
			if (GetSelectable("STORYLINE")) return "STORYLINE"; else return NextUp("STORYLINE");
		break;
	}
	return " ";
}

string NextDown(string curNode)
{
	switch (curNode)
	{
		case "STORYLINE":
			if (GetSelectable("NATION_CHANGER")) return "NATION_CHANGER"; else return NextDown("NATION_CHANGER");
		break;
		case "NATION_CHANGER":
			if (GetSelectable("DIFFICULTY")) return "DIFFICULTY"; else return NextDown("DIFFICULTY");
		break;
		case "DIFFICULTY":
			if (AUTO_SKILL_SYSTEM) {
				if (GetSelectable("PLAYER_TYPE")) return "PLAYER_TYPE"; else return NextDown("PLAYER_TYPE");
			} else {
				if (GetSelectable("CUSTOMIZE_BUTTON")) return "CUSTOMIZE_BUTTON"; else return NextDown("CUSTOMIZE_BUTTON");
			}
		break;
		case "PLAYER_TYPE":
			if (GetSelectable("CUSTOMIZE_BUTTON")) return "CUSTOMIZE_BUTTON"; else return NextDown("CUSTOMIZE_BUTTON");
		break;
		case "CUSTOMIZE_BUTTON":
			if (GetSelectable("START_GAME_BUTTON")) return "START_GAME_BUTTON"; else return NextDown("START_GAME_BUTTON");
		break;
		case "START_GAME_BUTTON":
			if (GetSelectable("STORYLINE")) return "STORYLINE"; else return NextDown("STORYLINE");
		break;
	}
	return " ";
}
