﻿/*
 * Create Object Box
 */
function CreateBox$BTD(util, pathImgSpacer, myName, headerText, content, style)
{
	this.util = util;
	this.myName = myName;
	this.style = style;
	this.headerText = headerText;
	this.content = content;
	this.elContent = null;
	this.pathImgSpacer = pathImgSpacer;
};

CreateBox$BTD.prototype = 
{
	createMain : function(w)
	{
		var oTable = this.util.createEl("TABLE");
		oTable.id = this.myName;
		oTable.className = "box_content" + this.style;
		if (typeof(w) != "undefined")
		{
			oTable.style.width = w + "px";
		}
		oTable.cellPadding = 0;
		oTable.cellSpacing = 0;
		oTable.border = 0;
		var oTbody = this.util.createEl("TBODY");
		// Create header
		oTbody.appendChild(this.createHeader());
		// Create body
		oTbody.appendChild(this.createBody());
		// Create footer
		oTbody.appendChild(this.createFooter());
		oTable.appendChild(oTbody);
		this.oOut = oTable;
		return oTable;
	},

	changeStyleNow : function(style)
	{
		if (this.style == style) return;
		this.util.changeStyleAll(this.oOut, this.style, style, "box");
		this.style = style;
	},
	
	createHeader : function()
	{
		var oTR = this.util.createEl("TR");
		var oTD = this.util.createEl("TD");
		var oDiv = this.util.createEl("div");
		oDiv.className = "box_header_L" + this.style;
		oTD.appendChild(oDiv);
		oTR.appendChild(oTD);
		
		oTD = this.util.createEl("TD");
		oTD.className = "box_header_C" + this.style;
		oTD.appendChild(this.createHeaderContent());
		oTR.appendChild(oTD);
		
		oTD = this.util.createEl("TD");
		oDiv = this.util.createEl("div");
		oDiv.className = "box_header_R" + this.style;
		oTD.appendChild(oDiv);
		oTR.appendChild(oTD);
		return oTR;
	},
	
	createBody : function()
	{
		var oTR = this.util.createEl("TR");
		var oTD = this.util.createEl("TD");
		oTD.colSpan = "3";
		oTD.className = "box_body" + this.style;
		oTD.appendChild(this.createContent());
		oTR.appendChild(oTD);
		return oTR;
	},
	
	createFooter : function()
	{
		var oTR = this.util.createEl("TR");
		oTR.className = "box_footer" + this.style;
		var oTD = this.util.createEl("TD");
		oTD.className = "box_footer_L" + this.style;
		oTR.appendChild(oTD);
		oTD = this.util.createEl("TD");
		oTR.appendChild(oTD);
		oTD = this.util.createEl("TD");
		oTD.className = "box_footer_R" + this.style;
		oTR.appendChild(oTD);
		return oTR;
	},
	
	createHeaderContent : function()
	{
		var oTable = this.util.createEl("TABLE");
		oTable.cellPadding = 0;
		oTable.cellSpacing = 0;
		oTable.border = 0;
		oTable.style.width = "100%";
		var oTbody = this.util.createEl("TBODY");
		oTbody.appendChild(this.createHeaderText());
		oTbody.appendChild(this.createHeaderLine());
		oTable.appendChild(oTbody);
		return oTable;
	},
	
	createHeaderText : function()
	{
		var oTR = this.util.createEl("TR");
		// Create img right
		var oTD = this.util.createEl("TD");
		var oDiv = this.util.createEl("DIV");
		this.oHeader = oDiv;
		oDiv.className = "titleBlock";
		oDiv.innerHTML = this.headerText;
		oTD.appendChild(oDiv);
		oTR.appendChild(oTD);
		return oTR;
	},
	
	createHeaderLine : function()
	{
		var oTR = this.util.createEl("TR");
		// Create img right
		var oTD = this.util.createEl("TD");
		oTD.style.textAlign = "center";
		oTD.style.fontSize = "1px";
		var img = this.createImgSpacer(this.pathImgSpacer, "box_line" + this.style);
		oTD.appendChild(img);
		oTR.appendChild(oTD);
		return oTR;
	},
	
	createContent : function()
	{
		var o = this.util.createEl("DIV");
		o.className = "box_body_C" + this.style;
		o.innerHTML = this.content;
		this.elContent = o;
		return o;
	},
	
	createImgSpacer : function(path, className)
	{
		var o = this.util.createEl("IMG");
		o.className = className;
		o.src = path;
		return o;
	},

/*****************************************************************************
								Set Content Start
*****************************************************************************/
	setTextBox : function(textHeader, textContent)
	{
		this.setTextHeader(textHeader);
		this.setContent(textContent);
	},
	
	setTextHeader : function(text)
	{
		this.oHeader.innerHTML = text;
		this.headerText = text;
	},
	
	setContent : function(content)
	{
		this.elContent.innerHTML = content;
		this.content = content;
	}
/*****************************************************************************
								Set Content End
*****************************************************************************/

};