//メイン処理
var ver_str = "ver.1.1.0";
var myImg = null;
var myBT = null;
Main.ProcStart = function(){
	if(window.parent.caches!=undefined)window.parent.caches.delete("call");
	var _this = null;
	_this = new BaseJs();
	_self = _this;
	//製品フラグ
	var input_option = location.search.substr(1,location.search.length);
	_self.product_flg = (input_option.indexOf("true")==-1);
	console.log("製品モード:"+_self.product_flg);
	var width = Main.DisplayWidth(500);
	var height = Main.DisplayHeight(600);
	_this.setWidthHi(width);
	_this.setHeightHi(height);
	if(!_self.product_flg)ver_str += "\n通常版";
	if(_self.product_flg)ver_str += "\n製品版";	
	//暗幕
	Main.Loading(_this,width+"px",height+"px");
	//メイン処理
	Main.MainProc = function(){
		document.oncontextmenu = function () {return false;}
		//データ名設定
		//画像表示用カスタムクラス読み込み
		Main.oneload = false;
		Main.ScriptLoad("./MyBoxTouch.js?202305082359");
		var imgLoad = Main.ScriptLoad("./MyImage.js?202305082359");	
		Main.WaitLoad = function(){
			if(myBT==null){
				_this.setTimer(Main.WaitLoad,100);
				return;
			}
			else if(myImg==null){
				_this.setTimer(Main.WaitLoad,100);
				return;
			}
			_this.InitProgeress = function(_this){
				_this.Elm(".Progress").innerText = parseInt(myImg.InitializeProgress*100)+"%";
				if(parseInt(myImg.InitializeProgress*100)<100){
					_this.setTimer(_this.InitProgeress,100,_this);
				}else{
					_this.setTimer(function(_this){
						if(_this.Elm(".Progress").innerText!=""){
							_this.Elm(".Progress").innerText = "まもなく起動します...";
						}
					},500,_this);
				}
			}
			_this.InitProgeress(_this);
			myImg.InitImageView();
		}
		Main.WaitLoad();
		//枠描画
		_this.ViewInitializeBox = function(){
			var elm = _this.Elm("anmaku",_this.TypeID);
			if(elm.style.display!="none"){
				_this.setTimer(_this.ViewInitializeBox,1000);
				return;
			}
			//枠を生成
			var parent =  _this.Elm("body");
			var imgElm = _self.Elm(".image");
			elm_div = _self.GetInitBox();
			elm_div = _self.SetBoxParam(elm_div,"StartMsg",imgElm.width+"px",imgElm.height+"px");
			_self.AddBoxData(elm_div);
			_self.SettingBox(parent[0],elm_div.Name,"");
			_self.Elm(".StartMsg").innerHTML += "<br>";
			_self.Elm(".StartMsg").innerHTML += "<br>";
			_self.Elm(".StartMsg").innerHTML += "<br>";
			_self.Elm(".StartMsg").innerHTML += "<br>";
			_self.Elm(".StartMsg").innerHTML += "<br>";
			_self.Elm(".StartMsg").innerHTML += "<br>";
			_self.Elm(".StartMsg").innerHTML += "<span id='Msg'>開始まで...</span><span id='countDown'></span>";
			_self.Elm(".StartMsg").style.textAlign="center";
			_self.Elm(".StartMsg").style.fontSize="20pt";
			myBT.Start = function(restart=false){
				myDataCtrl.SetDataName("TouchGirl");
				if(myBT.mode!=0){
					if(myBT.MissionLV==1){
						myImg.SetIndexPos("taitu",3);
						myImg.ImageView("taitu",true,true);
					}
					if(myBT.MissionLV==2){
						myImg.SetIndexPos("wear",3);
						myImg.SetIndexPos("taitu",1);
						myImg.ImageView("wear",true,true);
						myImg.ImageView("taitu",true,true);
					}
					if(myBT.MissionLV==3){
						myImg.SetIndexPos("wear",3);
						myImg.SetIndexPos("taitu",3);
						myImg.ImageView("wear",true,true);
						myImg.ImageView("taitu",true,true);
					}
				}
				if(myBT.CountDown == undefined)myBT.CountDown = 9;
				if(myBT.CountDown<=3){
					_self.Elm(".Msg").innerText ="開始まで...";
					_self.Elm(".countDown").innerText = myBT.CountDown;
				}
				if(myBT.CountDown==9){
					if(myBT.mode==0)_self.Elm(".Msg").innerText ="遊び方は簡単！";
					if(myBT.mode==1)_self.Elm(".Msg").innerText ="ミッションモード遊び方！";
				}
				if(myBT.CountDown==7){
					if(myBT.mode==0)_self.Elm(".Msg").innerText ="女の子をタッチしまくって";
					if(myBT.mode==1)_self.Elm(".Msg").innerHTML ="指定秒間タッチ回数以上を<br>30秒間キープするだけ！";
				}
				if(myBT.CountDown==5){
					if(myBT.mode==0)_self.Elm(".Msg").innerHTML ="服を脱がすだけ！<br>※まずは800回タッチしてね☆";
					if(myBT.mode==1)_self.Elm(".Msg").innerHTML =myBT.MissionMsg[myBT.MissionLV];
				}
				if(myBT.CountDown<0){
					_self.HiddenBox("StartMsg");
					if(!restart)myBT.setBoxTouch(parent);
					if(restart){
						_self.ViewBox("menu2");
						_self.ViewBox("reset");
						if(myBT.mode==1){
							_self.Elm(".mode1").style.display = "none";
							_self.Elm(".mode2").style.display = "";
							myBT.startTime2 = 0;
						}else{
							_self.Elm(".mode1").style.display = "";
							_self.Elm(".mode2").style.display = "none";
						}
						myBT.startTime = Date.now();			
						myBT.touchSecStop = false;
						myBT.SecTouchCheck();						
					}
					myBT.CountDown = 9;
					_self.Elm(".Msg").innerText = "遊び方は簡単！";
					_self.Elm(".countDown").innerText = "";
				}
				else{
					_self.setTimer(myBT.Start,1000,restart);
				}
				myBT.CountDown--;

			}
			myBT.Start();
		}
		_this.ViewInitializeBox();
	}
	Main.MainProc();
}
Main.Start(Main.ProcStart);
