if(window.TOOL === undefined) {
    document.write('<script type="text/javascript" src="/javascript/cropper/tool.js"></script>');
}
if(window.POSITION === undefined) {
    document.write('<script type="text/javascript" src="/javascript/core/Position.js"></script>');
}
if(window.Animator === undefined) {
    document.write('<script type="text/javascript" src="/javascript/core/Animator.js"></script>');
}

/**
 * Notifier
 * @param {type} param 
 */
 var Notifier = __class__();
 Notifier.prototype = {
 	__construct : function(sMessage, iTotalTime)
 	{
 		this.note = sMessage;
 		this.totalTime = iTotalTime;
 		this.timer = null;
 		this.init();
 	},
 	
 	init : function()
 	{
 		this.messageBoard = this.createBoard();
 		var message = this.createMessage();
 		this.messageBoard.appendChild(message);
 		document.body.appendChild(this.messageBoard);

 		var anim = new Animator.Css();
 		anim.animate(this.messageBoard, 'top', POSITION.getScrollOffset('y') + 20, this.totalTime*1.5, 1);
 		var fade = this.fade.bind(this);
 		this.timer = setTimeout(fade, this.totalTime*3);
 		EventUtil.addEventHandler(window, 'scroll', fade);
 	},
 	
 	createBoard : function()
 	{
 		var board = TOOL.extendElement(document.createElement('div'));
 		var bstyle = {
 			'width' : '240px',
 			'height' : '40px',
 			'position' : 'absolute',
 			'text-align' : 'center',
 			'z-index' : '9999',
 			'background-color' : '#ffff66',
 			'border' : '1px solid #ffbe22',
 			'top' : POSITION.getScrollOffset('y') - 1000 + 'px',
 			'left' : (POSITION.getInnerSize('width') - 240)/2 + 'px'
 		}
 		board.setStyle(bstyle);
 		return board;
 	},
 	
 	createMessage : function()
 	{
 		var msg = TOOL.extendElement(document.createElement('span'));
 		var s = {
 			'font' : 'bold 13px/1em Verdana, Arial, sans-serif',
 			'color' : '#000',
 			'position' : 'relative',
 			'top' : (parseInt(this.messageBoard.style.height) - 13)/2 + 'px'
 		}
 		msg.setStyle(s);
 		msg.appendChild(document.createTextNode(this.note));
 		return msg;
 	},
 	
 	fade : function()
 	{
 		clearTimeout(this.timer);
 		this.timer = null;
 		
 		var kill = this.remove.bind(this);
 		
 		var f = new Animator.Opacity();
 		f.animate(this.messageBoard, 0, this.totalTime, 2, null, kill);
 	},
 	
 	remove : function()
 	{
 		try{
 			document.body.removeChild(this.messageBoard);
 		} catch (e) { e = null; }
 	}
 }
 	