<!--
/******************************************************************************
 *
 * /js/net/highbase/util/logger.js
 *
 *  Author	highbase
 *	create	2005.03.31
 *	modify	2005.04.02	ÃÖÃÊ ·Î°Å°¡ µ¿ÀÛÇÏÁö ¾Ê´Â ¿À·ù¼öÁ¤
 *			2005.04.21	´Ù¸¥ Å¬·¡½ºÀÇ µµ¿òÀÌ ÇÊ¿ä ¾øµµ·Ï ¼öÁ¤ ÇÔ.
 *
 ******************************************************************************/
Logger = function (b) {
	this.COOKIE_NAME = "_LOGGER_";
	this.COOKIE_VALUE = "ACT";
	this.WINDOW_BASE_NAME = "_LOG_DISPLAY_";
	this.debug = false;
	this.oOut = null;
	this.sWinName = null;
	this.mode = "";
	this.bb = false;
	if (this.debug) alert("L#17 b=["+b+"]");
	try {
		this.cookie = new Cookie();
	} catch(e) {
		;
	}
	if (this.debug) alert("L#19 this.cookie=["+ this.cookie +"]");
	if (this.debug) alert("L#19 (typeof(b) == \"undefined\" || b == false)=["+ (typeof(b) == "undefined" || b == false) +"]");
	if ((typeof(b) == "undefined") && typeof(this.cookie) == "object")
	{
		try {
			if (this.debug) alert("L#19 this.cookie.get(this.COOKIE_NAME)=["+ this.cookie.get(this.COOKIE_NAME) +"]");
			this.bb = (this.COOKIE_VALUE == (this.cookie.get(this.COOKIE_NAME)));
		}
		catch(e) {
			if (this.debug) alert("Cookie°¡ ¾ø½À´Ï´Ù.");
		}
	}
	else {
		this.bb = b;
	}
	if (this.debug) alert("L#19 this.bb=["+this.bb+"]");
	if (this.bb) {
		this.init();
	}
	else if (typeof(this.cookie) == "object") {
		this.cookie.remove(this.COOKIE_NAME);
	}
}

Logger.prototype.init = function() {
	try {
		if (typeof(this.cookie) == "object")
			this.cookie.set(this.COOKIE_NAME, this.COOKIE_VALUE);
		this.open();
		if (this.oOut.document.body == null || this.oOut.document.body.innerHTML == "")
		{
			this.write("<title>### Highbase Script Logger ###</title>");
			this.write("<style> body {font-size:12px; background-color:ddeedd; } </style>");
		}
		this.oOut.scrollBy(0, 10000);
	}
	catch(e) {
		;
	}
}

Logger.prototype.open = function() {
	//if (this.debug) alert("·Î±× À©µµ¿ì ¿­±â");
	this.sWinName = this.WINDOW_BASE_NAME + new Date().getHours();
	//if (this.debug) alert("this.sWinName=" + this.sWinName);
	try {
		this.oOut = window.open("", this.sWinName, "width=600, height=300, scrollbars=yes, resizable=yes");
		//if (this.debug) alert("·Î±× À©µµ¿ì ¿­±â ¼º°ø");
	}
	catch(e) {
		//if (this.debug) alert(e);
	}
}

Logger.prototype.log = function(s) {
	var i = 0;
	try	{
		this.write("<div><font color=\"#6699cc\">");
		this.write(this.getYYYYMMDD());
		this.write(" ");
		this.write(this.getHHMMSS());
		this.write(" ");
		if (this.mode != "") {
			this.write(this.mode);
			this.write(" ");
		}
		this.write(location.pathname);
		this.write("</font> ");
		this.write(s);
		this.write("</div>");
	}
	catch(e) {
		if (this.debug) alert("L#80 e=["+e+"]");
	}
	try	{
		this.oOut.scrollBy(0, 10000);
	}
	catch(e) {
		if (this.debug) alert("L#81 e=["+e+"]");
	}
}

Logger.prototype.write = function(s) {
	try {
		this.oOut.document.write(s);
	}
	catch(e) {
		if (this.debug) alert("L#95 e=["+e+"]");
	}
}

Logger.prototype.clear = function() {
	if (this.isAlive())
	{
		this.oOut.document.open();
	}
}

Logger.prototype.close = function() {
	if (this.isAlive())
	{
		this.oOut.close();
		this.oOut = null;
		this.debug = false;
	}
}

Logger.prototype.on = function() {
	this.init();
}

Logger.prototype.off = function() {
	this.close();
}

Logger.prototype.isActive = function() {
	return this.isAlive();
}

Logger.prototype.isAlive = function() {
	try {
		if (this.oOut != null)
			return true;
		else
			return false;
	}
	catch (e) {
		return false;
	}
}

Logger.prototype.getYYYYMMDD = function() {
	var d = new Date();
	var delimiter = "-";
	
	return d.getYear() + "-" 
		+ (this.get00(d.getMonth() + 1)) + delimiter
		+ (this.get00(d.getDate()));
}

Logger.prototype.getHHMMSS = function() {
	var d = new Date();
	var delimiter = ":";

	return (this.get00(d.getHours())) + delimiter
		+ (this.get00(d.getMinutes())) + delimiter
		+ (this.get00(d.getSeconds()));
}

Logger.prototype.get00 = function(s) {
	s = "0" + s;
	return s.substring(s.length - 2, s.length);
}
// -->
