//設定クラス
function Core(){
	
	//コンストラクタ
	Core.prototype.constructor = function(){
		Core.prototype.Data = [];
		Core.prototype.Main = null;
		Core.prototype.TypeClass = 1;
		Core.prototype.TypeID = 2;
		Core.prototype.TypeName = 1;
		Core.prototype.ClassAdd = 0;
		Core.prototype.ClassDel = 1;
		BaseJsLoaded = true;
	}
	this.constructor();
		
	//設定データ構造取得
	Core.prototype.GetDataStruct = function(){
		var DataStruct = {
			Name:null,
			Value:null,
			Init:null,
			Buff:null,
			flg:false,
			Type:null,
		}
		
		return DataStruct;
	}
	
	//要素作成
	Core.prototype.CreateElm = function(Tag,Key){
		var elm = document.createElement(Tag);
		elm.id = Key;
		return elm;
	}
	
	//要素取得
	Core.prototype.Elm = function(Key,Type=null){
		var res = null;
		var classFlg = (Key.indexOf("#")!==-1);
		var idFlg = (Key.indexOf(".")!==-1);
		var nameFlg = (Key.indexOf("&")!==-1);
		if(classFlg||(Type==1)){
			if(classFlg)Key = Key.substr(1,Key.length-1);
			res = document.getElementsByClassName(Key);
		}
		else if(idFlg||(Type==2)){
			if(idFlg)Key = Key.substr(1,Key.length-1);
			res = document.getElementById(Key);
		}
		else if(nameFlg||(Type==3)){
			if(nameFlg)Key = Key.substr(1,Key.length-1);
			res = document.getElementsByName(Key);
		}
		else{
			res = document.getElementsByTagName(Key);
		}
		
		return res;
	}
	
	//初期化処理
	Core.prototype.Initailize = function(DataList){
		//データ設定
		for(var loop=0;loop<DataList.length;loop++){
			this.AddData(DataList[loop],DataList[loop].type);
		}
	}
	
	//データ追加
	Core.prototype.AddData = function(Data,Type=null){
		Data.Type = Type
		this.Data[Data.Name] = Data;
	}
	
	//データ取得
	Core.prototype.GetData = function(Key,Type=null){
		var res = null;
		if(this.Data[Key]!=undefined){
			if(this.Data[Key].Type == Type)res = this.Data[Key];
		}
		return res;
	}
	
	//タッチイベントチェック
	Core.prototype.CheckTouchEvent = function(){
		var res = false;
		var touch_event = window.ontouchdown;
		var touch_points = navigator.maxTouchPoints;
		if( touch_event !== undefined && 0 < touch_points )res = true;
		return res;
	}
	
	//要素のクラス名を設定/削除/切り替え
	Core.prototype.ClassOpr = function(elm,classname=null,opr=0){
		if(opr==this.ClassAdd){
			if(elm.classList.contains(classname))return;
			elm.classList.add(classname);
		}
		if(opr==this.ClassDel){
			if(!elm.ClassList.contains(classname))return;
			elm.ClassList.remove(classname);
		}
	}
	
}