class MyTouch{
	constructor(){
		this.touchCount = 0;		
		this.touchMaxCount = 0.0;		
		this.touchSecCount = 0;		
		this.touchSec = 0;		
		this.touchSecCountDown = 0;		
		this.touchClearSec = 9999;	
		this.touchSecStop = false;
		this.SetOmorashi = null;
		this.str_oshikko = "";
		this.AutoTest = false;
		this.mode = 0;//0:通常モード/1:ミッションモード
		this.lastImage = "";
		this.timeData;
		this.MissionLV = 0;
		this.MissionSw = false;
		this.type = 0;
		this.MissionValue = [5,5.5,6.0,6.2,6.4,6.6,6.8,7.0];
		this.MissionMsg = [
			"LV1：秒間"+this.MissionValue[0]+"回/秒以上を<br>30秒キープしろ！",
			"LV2：秒間"+this.MissionValue[0]+"回/秒以上を<br>30秒キープしろ！",
			"LV3：秒間"+this.MissionValue[0]+"回/秒以上を<br>30秒キープしろ！",
			"LV4：秒間"+this.MissionValue[0]+"回/秒以上を<br>30秒キープしろ！",
			"LV5：秒間"+this.MissionValue[0]+"回/秒以上を<br>30秒キープしろ！",
			"LV6：秒間"+this.MissionValue[0]+"回/秒以上を<br>30秒キープしろ！",
			"LV7：秒間"+this.MissionValue[0]+"回/秒以上を<br>30秒キープしろ！",
			"LV8：秒間"+this.MissionValue[0]+"回/秒以上を<br>30秒キープしろ！",
		];
	}
	//データ読み込み
	LoadData(){
		//保存データ設定
		myDataCtrl.Load();
		this.timeData = myDataCtrl.GetSaveData("timeData");
		if(!this.timeData){
			this.timeData = [];
			this.timeData[0] = this.touchMaxCount;
			this.timeData[1] = this.touchClearSec;
			myDataCtrl.SetSaveData("timeData",this.timeData);
		}else{
			this.touchMaxCount = this.timeData[0];
			this.touchClearSec = this.timeData[1];
		}		
	}
	//データ保存
	SaveData(){
		this.timeData[0] = this.touchMaxCount;
		this.timeData[1] = this.touchClearSec;
		myDataCtrl.SetSaveData("timeData",this.timeData);
		myDataCtrl.Save();		
	}
	
	//枠＆タッチ設定
	setBoxTouch(parent){
		//保存データ取得
		this.LoadData();
		//最終描画
		this.lastImage = myImg.imgKeyArry[myImg.imgKeyArry.length-1];
		//枠を生成
		var elm_div = _self.GetInitBox();
		elm_div.x = "200px";
		elm_div = _self.SetBoxParam(elm_div,"menu2","150px","200px");
		_self.AddBoxData(elm_div);
		_self.SettingBox(parent[0],elm_div.Name,"");
		_self.Elm(".menu2").style.fontSize = "10pt";
		_self.Elm(".menu2").innerHTML = "タッチ回数:<span id='TouchCount'></scan>";
		_self.Elm(".menu2").innerHTML += "<br>最大秒間タッチ回数<br><span id='TouchMaxCount'></scan>";
		_self.Elm(".menu2").innerHTML += "<br>秒間タッチ回数<br><span id='TouchSecCount'></scan>";
		_self.Elm(".menu2").innerHTML += "<span id='mode1'><br>経過秒数<br><span id='TouchSec'></scan></span>";
		_self.Elm(".menu2").innerHTML += "<span id='mode2'><br>キープ秒数<br><span id='TouchSecCountDown'></scan></scan>";
		_self.Elm(".mode2").style.display = "none";
		_self.Elm(".menu2").innerHTML += "<br>最速クリア時間<br><span id='TouchClearSec'></scan>";
		//リセット
		elm_div = _self.GetInitBox();
		elm_div.x = "200px";
		elm_div.y = "330px";
		elm_div = _self.SetBoxParam(elm_div,"reset","150px","90px");
		_self.AddBoxData(elm_div);
		var operation = _self.Elm(".operation");
		_self.SettingBox(operation,elm_div.Name,"");
		
		//リセットメッセージ
		var imgElm = _self.Elm(".image");//画像描画サイズ取得
		elm_div = _self.GetInitBox();
		elm_div = _self.SetBoxParam(elm_div,"resetMsg",imgElm.width+"px",imgElm.height+"px");
		_self.AddBoxData(elm_div);
		_self.SettingBox(parent[0],elm_div.Name,"none");
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<span id='mode'></span>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<br>";
		_self.Elm(".resetMsg").innerHTML += "<span id='Yes'>はい</span>　　　　<span id='No'>いいえ</span>";
		_self.Elm(".resetMsg").style.textAlign="center";
		
		//次のレベルへ
		elm_div = _self.GetInitBox();
		elm_div.x = "0px";
		elm_div.y = (imgElm.height/2)+"px";
		elm_div = _self.SetBoxParam(elm_div,"NextLv",imgElm.width+"px","25px");
		_self.AddBoxData(elm_div);
		_self.SettingBox(document.body,elm_div.Name,"none");
		_self.Elm(".NextLv").innerText = "次のレベルへ";
		_self.Elm(".NextLv").style.textAlign = "center";
		
		//イベントセット
		_self.AddCommand("reset","modeChg","モード切替");
		_self.AddCommand("reset","resetBtn","リセット");
		_self.AddCommand("reset","chgClothsBtn","服装チェンジ");
		//モード切替
		var elm = _self.Elm(".modeChg");
		elm.style.marginTop = "5px";		
		elm.style.marginBottom = "5px";	
		_self.AddEventForId("modeChg",function(e){
			_self.HiddenBox("NextLv");
			_self.Elm(".mode").innerHTML = myBT.mode?"通常モードに変更しますか？":"ミッションモードに変更しますか？";
			_self.Elm(".resetMsg").style.display = "";
			myBT.touchSecStop = true;
			_self.AddEventForId("Yes",function(e){
				if(myBT.mode==0){
					myBT.mode=1;
				}else{
					myBT.mode=0;
				}
				myBT.YesSelect();
			});
			_self.AddEventForId("No",function(e){
				myBT.NoSelect();
			});			
		});
		//服装チェンジボタン
		elm = _self.Elm(".chgClothsBtn");
		elm.style.marginTop = "5px";		
		elm.style.marginBottom = "5px";		
		_self.AddEventForId("chgClothsBtn",function(e){
			_self.HiddenBox("NextLv");
			if(myBT.mode == 0){
				_self.Elm(".mode").innerHTML = "服装を変えてリセットしますか？<br>※最大秒間タッチ回数はリセットされません。";
				_self.Elm(".resetMsg").style.display = "";
				myBT.touchSecStop = true;
				_self.AddEventForId("Yes",function(e){
					//服装タイプ変更
					myBT.type = myBT.type==0?1:0; 
					myBT.YesSelect();
				});
				_self.AddEventForId("No",function(e){
					myBT.NoSelect();
				});
			}else{
				_self.Elm(".mode").innerHTML = "通常モード時のみ有効です。";
				_self.Elm(".resetMsg").style.display = "";
				_self.Elm(".resetMsg").onclick = function(){
					_self.Elm(".resetMsg").style.display = "none";
				}
			}
		});		
		//リセットボタン
		elm = _self.Elm(".resetBtn");
		elm.style.marginTop = "5px";		
		elm.style.marginBottom = "5px";		
		_self.AddEventForId("resetBtn",function(e){
			_self.HiddenBox("NextLv");
			_self.Elm(".mode").innerHTML = "リセットしますか？<br>※最大秒間タッチ回数はリセットされません。";
			_self.Elm(".resetMsg").style.display = "";
			myBT.touchSecStop = true;
			_self.AddEventForId("Yes",function(e){
				myBT.YesSelect();
			});
			_self.AddEventForId("No",function(e){
				myBT.NoSelect();
			});
		});
		
		//次のレベルへ
		_self.AddEventForId("NextLv",function(e){
			if(myBT.MissionLV<3){
			_self.HiddenBox("NextLv");
			_self.Elm(".mode").innerHTML = "次のレベルへ行きますか？";
			_self.Elm(".resetMsg").style.display = "";
			myBT.touchSecStop = true;
			_self.AddEventForId("Yes",function(e){
				myBT.MissionLV++;				
				myBT.YesSelect();
			});
			_self.AddEventForId("No",function(e){
				myBT.NoSelect();
				_self.ViewBox("NextLv");
			});
				
			}
		});
		//Yesボタン共通処理
		this.YesSelect = function(){
			for(var loop in myImg.imgKeyArry){
				if(loop==0)continue;
				myImg.SetIndexPos(myImg.imgKeyArry[loop],myImg.GetIndexInitPos(myImg.imgKeyArry[loop]));
				myImg.ImageView(myImg.imgKeyArry[loop],true,true);
			}
			//モード判定
			if(myBT.mode==0){
				//服装判定
				if(myBT.type){
					//背景設定
					myImg.SetIndexPos("back",2);
					myImg.ImageView("back",true,true);
					myImg.SetIndexPos("wear",9);
					myImg.ImageView("wear",true,true);
					myImg.SetIndexPos("taitu",3);
					myImg.ImageView("taitu",true,true);
					myImg.SetIndexPos("sitagi",4);
					myImg.ImageView("sitagi",true,true);
					myImg.SetIndexPos("kutu",2);
					myImg.ImageView("kutu",true,true);
				}else{
					//背景設定
					myImg.SetIndexPos("back",1);
					myImg.ImageView("back",true,true);
				}
			}
			myBT.touchSec = 0;
			myBT.touchCount = 0;
			_self.Elm(".TouchCount").innerText = myBT.touchCount;
			_self.Elm(".resetMsg").style.display = "none";
			myBT.Start(true);
			_self.HiddenBox("menu2");
			_self.HiddenBox("reset");
			_self.ViewBox("StartMsg");
		}
		//Noボタン共通処理
		this.NoSelect = function(){
			myBT.touchSecStop = false;
			_self.Elm(".resetMsg").style.display = "none";
			myBT.startTime = Date.now()-(myBT.touchSec*1000);
			myBT.touchSec = (Date.now()-myBT.startTime)/1000;
			myBT.SecTouchCheck();
		}
		
		//セリフ枠
		elm_div = _self.GetInitBox();
		elm_div.x = "0px";
		elm_div.y = "20px";
		elm_div = _self.SetBoxParam(elm_div,"Say1","150px","20px");
		_self.AddBoxData(elm_div);
		_self.SettingBox(parent[0],elm_div.Name,"none");
		_self.Elm(".Say1").style.fontSize = "10pt";
		elm_div = _self.GetInitBox();
		elm_div.x = "200px";
		elm_div.y = "210px";
		elm_div = _self.SetBoxParam(elm_div,"Say2","150px","20px");
		_self.AddBoxData(elm_div);
		_self.SettingBox(parent[0],elm_div.Name,"none");
		_self.Elm(".Say2").style.fontSize = "10pt";
		elm_div = _self.GetInitBox();
		elm_div.x = "20px";
		elm_div.y = "300px";
		elm_div = _self.SetBoxParam(elm_div,"Say3","150px","20px");
		_self.AddBoxData(elm_div);
		_self.SettingBox(parent[0],elm_div.Name,"none");
		_self.Elm(".Say3").style.fontSize = "10pt";
		
		//枠を生成
		elm_div = _self.GetInitBox();
		elm_div.x = "0px";
		elm_div.y = "100px";
		elm_div = _self.SetBoxParam(elm_div,"menu3","150px","100px");
		_self.AddBoxData(elm_div);
		_self.SettingBox(parent[0],elm_div.Name,"");
		_self.Elm(elm_div.Name,_self.TypeID).innerText = "X:-,Y:-";							
		_self.Elm(elm_div.Name,_self.TypeID).style.fontSize = "10pt";
		_self.HiddenBox(elm_div.Name);
		_self.Elm(".Progress").innerText = "";
		
		//自動テスト
		myBT.AutoTestMode = function(){
			if(myBT.AutoTest){
				var elementName = myImg.GetCanvasTarget(myBT.lastImage);
				var xyPoint = {};
				xyPoint.clientX = 50;
				xyPoint.clientY = 100;
				_self.Elm(elementName,_self.TypeID).onmousedown(xyPoint);
				_self.setTimer(myBT.AutoTestMode,100);
			}
		}
		
		//秒間タッチ回数チェック
		myBT.startTime = Date.now();
		myBT.startTime2 = 0;
		this.SecTouchCheck = function(){
			_self.setTimer(function(){
				if(!myBT.touchSecStop){
					myBT.touchSec = (Date.now()-myBT.startTime)/1000;
					myBT.touchSecCount = parseFloat(myBT.touchCount/myBT.touchSec);
					//ミッションモード用指定回数到達判定
					var idx = myBT.MissionLV;
					if(myBT.touchSecCount>=myBT.MissionValue[idx]){
						myBT.MissionSw = true;
					}else{
						myBT.MissionSw = false;
					}
					//指定回数キープ判定
					if(myBT.MissionSw){
						if(myBT.startTime2==0)myBT.startTime2 =  Date.now();
						if(myBT.startTime2!=0)myBT.touchSecCountDown = (30-(Date.now()-myBT.startTime2)/1000);
					}else{
						myBT.startTime2 = 0;
						myBT.touchSecCountDown = 0;
					}
					//最大秒間タッチ回数更新判定
					if((myBT.touchSecCount>myBT.touchMaxCount)&&(myBT.touchSec>=30)){
						myBT.touchMaxCount = myBT.touchSecCount;
						myBT.SaveData();
					}
					_self.Elm(".TouchMaxCount").innerText = myBT.touchMaxCount.toFixed(2)+"回/秒";
					_self.Elm(".TouchSecCount").innerText = myBT.touchSecCount.toFixed(2)+"回/秒";
					if(!myBT.mode){
						_self.Elm(".TouchSec").innerText = myBT.touchSec.toFixed(2)+"秒";
					}else{
						_self.Elm(".TouchSecCountDown").innerText = myBT.touchSecCountDown.toFixed(2)+"秒";
					}
					_self.Elm(".TouchClearSec").innerText = myBT.touchClearSec.toFixed(2)+"秒";
					_self.setTimer(myBT.SecTouchCheck,100);				
				}
			},100);
		}
		this.SecTouchCheck();
		
		//通常モード
		this.NormalMode = function(){
			//----------------セリフ---------------
			if((myBT.touchCount==1)||(myBT.touchCount%30==0)){
				_self.Elm(".Say1").innerText = "なんですか？";
				if(myBT.touchCount>=30)_self.Elm(".Say1").innerText = "もう、なんです？";
				if(myBT.touchCount>=60)_self.Elm(".Say1").innerText = "ちょ、ちょっと？";
				if(myBT.touchCount>=120)_self.Elm(".Say1").innerText = "やめて下さい...";
				if(myBT.touchCount>=180)_self.Elm(".Say1").innerText = "なんで...";
				if(myBT.touchCount>=300)_self.Elm(".Say1").innerText = "恥ずかしいんです...";
				if(myBT.touchCount>=300)_self.Elm(".Say1").innerText = "やぁ...";
				_self.Elm(".Say1").style.height = "20px";
				if(myBT.touchCount==570){
					_self.Elm(".Say1").innerText = "は、裸を見せるんですか！？";
					_self.Elm(".Say1").style.height = "50px";
				}
				if(myBT.touchCount==630){
					_self.Elm(".Say1").innerText = "おしっこ洩れちゃうよ...";
					_self.Elm(".Say1").style.height = "50px";
				}
				_self.ViewBox("Say1");
				_self.setTimer(function(){
					_self.HiddenBox("Say1");
				},2000);
			}
			if((myBT.touchCount%49==0)){
				_self.Elm(".Say2").innerText = "くすぐったいですよ～";
				if(myBT.touchCount>=50)_self.Elm(".Say2").innerText = "触り方がエッチですよ～";
				if(myBT.touchCount>=100)_self.Elm(".Say2").innerText = "やだ！変なところ触らないでぇ！";
				_self.Elm(".Say2").height = "50px;"
				if(myBT.touchCount>=150)_self.Elm(".Say2").innerText = "もう、やだぁ...";
				_self.Elm(".Say2").height = "20px;"
				if(myBT.touchCount>=300)_self.Elm(".Say2").innerText = "はぁ、はぁ、はぁ....";
				if(myBT.touchCount==588)_self.Elm(".Say2").innerText = "ううう...";
				if(myBT.touchCount==639)_self.Elm(".Say2").innerText = "こ、ここで、するんですか！？";
				_self.ViewBox("Say2");
				_self.setTimer(function(){
					_self.HiddenBox("Say2");
				},2000);
			}
			if(myBT.touchCount==100){
				_self.Elm(".Say3").style.width = "200px";
				_self.Elm(".Say3").innerText = "な、なにするんですか！？";
				_self.ViewBox("Say3");
				_self.setTimer(function(){
					_self.HiddenBox("Say3");
				},2000);
			}
			if(myBT.touchCount==150){
				_self.Elm(".Say3").style.width = "200px";
				_self.Elm(".Say3").innerText = "に、匂いなんて嗅がないで...";
				_self.ViewBox("Say3");
				_self.setTimer(function(){
					_self.HiddenBox("Say3");
				},2000);
			}				
			if(myBT.touchCount==250){
				_self.Elm(".Say3").innerText = "ぱ、パンツが丸見えに...";
				_self.ViewBox("Say3");
				_self.setTimer(function(){
					_self.HiddenBox("Say3");
				},2000);
			}					
			if(myBT.touchCount==300){
				_self.Elm(".Say3").style.height = "50px";
				_self.Elm(".Say3").innerText = "下着姿、男の人に見せた事なんてないんですよ...";
				_self.ViewBox("Say3");
				_self.setTimer(function(){
					_self.HiddenBox("Say3");
				},2000);
			}					
			if(myBT.touchCount==350){
				_self.Elm(".Say3").style.height = "50px";
				_self.Elm(".Say3").innerText = "ブラジャーまで...。む、胸みないでぇ...";
				_self.ViewBox("Say3");
				_self.setTimer(function(){
					_self.HiddenBox("Say3");
				},2000);
			}					
			if(myBT.touchCount==500){
				_self.Elm(".Say3").style.height = "20px";
				_self.Elm(".Say3").innerText = "裸にされちゃったよぉ～";
				_self.ViewBox("Say3");
				_self.setTimer(function(){
					_self.HiddenBox("Say3");
				},2000);
				myBT.touchSecStop = true;
				if(myBT.touchClearSec>myBT.touchSec){
					myBT.touchClearSec = myBT.touchSec;
					myBT.SecTouchCheck();
					myBT.SaveData();
				}
			}
			if(!_self.product_flg){
				if(myBT.touchCount==550){
					_self.Elm(".Say3").style.height = "20px";
					_self.Elm(".Say3").innerText = "ま、まだ何かするんですか！？";
					_self.ViewBox("Say3");
					_self.setTimer(function(){
						_self.HiddenBox("Say3");
					},2000);
				}
				if(myBT.touchCount==600){
					_self.Elm(".Say3").style.height = "20px";
					_self.Elm(".Say3").innerText = "凄く恥ずかしいですよ...";
					if(!_self.product_flg)_self.Elm(".Say3").innerText = "体験版はここまでです。";
					_self.ViewBox("Say3");
					_self.setTimer(function(){
						_self.HiddenBox("Say3");
					},2000);
				}
			}			
			//----------------セリフ---------------
			//--------------脱衣判定--------------
			//ブレザー無し
			if(myBT.touchCount>=100){
				var val = myImg.GetIndexPos("wear");
				if(val==1){
					myImg.SetIndexPos("kao",2);
					myImg.SetIndexPos("wear",3);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao",true,true);
				}
				if(val==9){
					myImg.SetIndexPos("kao",2);
					myImg.SetIndexPos("wear",10);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao",true,true);
				}
			}
			//タイツ無し
			if(myBT.touchCount>=150){					
				var val = myImg.GetIndexPos("taitu");
				if(val==1){
					myImg.SetIndexPos("taitu",0);
					myImg.ImageView("taitu",true,true);
				}
				var val = myImg.GetIndexPos("wear");
				if(val==10){
					myImg.SetIndexPos("kao",4);
					myImg.SetIndexPos("wear",11);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao",true,true);
				}				
			}
			//スカート無し
			if(myBT.touchCount>=250){					
				var val = myImg.GetIndexPos("wear");
				if(val==3){
					myImg.SetIndexPos("wear",4);
					myImg.SetIndexPos("kao_iro",1);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao_iro",true,true);
				}
				if(val==11){
					myImg.SetIndexPos("kao_iro",1);
					myImg.SetIndexPos("wear",12);
					myImg.ImageView("wear",true,true);
					myImg.SetIndexPos("kao_iro",1);
				}				
			}
			//ブラウス無し
			if(myBT.touchCount>=300){					
				var val = myImg.GetIndexPos("wear");
				if(val==4||val==12){
					myImg.SetIndexPos("wear",0);
					myImg.SetIndexPos("kao_iro",1);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao_iro",true,true);
				}
			}
			//ブラ無し
			if(myBT.touchCount>=350){					
				var val = myImg.GetIndexPos("sitagi");
				if(val==2||val==4){
					myImg.SetIndexPos("sitagi",3);
					myImg.SetIndexPos("body",3);
					myImg.ImageView("body",true,true);
					myImg.ImageView("sitagi",true,true);
				}
			}
			//パンツ無し
			if(myBT.touchCount>=500){					
				var val = myImg.GetIndexPos("sitagi");
				if(val==3){
					myImg.SetIndexPos("kao",3);							
					myImg.SetIndexPos("sitagi",0);
					myImg.SetIndexPos("body",4);
					myImg.ImageView("body",true,true);
					myImg.ImageView("kao",true,true);
					myImg.ImageView("sitagi",true,true);
				}					
			}
			//パンツ無し
			if(myBT.touchCount>=500){					
				var val = myImg.GetIndexPos("sitagi");
				if(val==3){
					myImg.SetIndexPos("kao",3);							
					myImg.SetIndexPos("sitagi",0);
					myImg.SetIndexPos("body",4);
					myImg.ImageView("body",true,true);
					myImg.ImageView("kao",true,true);
					myImg.ImageView("sitagi",true,true);
				}					
			}
			//パンツ無し
			if(myBT.touchCount>=550){					
				myImg.SetIndexPos("kao",4);
				myImg.ImageView("kao",true,true);
			}
			//パンツ無し
			if(myBT.touchCount>=600){
				if(_self.product_flg){
					myImg.SetIndexPos("body",5);
					myImg.ImageView("body",true,true);
				}
			}
			//お漏らし
			if(myBT.touchCount>600){
				if(_self.product_flg){
					if((myBT.touchCount%50==0)){
						if(myBT.SetOmorashi!=null){
							myImg.SetIndexPos(myBT.SetOmorashi[0],myBT.SetOmorashi[1]);
							myImg.ImageView("body",true,true);
						}								
						var val = myImg.GetIndexPos("oshikko");
						if(val==0){
							myBT.str_oshikko = "少し出ちゃった...。";
							myBT.SetOmorashi = ["oshikko",1];
						}
						else if(val==1){
							myBT.str_oshikko = "いや、止まらないよぉ...。";
							myBT.SetOmorashi = ["oshikko",2];
							myImg.ImageView("oshikko",true,true);
						}
						else if(val==2){
							myBT.str_oshikko = "お願い見ないでぇ...。";
							myBT.SetOmorashi = ["oshikko",3];
							myImg.ImageView("oshikko",true,true);
						}
						else if(val==3){
							myBT.str_oshikko = "ううう...。こんなの嫌だよぉ。";
							myBT.SetOmorashi = ["oshikko",4];
							myImg.ImageView("oshikko",true,true);
						}
						else if(val==4){
							myBT.str_oshikko = "いや、また出ちゃう！";
							myBT.SetOmorashi = ["oshikko",1];
							myImg.ImageView("oshikko",true,true);
						}
						_self.Elm(".Say3").style.height = "20px";
						_self.Elm(".Say3").innerText = myBT.str_oshikko;
						_self.ViewBox("Say3");
						_self.setTimer(function(){
							_self.HiddenBox("Say3");
						},2000);								
					}
					if(myBT.SetOmorashi!=null){
						myImg.SetIndexPos(myBT.SetOmorashi[0],myBT.SetOmorashi[1]);
						myImg.ImageView("oshikko",true,true);	
					}
				}		
			}
			//--------------脱衣判定--------------
		}
		
		//ミッションモード
		this.MissionMode = function(){
			if(myBT.touchSecCountDown > 0){
				if(myBT.touchSecStop){
					myBT.touchSecStop = false;
					myBT.SecTouchCheck();
				}
				if((myBT.touchCount==1)||(myBT.touchCount%11==0)){
					_self.Elm(".Say1").innerText = "風が強いなぁ...";
					_self.ViewBox("Say1");
					_self.setTimer(function(){
						_self.HiddenBox("Say1");
					},2000);
				}
				if((myBT.touchCount%13==0)){
					if(myBT.MissionSw){
						_self.Elm(".Say2").innerText = "これじゃ、スカートが捲れちゃうよぉ";
						_self.Elm(".Say2").style.height = "50px";
						_self.ViewBox("Say2");
						_self.setTimer(function(){
							_self.HiddenBox("Say2");
						},2000);
					}
				}
				if(myBT.touchCount%15==0){
					if(myBT.MissionSw){
						if(myBT.MissionLV==0){
							myImg.SetIndexPos("body",10);
							myImg.SetIndexPos("taitu",2);
							myImg.SetIndexPos("wear",6);
							myImg.SetIndexPos("kao",2);
							myImg.SetIndexPos("kao_iro",1);
							myImg.ImageView("body",true,true);
							myImg.ImageView("taitu",true,true);
							myImg.ImageView("wear",true,true);
							myImg.ImageView("kao",true,true);
							myImg.ImageView("kao_iro",true,true);
							_self.setTimer(function(){
								if(myBT.touchSecStop)return;
								myImg.SetIndexPos("body",2);
								myImg.SetIndexPos("taitu",1);
								myImg.SetIndexPos("wear",1);
								myImg.SetIndexPos("kao",1);
								myImg.SetIndexPos("kao_iro",0);
								myImg.ImageView("body",true,true);
								myImg.ImageView("taitu",true,true);
								myImg.ImageView("wear",true,true);
								myImg.ImageView("kao",true,true);
								myImg.ImageView("kao_iro",true,true);
							},2000);
						}
						if(myBT.MissionLV==1){
							myImg.SetIndexPos("body",10);
							myImg.SetIndexPos("wear",6);
							myImg.SetIndexPos("kao",2);
							myImg.SetIndexPos("kao_iro",1);
							myImg.ImageView("body",true,true);
							myImg.ImageView("wear",true,true);
							myImg.ImageView("kao",true,true);
							myImg.ImageView("kao_iro",true,true);
							_self.setTimer(function(){
								if(myBT.touchSecStop)return;
								myImg.SetIndexPos("body",2);
								myImg.SetIndexPos("wear",1);
								myImg.SetIndexPos("kao",1);
								myImg.SetIndexPos("kao_iro",0);
								myImg.ImageView("body",true,true);
								myImg.ImageView("wear",true,true);
								myImg.ImageView("kao",true,true);
								myImg.ImageView("kao_iro",true,true);
							},2000);
						}
						if(myBT.MissionLV==2){
							myImg.SetIndexPos("body",10);
							myImg.SetIndexPos("wear",8);
							myImg.SetIndexPos("kao",2);
							myImg.SetIndexPos("taitu",2);
							myImg.SetIndexPos("kao_iro",1);
							myImg.ImageView("wear",true,true);
							myImg.ImageView("kao",true,true);
							myImg.ImageView("taitu",true,true);
							myImg.ImageView("kao_iro",true,true);
							myImg.ImageView("body",true,true);
							_self.setTimer(function(){
								if(myBT.touchSecStop)return;
								myImg.SetIndexPos("body",2);
								myImg.SetIndexPos("wear",3);
								myImg.SetIndexPos("taitu",1);
								myImg.SetIndexPos("kao",1);
								myImg.SetIndexPos("kao_iro",0);
								myImg.ImageView("body",true,true);
								myImg.ImageView("wear",true,true);
								myImg.ImageView("taitu",true,true);
								myImg.ImageView("kao",true,true);
								myImg.ImageView("kao_iro",true,true);
							},2000);
						}
						if(myBT.MissionLV==3){
							myImg.SetIndexPos("body",10);
							myImg.SetIndexPos("wear",8);
							myImg.SetIndexPos("kao",2);
							myImg.SetIndexPos("kao_iro",1);
							myImg.ImageView("wear",true,true);
							myImg.ImageView("kao",true,true);
							myImg.ImageView("kao_iro",true,true);
							myImg.ImageView("body",true,true);
							_self.setTimer(function(){
								if(myBT.touchSecStop)return;
								myImg.SetIndexPos("body",2);
								myImg.SetIndexPos("wear",3);
								myImg.SetIndexPos("kao",1);
								myImg.SetIndexPos("kao_iro",0);
								myImg.ImageView("body",true,true);
								myImg.ImageView("wear",true,true);
								myImg.ImageView("kao",true,true);
								myImg.ImageView("kao_iro",true,true);
							},2000);
						}
						if(myBT.MissionLV==4){
							myImg.SetIndexPos("body",10);
							myImg.SetIndexPos("wear",8);
							myImg.SetIndexPos("kao",2);
							myImg.SetIndexPos("kao_iro",1);
							myImg.ImageView("wear",true,true);
							myImg.ImageView("kao",true,true);
							myImg.ImageView("kao_iro",true,true);
							myImg.ImageView("body",true,true);
							_self.setTimer(function(){
								if(myBT.touchSecStop)return;
								myImg.SetIndexPos("body",2);
								myImg.SetIndexPos("wear",3);
								myImg.SetIndexPos("kao",1);
								myImg.SetIndexPos("kao_iro",0);
								myImg.ImageView("body",true,true);
								myImg.ImageView("wear",true,true);
								myImg.ImageView("kao",true,true);
								myImg.ImageView("kao_iro",true,true);
							},2000);
						}						
						_self.Elm(".Say3").innerText = "もう、いやな風だな...";
						_self.ViewBox("Say3");
						_self.setTimer(function(){
							_self.HiddenBox("Say3");
						},2000);
					}
				}
			}
			if(myBT.touchSecCountDown < 0){
				if(myBT.MissionLV==0){
					myImg.SetIndexPos("body",2);
					myImg.SetIndexPos("taitu",1);
					myImg.SetIndexPos("wear",5);
					myImg.SetIndexPos("kao",4);
					myImg.SetIndexPos("kao_iro",1);
					myImg.ImageView("body",true,true);
					myImg.ImageView("taitu",true,true);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao",true,true);
					myImg.ImageView("kao_iro",true,true);
				}
				if(myBT.MissionLV==1){
					myImg.SetIndexPos("body",2);
					myImg.SetIndexPos("taitu",3);
					myImg.SetIndexPos("wear",5);
					myImg.SetIndexPos("kao",4);
					myImg.SetIndexPos("kao_iro",1);
					myImg.ImageView("body",true,true);
					myImg.ImageView("taitu",true,true);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao",true,true);
					myImg.ImageView("kao_iro",true,true);
				}
				if(myBT.MissionLV==2){
					myImg.SetIndexPos("body",2);
					myImg.SetIndexPos("taitu",1);
					myImg.SetIndexPos("wear",7);
					myImg.SetIndexPos("kao",4);
					myImg.SetIndexPos("kao_iro",1);
					myImg.ImageView("body",true,true);
					myImg.ImageView("taitu",true,true);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao",true,true);
					myImg.ImageView("kao_iro",true,true);
				}
				if(myBT.MissionLV==3){
					myImg.SetIndexPos("body",2);
					myImg.SetIndexPos("taitu",3);
					myImg.SetIndexPos("wear",7);
					myImg.SetIndexPos("kao",4);
					myImg.SetIndexPos("kao_iro",1);
					myImg.ImageView("body",true,true);
					myImg.ImageView("taitu",true,true);
					myImg.ImageView("wear",true,true);
					myImg.ImageView("kao",true,true);
					myImg.ImageView("kao_iro",true,true);
					_self.Elm(".NextLv").innerText = "全レベルクリア！";
				}
				_self.ViewBox("NextLv");
				myBT.touchSecCountDown = 0;
				myBT.touchSecStop = true;
				_self.Elm(".TouchSecCountDown").innerText = myBT.touchSecCountDown.toFixed(2)+"秒";
			}
		}
		
		//イベント設定
		var elementName = myImg.GetCanvasTarget(myBT.lastImage);
		_self.AddEventForId(elementName,function(e){
			_self.Elm(".menu3").innerText = "X:"+e.clientX+",Y:"+e.clientY;
			if((e.clientX>=40)&&(e.clientX<=210)){
				if((e.clientY>=0)&&(e.clientY<=500)){
					myBT.touchCount++;
					_self.Elm(".TouchCount").innerText = myBT.touchCount+"回";
					//通常モード
					if(myBT.mode==0){
						myBT.NormalMode();
					}
					//ミッションモード
					else{
						myBT.MissionMode();
					}
				}
			}
		});
		myBT.AutoTestMode();
	}
}
myBT = new MyTouch();