//枠作成クラス
function BoxMaker(){
	//コンストラクタ
	BoxMaker.prototype.constructor = function(){
		BoxMaker.prototype.Data = [];
	}
	this.constructor();
	
	
	//枠データ取得
	BoxMaker.prototype.GetInitBox = function(){
		var ResData = {
			Name:null,
			Type:"box",
			x:0,
			y:0,
			width:0,
			height:0,
			linecolor:null,
			bgcolor:null,
			txtcolor:null,
			display:"none",
			opacity:0.8,
		}
		
		return ResData;
	}
	
	//枠データ追加
	BoxMaker.prototype.AddBoxData = function(Data){
		this.AddData(Data,"box");
	}
	
	//枠データ取得
	BoxMaker.prototype.GetBoxData = function(Key){
		return this.GetData(Key,"box");
	}
	
	//枠表示
	BoxMaker.prototype.ViewBox = function(Key){
		var tmp = this.Elm("."+Key);
		if(tmp==null)return;
		tmp.style.display = "";
	}
	
	//枠非表示
	BoxMaker.prototype.HiddenBox = function(Key){
		var tmp = this.Elm("."+Key);
		if(tmp==null)return;
		tmp.style.display = "none";
	}
	
	//表示状態
	BoxMaker.prototype.GetBoxStatus = function(Key){
		if(this.Elm("."+Key)==undefined) return false;
		return this.Elm("."+Key).style.display==""?true:false;
	}
	
	//コマンド追加
	BoxMaker.prototype.AddCommand = function(addElmId,Key,str,display=null){
		var selm = this.CreateElm("p",Key);
		selm.innerText = str;
		selm.style.textAlign = "center";
		selm.style.display = display;
		var IdKey = "."+addElmId;
		var elm = this.Elm(IdKey);
		elm.appendChild(selm);
	}
	
	BoxMaker.prototype.AddCommandDiv = function(addElmId,Key,str,display=null){
		var selm = this.CreateElm("div",Key);
		selm.innerText = str;
		selm.style.textAlign = "center";
		selm.style.display = display;
		var IdKey = "."+addElmId;
		var elm = this.Elm(IdKey);
		elm.appendChild(selm);
	}	
	
	//コマンドタッチイベント追加
	BoxMaker.prototype.AddEventForId = function(Key,func){
		Key = "."+Key;
		var elm = this.Elm(Key);
		elm.onmousedown = func;
		elm.ontouchstart = func;
	}
	
	//枠データ設置
	BoxMaker.prototype.SettingBox = function(parent,Key,display=null){
		var selm = this.CreateElm("div",Key);
		var elm = this.GetBoxData(Key);
		if(display!=null)elm.display = display;
		selm.style.top = elm.y;
		selm.style.left = elm.x;
		selm.style.width = elm.width;
		selm.style.height = elm.height;
		selm.style.display = elm.display;
		selm.style.backgroundColor = elm.bgcolor;
		selm.style.color = elm.txtcolor;
		selm.style.border = elm.linecolor;
		selm.style.position = "absolute";
		selm.style.opacity = elm.opacity;
		parent.appendChild(selm);
	}

	//パラメータセット
	BoxMaker.prototype.SetBoxParam = function(data,Name,width,height,option=null){
		data.Name = Name;
		data.width = width;
		data.height = height;
		data.bgcolor = "#303030";
		data.txtcolor = "#F0F0F0";
		data.linecolor = "solid 1px #0F0F0F";
		data.opacity = 0.8;
		if(option!=null){
			if(option.bgcolor)data.bgcolor = option.bgcolor;
			if(option.txtcolor)data.txtcolor = option.txtcolor;
			if(option.linecolor)data.linecolor = option.linecolor;
			if(option.opacity)data.opacity = option.opacity;
		}
		return data;
	}	
	
	//枠データ設置
	BoxMaker.prototype.ChangeBox = function(Key){
		var selm = this.Elm("."+Key);
		var elm = this.GetBoxData(Key);
		selm.style.top = elm.y;
		selm.style.left = elm.x;
		selm.style.width = elm.width;
		selm.style.height = elm.height;
		selm.style.backgroundColor = elm.bgcolor;
		selm.style.color = elm.txtcolor;
		selm.style.border = elm.linecolor;
		selm.style.position = "absolute";
		selm.style.opacity = elm.opacity;
	}	
	
}