/**
 * テンプレートクラス
 *
 * @param
 * @return
 */
function templateAbstract() {
	this.id = null;
	this.html = null;
	this.outDiv = null;
	this.tagMap = null;
}
templateAbstract.templateHash = new Object();

templateAbstract.prototype.getTemplate = function() {
	var htmltext="";
	if (this.id != null && typeof(templateAbstract.templateHash[this.id]) != "undefined") {
		htmltext = templateAbstract.templateHash[this.id];
	} else {
		var xmlhttp = this.getXMLHttp();
		var ts=new Date().getTime();
		var url=homesGlobal.baseurl+"/homes/template/"+this.id+".template?"+ts;
	    xmlhttp.open("GET", url, false);
	    xmlhttp.send(null);
	    if (xmlhttp.status == 200 || xmlhttp.status == 304) {
	    	htmltext=xmlhttp.responseText;
	    	if (this.id != null) {
		    	templateAbstract.templateHash[this.id] = htmltext;
	    	}
		}
	}
	return htmltext.replace(/[\t\r\n]/g,"");
}

templateAbstract.prototype.getXMLHttp = function() {

    var xmlhttp;

    try {
    	xmlhttp = new XMLHttpRequest();
    } catch(e) {
    	try {
    		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch(e) {
    		try {
    			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    		} catch(e) {
    			xmlhttp = null;
    		}
    	}
    }

    return xmlhttp;
};

templateAbstract.prototype.putTemplate = function(data) {
	var a = new Template(this.tagMap).compile(this.html);
	this.outDiv.innerHTML = a(data);
}

templateAbstract.prototype.getHTML = function(data) {
	var a = new Template(this.tagMap).compile(this.html);
	return a(data);
}

/**
 * アイコン
 *
 * @param
 * @return
 */
function templateIcon(tid, icontype) {
	this.id = tid+icontype;
	this.icontype = icontype;
	this.html = this.getTemplate();
	this.tagMap = {
	};
}

templateIcon.prototype = new templateAbstract;

templateIcon.prototype.putTemplate = function(data) {
	data.type = this.icontype;
	var a = new Template(this.tagMap).compile(this.html);
	this.outDiv.innerHTML = a(data);
}

templateAbstract.prototype.getHTML = function(data) {
	data.type = this.icontype;
	var a = new Template(this.tagMap).compile(this.html);
	return a(data);
}


/**
 * ウィンドウ
 *
 * @param
 * @return
 */
function templateWindow(tid, outdiv) {
	this.id = tid;
	this.html = this.getTemplate();
	this.outDiv = outdiv;
	this.tagMap = {
	};
}

templateWindow.prototype = new templateAbstract;

/**
 * 条件表示
 *
 * @param
 * @return
 */
function templateCondition(tid, outdiv) {
	this.id = tid;
	this.html = this.getTemplate();
	this.outDiv = outdiv;
	this.tagMap = {
	};
}

templateCondition.prototype = new templateAbstract;

