var Notification = Class.create({
	initialize: function(parent,topMargin){
		this.parentPos = new Element.getLayout(parent);
		this.textBox = new Element('p');
		targetWidth = this.parentPos.get('width');
		targetTop = this.parentPos.get('top')-topMargin;
		this.notificationBox = new Element('div',{'class':'notification'}).setStyle({'display':'none','width':targetWidth+'px','height':'30px','top':targetTop+'px'}).update(this.textBox);
		parent.insert({top:this.notificationBox});
		this.errMode = false;
	},
	setMode: function(err){
		var errormode = (err)?err:false;
		this.errMode = errormode;
		if(errormode == 'true'){
			this.notificationBox.addClassName('error');
		} else {
			this.notificationBox.removeClassName('error');
		}
	},
	show: function(string, autohide, dur, color){
		this.textBox.update(string);
		this.notificationBox.setStyle({'background-color':((color)?color:'transparent')});
		new Effect.SlideDown(this.notificationBox, {duration:.4});
		if(autohide){
			new PeriodicalExecuter(this.hideTimer.bind(this), (dur)?dur:4);
		}
	},
	hideTimer: function(pe){
		pe.stop();
		this.hide();
	},
	hide: function(){
		new Effect.SlideUp(this.notificationBox, {duration:.4,onComplete:this.setMode.bind(this)});
	}
});
