DIV = function(id, parent_id) {
	DIV.superclass.constructor.call(this, id, parent_id);
}

Class(
	DIV, OBJECT,

	"init", function(id, parent_id) {
		DIV.superclass.init.call(this, id, parent_id);
	},

	"clear", function() {
		delete this.el;
		delete this.parent;

		DIV.superclass.clear.call(this);
	},

	"create", function(x, y, w, h) {
		this.parent = YAHOO.util.Dom.get(this.parent_id) ? YAHOO.util.Dom.get(this.parent_id) : document.body;
		this.el = document.createElement("div");
		this.el.id = this.id;
		YAHOO.util.Dom.setStyle(this.el, "font", "12pt malgun");
		this.parent.appendChild(this.el);

		if( w && h ) {
			this.setXYWH(x, y, w, h);
		}
	},

	"destroy", function() {
		try {
			this.parent.removeChild(this.el);
		}
		catch( x ) {
			this.el.outerHTML = "";
		}

		DIV.superclass.destroy.call(this);
	},

	"setClass", function(className) {
		if( !this.el ) {
			return;
		}

		this.el.className = className;
	},

	"setXY", function(x, y) {
		if( !this.el || x == undefined || y == undefined ) {
			return;
		}

		YAHOO.util.Dom.setStyle(this.el, "position", "absolute");
		this.setX(x);
		this.setY(y);
	}, 

	"setXYWH", function(x, y, w, h) {
		if( !this.el || !w || !h ) {
			return;
		}

		YAHOO.util.Dom.setStyle(this.el, "position", "absolute");
		YAHOO.util.Dom.setStyle(this.el, "overflow", "hidden");
		this.setX(x);
		this.setY(y);
		this.setW(w);
		this.setH(h);
	},

	"setX", function(x) {
		if( !this.el || x == undefined ) {
			return;
		}

		this.x = x;
		YAHOO.util.Dom.setStyle(this.el, "left", x + "px");
	},

	"setY", function(y) {
		if( !this.el || y == undefined ) {
			return;
		}

		this.y = y;
		YAHOO.util.Dom.setStyle(this.el, "top", y + "px");
	},

	"setWH", function(w, h) {
		if( !this.el || !w || !h ) {
			return;
		}

		YAHOO.util.Dom.setStyle(this.el, "float", "left");
		YAHOO.util.Dom.setStyle(this.el, "overflow", "hidden");
		this.setW(w);
		this.setH(h);
	},

	"setW", function(w) {
		if( !this.el || !w ) {
			return;
		}

		this.w = w;
		YAHOO.util.Dom.setStyle(this.el, "width", w + "px");
	},

	"setH", function(h) {
		if( !this.el || !h ) {
			return;
		}

		this.h = h;
		YAHOO.util.Dom.setStyle(this.el, "height", h + "px");
	},

	"setBackground", function(background) {
		if( !this.el || !background ) {
			return;
		}

		YAHOO.util.Dom.setStyle(this.el, "background", background);
	},

	"setBorder", function(size, color) {
		if( !this.el ) {
			return;
		}

		size = size || 0;
		color = color || "#000";
		YAHOO.util.Dom.setStyle(this.el, "border", "solid " + size + "px " + color);
	},

	"setTextColor", function(color) {
		if( !this.el ) {
			return;
		}

		color = color || "#000";
		YAHOO.util.Dom.setStyle(this.el, "color", color);
	},

	"setText", function(text) {
		if( !this.el ) {
			return;
		}

		this.el.innerHTML = text;
	},

	"getText", function() {
		if( !this.el ) {
			return "";
		}

		return this.el.innerHTML;
	},

	"setStyle", function(style, value) {
		if( !this.el ) {
			return;
		}

		YAHOO.util.Dom.setStyle(this.el, style, value);
	},

	"show", function() {
		this.setStyle("display", "block");
	},

	"hide", function() {
		this.setStyle("display", "none");
	},

	"setCenter", function() {
		if( !this.w || !this.h ) {
			return;
		}

		if( this.parent_id ) {
			var r = YAHOO.util.Dom.getRegion(this.parent_id);
			var x = Math.floor((r.right - r.left - this.w) / 2);
			var y = Math.floor((r.bottom - r.top - this.h) / 2);
		}
		else {
			var x = Math.floor((YAHOO.util.Dom.getClientWidth() - this.w) / 2);
			var y = Math.floor((YAHOO.util.Dom.getClientHeight() - this.h) / 2);
		}

		this.setX(x);
		this.setY(y);
	}
);

getTextSize = function(text, font, lineHeight, max, ff) {
	if( !(el = YAHOO.util.Dom.get("get_text_width")) ) {
		el = document.createElement("div");
		el.id = "get_text_width";
		document.body.appendChild(el);
		YAHOO.util.Dom.setStyle(el, "visibility", "hidden");
	}

	if( !text || text == "" ) {
		return 1;
	}

	font = font || "9pt verdana";
	lineHeight = lineHeight || "150%";
	max = max || 1000;
	text = text.replace(/\r\n/gi, "<br>");

//	YAHOO.util.Dom.setStyle(el, "display", "");
	YAHOO.util.Dom.setStyle(el, "font", font);
	if( ff ) {
		YAHOO.util.Dom.setStyle(el, "fontFamily", ff);
	}
	YAHOO.util.Dom.setStyle(el, "lineHeight", lineHeight);
	YAHOO.util.Dom.setStyle(el, "wordBreak", "break-all");
	YAHOO.util.Dom.setStyle(el, "position", "absolute");
	YAHOO.util.Dom.setStyle(el, "left", "0");
	YAHOO.util.Dom.setStyle(el, "top", "0");
	YAHOO.util.Dom.setStyle(el, "width", "1px");
	YAHOO.util.Dom.setStyle(el, "height", "1px");
	YAHOO.util.Dom.setStyle(el, "overflow", "visible");
	YAHOO.util.Dom.setStyle(el, "background", "#ff9999");
	el.innerHTML = text;
	YAHOO.util.Dom.setStyle(el, "width", "");
	YAHOO.util.Dom.setStyle(el, "height", "");

	var r = YAHOO.util.Dom.getRegion(el);
//	YAHOO.util.Dom.setStyle(el, "display", "none");

	if( r.right > max ) {
		YAHOO.util.Dom.setStyle(el, "width", max + "px");
		YAHOO.util.Dom.setStyle(el, "overflow", "hidden");
		r = YAHOO.util.Dom.getRegion(el);
	}

	return { width: r.right, height: r.bottom };
}



