
menu.texture_load_type = 2;//初期化時全部

menu.xStep = 1;
menu.yStep = 1;

menu.nXPos = -1;
menu.nYPos = -1;
menu.nXDif = 0;
menu.nYDif = 0;
s_med.med.a3itemEnableManualOverride( true );

//========== コンテンツ設定 ==========//
//スクリーン最大数
menu.screen_num = 7;
//１スクリーン当りのoffset範囲
menu.screen_xoffset = 100;
//スクリーン位置（１起算）
menu.screen = 1;

//a3tのフレーム数---------------------------------------★
//menu.a3_frame = 64;
menu.a3_frame = 192;

//a3tのＦＰＳ
menu.a3_fps   = 30;


//========== ローカル使用 ==========//
//現在のスクリーンのオフセット値
menu.center_offset = 0;

//初期化要求
System.exec("system.Kisekae.initContents");
//
//menu.around_offset = menu.screen_xoffset * 2;
menu.around_offset = menu.screen_xoffset * 6;

//テクスチャ設定
System.exec("system.Kisekae.setA3Texture.med." + menu.screen);
//move(menu.screen_xoffset*(menu.screen-1));
NotifyScreenChanged(menu.screen);




function callbackPosX( nX )
{
    menu.nXPos = nX;
}

function callbackPosY( nY )
{
    menu.nYPos = nY;
}

function callbackDiffX( nX )
{
    menu.nXDif += nX;
}

function callbackDiffY( nY )
{
    menu.nYDif += nY;
}

function callbackFlickSpeed( nSpeed )
{
}

function down()
{
}

function effect_end()
{
}

function popup_callback()
{
}

function click()
{
}

function drag()
{
}

function drop()
{
}

function flick(index, type)
{
}


function NotifyScreenOffsets( valu )
{
	xOffset = ( valu & 0xFFFF );
	yOffset = ( valu >> 16 );

	move( xOffset );
}

function NotifyScreenOffsetSteps( valu )
{
	menu.xStep = ( valu & 0xFFFF );
	menu.yStep = ( valu >> 16 );
}

function NotifyScreenChanged( valu )
{
	var nextScreen = ( valu & 0xFFFF );
	var prevScreen = ( (valu >> 16) & 0xFFFF );
	//System.outputDebugString("NotifyScreenChanged: screen " + prevScreen + " -> " + nextScreen);
	if(nextScreen > 0)System.exec("system.Kisekae.setA3Texture.med." + (nextScreen - 1));
	System.exec("system.Kisekae.setA3Texture.med." + nextScreen);
	if(nextScreen < menu.screen_num)System.exec("system.Kisekae.setA3Texture.med." + (nextScreen + 1));
	menu.screen = nextScreen;
	menu.center_offset   = menu.screen * menu.screen_xoffset - menu.screen_xoffset;
	//反映させる（不要かも）
	move(menu.center_offset);
}


function move( nOffset )
{
	var offset = nOffset;
	var time = 0;

	//System.outputDebugString("offset,center,screen_xoffset=" + nOffset + "," + menu.center_offset + "," + menu.screen_xoffset + "\n");

	if (offset >= menu.center_offset + menu.screen_xoffset) {
			System.outputDebugString("********** offset is over ! change screen " + menu.screen + " -> " + (menu.screen + 1));
			NotifyScreenChanged( 0xffff0000 | (menu.screen + 1));
			return;
	}
	else if (offset <= menu.center_offset - menu.screen_xoffset) {
			System.outputDebugString("********** offset is over ! change screen " + menu.screen + " -> " + (menu.screen - 1));
			NotifyScreenChanged( 0xffff0000 | (menu.screen - 1));
			return;
	}

	//System.outputDebugString("offset,center,roffset=" + nOffset + "," + menu.center_offset + "," + offset + "\n");
	time = offset * menu.a3_frame / menu.a3_fps * 0x10000 / menu.around_offset;
	//System.outputDebugString("offset:" + offset + " time=" + time + "\n");


    s_med.med.a3itemSetTime( 'plate01',time );
    s_med.med.a3itemSetTime( 'plate02',time );
    s_med.med.a3itemSetTime( 'plate03',time );
    s_med.med.a3itemSetTime( 'plate04',time );
    s_med.med.a3itemSetTime( 'plate05',time );
    s_med.med.a3itemSetTime( 'plate06',time );
    s_med.med.a3itemSetTime( 'plate07',time );

}


function NotifyPause()
{
}

function NotifyResume()
{
}

function NotifyPauseSurface()
{
	var min = 1;
	var max = menu.screen_num;
	for(var i=min; i<=max; ++i){
		System.exec("system.Kisekae.clearA3Texture.med." + i);
	}
}

function NotifyResumeSurface()
{
	System.exec("system.Kisekae.setA3Texture.med." + menu.screen);
}
