
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 = 200;
//スクリーン位置（１起算）
menu.screen = 1;

//a3tのフレーム数
menu.a3_frame = 65;
//a3tのＦＰＳ
menu.a3_fps   = 30;


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

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

//テクスチャ設定
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);
	System.exec("system.Kisekae.setA3Texture.med." + nextScreen);
	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;
	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;
	}
	offset = offset - menu.center_offset + menu.screen_xoffset;
	//offset = offset - menu.center_offset;
	System.outputDebugString("offset,center,roffset=" + nOffset + "," + menu.center_offset + "," + offset + "\n");

//	time = offset * (0x10000 / menu.around_offset) * menu.a3_frame / menu.a3_fps;
//	time = offset * 0x10000 * menu.a3_frame / menu.around_offset / menu.a3_fps;
//	time = offset * (0x10000 / menu.around_offset / menu.a3_fps) * menu.a3_frame;
	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 );

}

