Logger = function() {
	// Declare public instance variable(s)
	this.className = "";

	this.doLogging = function(messageToPrint, severity) {
		if (!Logger.debugWindow || Logger.debugWindow.closed) {
			var oWindow = window.open("", null, "width=1000,height=400,scrollbars=yes,resizable=yes,status=no,location=no,menubar=no,toolbar=no");
			if (!oWindow) {
				return;
			}
			var oDocument = oWindow.document;
			oDocument.write("<html><head><title>Debug Log</title></head><body></body></html>");
			oDocument.close();
			Logger.debugWindow = oWindow;
		}

		var logLine = Logger.debugWindow.document.createElement("div");
		logLine.style.whiteSpace = "nowrap";

		var fontColor = "black";
		var severityName = "";

		if (severity == Logger.DEBUG) {
			fontColor = "lightgreen";
			severityName = "DEBUG";
		} else if (severity == Logger.LOG) {
			fontColor = "blue";
			severityName = "LOG";
		} else if (severity == Logger.INFO) {
			fontColor = "green";
			severityName = "INFO";
		} else if (severity == Logger.WARNING) {
			fontColor = "orange";
			severityName = "WARN";
		} else if (severity == Logger.ERROR) {
			fontColor = "red";
			severityName = "ERROR";
		}

		var currentTime = new Date();
		var year = (currentTime.getFullYear() + "").padLeft(4, "0");
		var month = (currentTime.getMonth() + 1 + "").padLeft(2, "0");
		var day = (currentTime.getDate() + "").padLeft(2, "0");
		var hour = (currentTime.getHours() + "").padLeft(2, "0");
		var minute = (currentTime.getMinutes() + "").padLeft(2, "0");
		var second = (currentTime.getSeconds() + "").padLeft(2, "0");
		var milliSecond = (currentTime.getMilliseconds() + "").padLeft(3, "0");
		severityName = severityName.padRight(5, "&nbsp;");
		var formattedDate = year + "." + month + "." + day + " " + hour + ":" + minute + ":" + second + ":" + milliSecond;

		logLine.innerHTML = "<b><font size='0' face='courier' color='" + fontColor + "'>" + formattedDate + " - " + severityName + " - " + this.className + " - " + messageToPrint + "</font></b>";

		Logger.debugWindow.document.body.appendChild(logLine);
	};
	this.debug = function(messageToPrint) {
		if (Logger.logLevels[this.className]) {
			if (Logger.logLevels[this.className] <= Logger.DEBUG) {
				this.doLogging("&nbsp;&nbsp;&nbsp;&nbsp;" + messageToPrint, Logger.DEBUG);
			}
		}
	};
	this.log = function(messageToPrint) {
		if (Logger.logLevels[this.className]) {
			if (Logger.logLevels[this.className] <= Logger.LOG) {
				this.doLogging("&nbsp;&nbsp;" + messageToPrint, Logger.LOG);
			}
		}
	};
	this.info = function(messageToPrint) {
		if (Logger.logLevels[this.className]) {
			if (Logger.logLevels[this.className] <= Logger.INFO) {
				this.doLogging(messageToPrint, Logger.INFO);
			}
		}
	};
	this.warn = function(messageToPrint) {
		if (Logger.logLevels[this.className]) {
			if (Logger.logLevels[this.className] <= Logger.WARNING) {
				this.doLogging(messageToPrint, Logger.WARNING);
			}
		}
	};
	this.error = function(messageToPrint) {
		if (Logger.logLevels[this.className]) {
			if (Logger.logLevels[this.className] <= Logger.ERROR) {
				this.doLogging(messageToPrint, Logger.ERROR);
			}
		}
	};
	this.enter = function(methodName) {
		this.log(methodName + " was called.")
	};

	this.complete = function(methodName) {
		this.log(methodName + " completed successfully.")
	};

};
// Declare static variable(s)
Logger.logLevels = new Object();
Logger.debugWindow;

// Declare default logLevels interpreded as contants
Logger.DEBUG = 10;
Logger.LOG = 20;
Logger.INFO = 30;
Logger.WARNING = 40;
Logger.ERROR = 50;
Logger.NONE = 60;

Logger.DEFAULT_LOG_LEVEL = Logger.NONE;

// Declare custom log levels for classes
Logger.customLevel = new Object();
Logger.customLevel["ImageUtil"] = Logger.NONE;
Logger.customLevel["Animation"] = Logger.NONE;
Logger.customLevel["Iframe"] = Logger.NONE;
// Declare static functions
Logger.getLogger = function(className) {
	var logger = new Logger();
	if (!Logger.logLevels[className]) {
		if (Logger.customLevel[className]) {
			Logger.logLevels[className] = Logger.customLevel[className];
		} else {
			Logger.logLevels[className] = Logger.DEFAULT_LOG_LEVEL;
		}
	}
	logger.className = className;
	return logger;
}

