
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 = 155;
//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( 'twist01',time );
    s_med.med.a3itemSetTime( 'twist02',time );
    s_med.med.a3itemSetTime( 'twist03',time );
    s_med.med.a3itemSetTime( 'point01',time );
    s_med.med.a3itemSetTime( 'point02',time );
    s_med.med.a3itemSetTime( 'point03',time );
    s_med.med.a3itemSetTime( 'point04',time );
    s_med.med.a3itemSetTime( 'point05',time );
    s_med.med.a3itemSetTime( 'point06',time );
    s_med.med.a3itemSetTime( 'point07',time );
    s_med.med.a3itemSetTime( 'point08',time );
    s_med.med.a3itemSetTime( 'Bone01',time );
    s_med.med.a3itemSetTime( 'Bone02',time );
    s_med.med.a3itemSetTime( 'Bone03',time );
    s_med.med.a3itemSetTime( 'Bone04',time );
    s_med.med.a3itemSetTime( 'Bone05',time );
    s_med.med.a3itemSetTime( 'Bone06',time );
    s_med.med.a3itemSetTime( 'Bone07',time );
    s_med.med.a3itemSetTime( 'Bone08',time );
    s_med.med.a3itemSetTime( 'Bone09',time );
    s_med.med.a3itemSetTime( 'Bone10',time );
    s_med.med.a3itemSetTime( 'Bone11',time );
    s_med.med.a3itemSetTime( 'Bone12',time );
    s_med.med.a3itemSetTime( 'Bone13',time );
    s_med.med.a3itemSetTime( 'Bone14',time );
    s_med.med.a3itemSetTime( 'Bone15',time );
    s_med.med.a3itemSetTime( 'Bone16',time );
    s_med.med.a3itemSetTime( 'Bone17',time );
    s_med.med.a3itemSetTime( 'Bone18',time );
    s_med.med.a3itemSetTime( 'Bone19',time );
    s_med.med.a3itemSetTime( 'Bone20',time );
    s_med.med.a3itemSetTime( 'Bone21',time );
    s_med.med.a3itemSetTime( 'Bone22',time );
    s_med.med.a3itemSetTime( 'Bone23',time );
    s_med.med.a3itemSetTime( 'Bone24',time );
    s_med.med.a3itemSetTime( 'Bone25',time );
    s_med.med.a3itemSetTime( 'Bone26',time );
    s_med.med.a3itemSetTime( 'Bone27',time );
    s_med.med.a3itemSetTime( 'Bone28',time );
    s_med.med.a3itemSetTime( 'Bone29',time );
    s_med.med.a3itemSetTime( 'Bone30',time );
    s_med.med.a3itemSetTime( 'Bone31',time );
    s_med.med.a3itemSetTime( 'Bone32',time );
    s_med.med.a3itemSetTime( 'Bone33',time );
    s_med.med.a3itemSetTime( 'Bone34',time );
    s_med.med.a3itemSetTime( 'Bone35',time );
    s_med.med.a3itemSetTime( 'Bone36',time );
    s_med.med.a3itemSetTime( 'Bone37',time );
    s_med.med.a3itemSetTime( 'Bone38',time );
    s_med.med.a3itemSetTime( 'Bone39',time );
    s_med.med.a3itemSetTime( 'Bone40',time );
    s_med.med.a3itemSetTime( 'Bone41',time );
    s_med.med.a3itemSetTime( 'Bone42',time );
    s_med.med.a3itemSetTime( 'Bone43',time );
    s_med.med.a3itemSetTime( 'Bone44',time );
    s_med.med.a3itemSetTime( 'Bone45',time );
    s_med.med.a3itemSetTime( 'Bone46',time );
    s_med.med.a3itemSetTime( 'Bone47',time );
    s_med.med.a3itemSetTime( 'Bone48',time );
    s_med.med.a3itemSetTime( 'Bone49',time );
    s_med.med.a3itemSetTime( 'Bone50',time );
    s_med.med.a3itemSetTime( 'Bone51',time );
    s_med.med.a3itemSetTime( 'Bone52',time );
    s_med.med.a3itemSetTime( 'Bone53',time );
    s_med.med.a3itemSetTime( 'Bone54',time );
    s_med.med.a3itemSetTime( 'Bone55',time );
    s_med.med.a3itemSetTime( 'Bone56',time );
    s_med.med.a3itemSetTime( 'Bone57',time );
    s_med.med.a3itemSetTime( 'Bone58',time );
    s_med.med.a3itemSetTime( 'Bone59',time );
    s_med.med.a3itemSetTime( 'Bone60',time );
    s_med.med.a3itemSetTime( 'Bone61',time );
    s_med.med.a3itemSetTime( 'Bone62',time );
    s_med.med.a3itemSetTime( 'Bone63',time );
    s_med.med.a3itemSetTime( 'Bone64',time );
    s_med.med.a3itemSetTime( 'Bone65',time );
    s_med.med.a3itemSetTime( 'Bone66',time );
    s_med.med.a3itemSetTime( 'Bone67',time );
    s_med.med.a3itemSetTime( 'Bone68',time );
    s_med.med.a3itemSetTime( 'Bone69',time );
    s_med.med.a3itemSetTime( 'Bone70',time );
    s_med.med.a3itemSetTime( 'Bone71',time );
    s_med.med.a3itemSetTime( 'Bone72',time );
    s_med.med.a3itemSetTime( 'Bone73',time );
    s_med.med.a3itemSetTime( 'Bone74',time );
    s_med.med.a3itemSetTime( 'Bone75',time );
    s_med.med.a3itemSetTime( 'Bone76',time );
    s_med.med.a3itemSetTime( 'Bone77',time );
    s_med.med.a3itemSetTime( 'Bone78',time );
    s_med.med.a3itemSetTime( 'Bone79',time );
    s_med.med.a3itemSetTime( 'Bone80',time );
    s_med.med.a3itemSetTime( 'Bone81',time );
    s_med.med.a3itemSetTime( 'Bone82',time );
    s_med.med.a3itemSetTime( 'Bone83',time );
    s_med.med.a3itemSetTime( 'Bone84',time );
    s_med.med.a3itemSetTime( 'Bone85',time );
    s_med.med.a3itemSetTime( 'Bone86',time );
    s_med.med.a3itemSetTime( 'Bone87',time );
    s_med.med.a3itemSetTime( 'Bone88',time );
    s_med.med.a3itemSetTime( 'Bone89',time );
    s_med.med.a3itemSetTime( 'Bone90',time );
    s_med.med.a3itemSetTime( 'Bone91',time );
    s_med.med.a3itemSetTime( 'Bone92',time );
    s_med.med.a3itemSetTime( 'Bone93',time );
    s_med.med.a3itemSetTime( 'Bone94',time );
    s_med.med.a3itemSetTime( 'Bone95',time );
    s_med.med.a3itemSetTime( 'Bone96',time );
    s_med.med.a3itemSetTime( 'Bone97',time );
    s_med.med.a3itemSetTime( 'Bone98',time );
    s_med.med.a3itemSetTime( 'Bone99',time );
    s_med.med.a3itemSetTime( 'Bone100',time );
    s_med.med.a3itemSetTime( 'Bone101',time );
    s_med.med.a3itemSetTime( 'Bone102',time );
    s_med.med.a3itemSetTime( 'Bone103',time );
    s_med.med.a3itemSetTime( 'Bone104',time );
    s_med.med.a3itemSetTime( 'Bone105',time );
    s_med.med.a3itemSetTime( 'Bone106',time );
    s_med.med.a3itemSetTime( 'Bone107',time );
    s_med.med.a3itemSetTime( 'Bone108',time );
    s_med.med.a3itemSetTime( 'Bone109',time );
    s_med.med.a3itemSetTime( 'Bone110',time );
    s_med.med.a3itemSetTime( 'Bone111',time );
    s_med.med.a3itemSetTime( 'Bone112',time );
    s_med.med.a3itemSetTime( 'Bone113',time );
    s_med.med.a3itemSetTime( 'Bone114',time );
    s_med.med.a3itemSetTime( 'Bone115',time );
    s_med.med.a3itemSetTime( 'Bone116',time );
    s_med.med.a3itemSetTime( 'Bone117',time );
    s_med.med.a3itemSetTime( 'Bone118',time );
    s_med.med.a3itemSetTime( 'Bone119',time );
    s_med.med.a3itemSetTime( 'Bone120',time );
    s_med.med.a3itemSetTime( 'Bone121',time );
    s_med.med.a3itemSetTime( 'Bone122',time );
    s_med.med.a3itemSetTime( 'Bone123',time );
    s_med.med.a3itemSetTime( 'Bone124',time );

}

