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

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

	switch(type) {
		case GameAppButton.TYPE_MOUSE_APP:
		setting.setStrokeColor(
			0xaa6666,
			0x884444,
			0x884444,
			0x333333
		);
		setting.setButtonColor(
			0xffdddd,
			0xddaaaa,
			0xddaaaa,
			0x666666
		);
		setting.setTextColor(
			"#a66",
			"#844",
			"#844",
			"#333"
		);
		break;
		case GameAppButton.TYPE_TYPING_PRACTICE:
		case GameAppButton.TYPE_TYPING_APP:
		setting.setStrokeColor(
			0x444488,
			0x6666aa,
			0x6666aa,
			0x333333
		);
		setting.setButtonColor(
			0xaaaadd,
			0xddddff,
			0xddddff,
			0x666666
		);
		setting.setTextColor(
			"#844",
			"#a66",
			"#a66",
			"#333"
		);
		break;
	}

	setting.fontStyle = {
		font: "24px Arial",
		boundsAlignH: "center",		// left, center. right
		boundsAlignV: "middle", 	// top, middle, bottom
		fill: "#fff"
	};

	var textCount = buttonText.length;
	if(textCount > 7)
		setting.fontStyle.font = "18px Arial";
	else if(textCount > 5)
		setting.fontStyle.font = "22px Arial";
	else
		setting.fontStyle.font = "24px Arial";

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


GameAppButton.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';
}


GameAppButton.TYPE_MOUSE_APP		= 0;
GameAppButton.TYPE_TYPING_PRACTICE	= 1;
GameAppButton.TYPE_TYPING_APP		= 2;

GameAppButton.BUTTON_WIDTH			= 120;
GameAppButton.BUTTON_HEIGHT			= 120;

GameAppButton.BUTTON_GAP			= 20;
GameAppButton.MARGIN_VERTICAL		= 100;

GameAppButton.BUTTON_UPPER_POS_Y	= 200;
GameAppButton.BUTTON_LOWER_POS_Y	= 480;