function myLogger(id){
	id = id || 'herowkLogwindow';
	var logWindow = null;
	var createWindow = function (){
		
		//get the new window's location and the top and left value
		var browserWindowSize = herowk.getBrowserWindowSize();
		var top = ((browserWindowSize.height - 200) / 2) || 0;
		var left = ((browserWindowSize.width - 200) /2) || 0;
		
		//create a new dom node which for the log window use
		logWindow = document.createElement('ul');
		
		//set the id
		logWindow.setAttribute('id',id);
		
		//locate the log window
		logWindow.style.position = 'absolute';
		logWindow.style.top = top + 'px';
		logWindow.style.left = left + 'px';
		
		//set the size and scroll type
		logWindow.style.width = '200px';
		logWindow.style.height = '200px';
		logWindow.style.overflow = 'scroll';
		
		//add some style~~
		logWindow.style.padding = '0';
		logWindow.style.margin = '0';
		logWindow.style.border = '1px solid black';
		logWindow.style.backgroundColor = 'white';
		logWindow.style.listStyle = 'none';
		logWindow.style.font = '10px/10px Verdana, Tahoma, Sans';
		
		//add the window into the document...
		document.body.appendChild(logWindow);
		};
	this.writeRaw = function (message) {
		//if the log window dosen't exist,create it
		if(!logWindow) createWindow();
		
		//create the list and add some style
		var li = document.createElement('li');
		li.style.padding = '12px';
		li.style.border = '0';
		li.style.borderBottom = '1px dotted black';
		li.style.margin = '0';
		li.style.color = '#000';
		li.style.font = '9px/9px Verdana, Tahoma, Sans';
		
		//add the message for the log node
		if(typeof message == 'undefined') {
			li.appendChild(document.createTextNode('Message was undefined'));
		} else if (typeof li.innerHTML != 'undefined' ) {
			li.innerHTML = message;
		} else {
			li.appendChild(document.createTextNode(message));
		}
		
		//add this node to the log window
		logWindow.appendChild(li);
		
		return true;
	};
};

myLogger.prototype = {
	write: function (message){
	//if the message is empty
	if(typeof message == 'string' && message.length ==0){
	    return this.writeRaw('herowk.log: null message');
	}

	//if the message is not string,try to call the toString method
	if(typeof message != 'string'){
	    if (message.toString) return this.writeRaw(message.toString());
	    else return this.writeRaw(typeof message);
	}
	
	//convert the char '<' and '>'
	message = message.replace(/</g,"&lt;").replace(/>/g,"&gt;");

	return this.writeRaw(message);
    },
	header: function (message){
	message = '<span style="color:white;background-color:black;font-weight:bold;padding:0px tpx;">' + message + '</span>';
	return this.writeRaw(message);
    }
};

if(!window.herowk) {window['herowk'] = {};}
window['herowk']['log'] = new myLogger();
