function GameLevelManager(mainGame) {
	this.mainGame = mainGame;
	this.extractWordManager = null;

	this.wordLevel = 0;

	this.clearedWordCountForLevel = [0, 0, 0, 0, 0, 0];
}

GameLevelManager.prototype.setExtractWordManager = function(extractWordManager) {
	this.extractWordManager = extractWordManager;

	this.difficultyForLevelList = [];
	var count = this.extractWordManager.getWordLevelCount();
	for(var i = 0; i < count; i++)
		this.difficultyForLevelList[i] = ExtractWordManager.DIFFICULTY_EASY;
}

GameLevelManager.prototype.getWordLevel = function() {
	// return this.wordLevel;

	var randomLevel = Math.floor(Math.random() * (this.wordLevel + 1));
	return randomLevel;
}

GameLevelManager.prototype.getWordLevelText = function(wordLevel) {
	var wordLevelText = "";
	switch(wordLevel) {
		case 0:
		if(isKoreanTypingApp())	wordLevelText = "기본자리";
		else					wordLevelText = "Basic";
		break;

		case 1:
		if(isKoreanTypingApp())	wordLevelText = "왼손 윗글쇠";
		else					wordLevelText = "Left upper";
		break;

		case 2:
		if(isKoreanTypingApp())	wordLevelText = "오른손 윗글쇠";
		else					wordLevelText = "Right upper";
		break;

		case 3:
		if(isKoreanTypingApp())	wordLevelText = "검지 글쇠";
		else					wordLevelText = "Second finger";
		break;

		case 4:
		if(isKoreanTypingApp())	wordLevelText = "왼손 밑글쇠";
		else					wordLevelText = "Left lower";
		break;

		case 5:
		if(isKoreanTypingApp())	wordLevelText = "오른손 밑글쇠";
		else					wordLevelText = "Right lower";
		break;

		case 6:
		if(isKoreanTypingApp())	wordLevelText = "왼손 쌍자음";
		else					wordLevelText = "";
		break;

		case 7:
		if(isKoreanTypingApp())	wordLevelText = "오른손 쌍자음";
		else					wordLevelText = "";
		break;
	}
	return wordLevelText;
}

GameLevelManager.prototype.getDifficultyForLevel = function(wordLevel) {
	return this.difficultyForLevelList[wordLevel];
}

GameLevelManager.prototype.getStandardScore = function(wordLevel, difficulty, speed) {
	return (wordLevel + 1) * (1 + difficulty) * (speed + 1);
}


GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) {
	// console.log("====");
	// var count = this.extractWordManager.getWordLevelCount();
	// for(var i = 0; i < count; i++) {
	// 	console.log("difficultyForLevelList[" + i + "] : " + this.difficultyForLevelList[i]);
	// }

	// console.log("wordLevel : " + wordLevel);
	// console.log("landingRatio : " + landingRatio);

	this.increaseClearedWordCountForLevel(wordLevel);

	if(landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) {
		// console.log("*** not enough ratio");
		return;
	}

	this.goNextWordLevel(wordLevel);
}

GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel) {
	this.clearedWordCountForLevel[wordLevel] += 1;

	// console.log("====");
	// var count = this.extractWordManager.getWordLevelCount();
	// for(var i = 0; i < count; i++) {
	// 	console.log("clearedWordCountForLevel[" + i + "] : " + this.clearedWordCountForLevel[i]);
	// }

	var difficulty = this.difficultyForLevelList[wordLevel];
	var clearedWordCount = this.clearedWordCountForLevel[wordLevel];
	var clearedWordCountForNextLevel = GameLevelManager.CLEARED_WORD_COUNT_FOR_NEXT_LEVEL[wordLevel];

	// console.log("=============");
	// console.log("difficulty : " + difficulty);
	// console.log("clearedWordCount : " + clearedWordCount);
	// console.log("clearedWordCountForNextLevel : " + clearedWordCountForNextLevel);

	if(difficulty == ExtractWordManager.DIFFICULTY_EASY
		&& clearedWordCount >= clearedWordCountForNextLevel) {

		this.difficultyForLevelList[wordLevel] = ExtractWordManager.DIFFICULTY_HARD;
		// console.log("level[" + wordLevel + "] : difficulty -> HARD");
	}
}

GameLevelManager.prototype.goNextWordLevel = function(wordLevel) {
	if(wordLevel < this.wordLevel) {
		// console.log("*** already goNextLevel");
		return;
	}

	if(this.wordLevel < this.extractWordManager.getWordLevelCount() - 1) {
		this.wordLevel++;
		this.mainGame.showLevelUpText(this.wordLevel);
	}
}


GameLevelManager.LEVEL_UP_LANDING_RATIO			= 0.7;
GameLevelManager.WARNING_LANDING_RATIO			= 0.3;

GameLevelManager.CLEARED_WORD_COUNT_FOR_NEXT_LEVEL		= [20, 15, 12, 10, 8, 7];

GameLevelManager.COCKPIT_COLOR_LIST			= [
	0xff66ff,
	0x9966ff,
	0x3399ff,
	0x00ffff,
	0x66ff66,
	0xffff66,
	0xff6633,
	0xff6666
]

GameLevelManager.CENTER_MESSAGE_TEXT_COLOR_LIST			= [
	"#ff66ff",
	"#9966ff",
	"#3399ff",
	"#00ffff",
	"#66ff66",
	"#ffff66",
	"#ff6633",
	"#ff6666"
]

GameLevelManager.CENTER_MESSAGE_STROKE_COLOR_LIST			= [
	"#662266",
	"#332266",
	"#113366",
	"#006666",
	"#226622",
	"#666622",
	"#662211",
	"#662222"
]