//
// レイアウト初期化

//---------------------------
//初期設定
//---------------------------

//画面高さサイズ
page.WINDOW_HEIGHT = 854;

//1つ目のボタンY座標
page.BTN_BASEY0 = 140;

//2つ目以降のボタンY座標オフセット値
page.BTN_YOFFSET = 94;

//クリアボタンのY座標
page.CLEAR_BASEY0 = 610;

switch(page.type){

	case 1://mailページのボタンの数
		page.BTN_NUM = 2;
	break;

	case 2://functionページのボタンの数
		page.BTN_NUM = 4;
	break;

	case 3://datafolderページのボタンの数
		page.BTN_NUM = 3;
	break;

	case 4://serviceページのボタンの数
		page.BTN_NUM = 5;
	break;

	default:
		page.BTN_NUM = 5;
	break;
}

//エフェクトタイプ
//1:スライドイン
//2:フェードイン
page.EFFECT_TYPE = 2;

//フェードイン時の分割数
page.fade_count = 5;

//---------------------------

	init_layout(page.BTN_NUM , page.EFFECT_TYPE);
	getElementById("EFFECT_BTN").disabled = true;

function init_layout(num , type) {
	var menu = menu;
	var page = page;
	page.count = 1;
	page.BG1 = getElementById("BG2_image");
	page.BG2 = getElementById("Title");

	for(i = 0;i < num; i++){
		if(num < 10){
			//ボタン数が10以下の場合
			page["BTN" + (100 + i)] = getElementById("Button_00" + i);
		}
		else if(num < 100){
			//ボタン数が100以下の場合
			page["BTN" + (100 + i)] = getElementById("Button_0" + i);
		}

		//メニュー名画像の登録
		page["name_menu" + (100 + i)] =  getElementById("menu_" + (i + 1)); 

		if(type == 1){
			page["BTN" + (100 + i)].baseyoffset = page.BTN_BASEY0 + page.BTN_YOFFSET * i - page.WINDOW_HEIGHT;
		}
		else if(type == 2){
			page["name_menu" + (100 + i)].color = 0x00FF00FF;
			page["BTN" + (100 + i)].setProperty("color", 0x00FF00FF , page["BTN" + (100 + i)].STATE_NORMAL);
			page["BTN" + (100 + i)].setProperty("color", 0x00FF00FF , page["BTN" + (100 + i)].STATE_SELECT);
		}
	}
		page["BTN" + (100 + num)] = getElementById("CLEAR");

	if(type == 1){
		page["BTN" + (100 + num)].baseyoffset = page.CLEAR_BASEY0 - page.WINDOW_HEIGHT;
		BG.baseyoffset = 0 - page.WINDOW_HEIGHT;
	}
	else if(type == 2){
			page.BG1.color =  0x00FF00FF;
			page.BG2.color =  0x00FF00FF;
			page["BTN" + (100 + num)].setProperty("color", 0x00FF00FF , page["BTN" + (100 + num)].STATE_NORMAL);
			page["BTN" + (100 + num)].setProperty("color", 0x00FF00FF , page["BTN" + (100 + num)].STATE_SELECT);
	}

}

// エフェクト実行
function init_Effect(num , yoffset) {
	var menu = menu;
	var page = page;

	if(BG.baseyoffset > -10){
		for(i = 0;i < num; i++){
				page["BTN" + (100 + i)].baseyoffset = page.BTN_BASEY0  + page.BTN_YOFFSET * i;
		}
		BG.baseyoffset = 0;
		page["BTN" + (100 + num)].baseyoffset = page.CLEAR_BASEY0;
		getElementById("EFFECT_BTN").disabled = false;
	}
	else{
		for(i = 0;i < num; i++){
				page["BTN" + (100 + i)].baseyoffset += (page.BTN_BASEY0 - page["BTN" + (100 + i)].baseyoffset + page.BTN_YOFFSET * i) / 2;
		}
		page["BTN" + (100 + num)].baseyoffset += (page.CLEAR_BASEY0 - page["BTN" + (100 + num)].baseyoffset) / 2;
		BG.baseyoffset += -1 * BG.baseyoffset / 2;
	}
}

// エフェクト実行
//フェード
function init_Effect_Fade(num) {
	var menu = menu;
	var page = page;

	if(page.count > num){
		page.a_color = 0xFF;
		page.a_colorBG = 0xB2;
		image_a_color(page.BTN_NUM , page.a_color , page.a_colorBG);
		getElementById("EFFECT_BTN").disabled = false;
	}
	else{
		page.a_color = ~~(0xFF/num) * page.count;
		page.a_colorBG = ~~(0xB2/num) * page.count;
		image_a_color(page.BTN_NUM , page.a_color , page.a_colorBG);
		page.count ++;
	}

}

function image_a_color(num , col , bgcol){

		for(i = 0;i < num; i++){
			page["name_menu" + (100 + i)].color = (0xFF000000 + (col << 24));
			page["BTN" + (100 + i)].setProperty("color", (0xFF000000 + (col << 24)), page["BTN" + (100 + i)].STATE_NORMAL);
			page["BTN" + (100 + i)].setProperty("color", (0xFF000000 + (col << 24)), page["BTN" + (100 + i)].STATE_SELECT);
		}
			page.BG1.color = (0xFF000000 + (bgcol << 24));
			page.BG2.color = (0xFF000000 + (col << 24));
			page["BTN" + (100 + num)].setProperty("color", (0xFF000000 + (col << 24)), page["BTN" + (100 + num)].STATE_NORMAL);
			page["BTN" + (100 + num)].setProperty("color", (0xFF000000 + (col << 24)), page["BTN" + (100 + num)].STATE_SELECT);

}
