TypingAppButton.prototype = Object.create(RoundRectButton.prototype);
TypingAppButton.constructor = TypingAppButton;

function TypingAppButton(type, x, y, iconSprite, buttonText, appInfo) {
	var setting = new RoundRectButtonSetting(x, y, TypingAppButton.BUTTON_WIDTH, TypingAppButton.BUTTON_HEIGHT);
	setting.fontStyle.boundsAlignH = "center";	// left, center. right
	setting.fontStyle.boundsAlignV = "middle";	// top, middle, bottom
	setting.strokeWidthPx = 5;

	switch(type) {
		case TypingAppButton.TYPE_PRACTICE_KOREAN:
		case TypingAppButton.TYPE_TEST_KOREAN:
		setting.setStrokeColor(
			0xffffff,
			0xeeeeff,
			0xccccdd,
			0x333333
		);
		setting.setButtonColor(
			0xeeeeff,
			0xddddee,
			0xccccdd,
			0x666666
		);
		setting.setTextColor(
			"#66c",
			"#66c",
			"#66c",
			"#333"
		);
		setting.setIconColor(
			0xeeeeff,
			0xddddee,
			0xccccdd,
			0x666666
		);
		break;

		case TypingAppButton.TYPE_PRACTICE_ENGLISH:
		case TypingAppButton.TYPE_TEST_ENGLISH:
		setting.setStrokeColor(
			0xffffff,
			0xffeeee,
			0xddcccc,
			0x333333
		);
		setting.setButtonColor(
			0xffeeee,
			0xeedddd,
			0xddcccc,
			0x666666
		);
		setting.setTextColor(
			"#a66",
			"#a66",
			"#a66",
			"#333"
		);
		setting.setIconColor(
			0xffeeee,
			0xeedddd,
			0xddcccc,
			0x666666
		);
		break;
	}

	setting.fontStyle = {
		font: "22px Arial",
		fill: "#fff"
	};

	this.appInfo = appInfo;
	RoundRectButton.call(
		this, setting,
		null,
		buttonText,
		this.clickEvent
	);

	this.text.x = 140;

	if(iconSprite != null) {
		this.icon = iconSprite.sprite;
		this.buttonIcon = this.button.addChild(this.icon);

		this.buttonIcon.x = 35;
		this.buttonIcon.y = this.button.height / 2 - 5;
	}

}

TypingAppButton.prototype.clickEvent = function() {
	sessionStorageManager.setPlayingAppID(this.appInfo.AppID);
	sessionStorageManager.setPlayingAppName(this.appInfo.AppName);
	sessionStorageManager.setPlayingAppKoreanName(this.appInfo.KoreanName);

	if(isExperiencePlayerAccount())
		location.href = '../../web/client/ads.html';
	else
		location.href = '../../web/client/start.html';
}


TypingAppButton.TYPE_PRACTICE_KOREAN	= 0;
TypingAppButton.TYPE_PRACTICE_ENGLISH	= 1;
TypingAppButton.TYPE_TEST_KOREAN		= 2;
TypingAppButton.TYPE_TEST_ENGLISH		= 3;

TypingAppButton.BUTTON_WIDTH		= 230;
TypingAppButton.BUTTON_HEIGHT		= 70;

TypingAppButton.BUTTON_GAP			= 10;
TypingAppButton.MARGIN_VERTICAL		= 20;

TypingAppButton.BUTTON_UPPER_POS_Y	= 205 + 60;
TypingAppButton.BUTTON_LOWER_POS_Y	= 475 + 30;

TypingAppButton.QUESTION_ICON		= "";