var Message = Class.create({
	initialize: function() {
		this.alert_div = "messagebox";
		this.timeout;
	},
	
	alert: function(str_message) {
		// hide error box
		Error.hide();
		
		// cancel timeout
		this.cancel_timeout();

		// show msg
		$(this.alert_div).update(str_message).show();
		
		// scroll
		$('top').scrollTo();
		
		// fade it
		this.fade();
	},
	
	fade: function() {
		this.timeout = setTimeout("new Effect.Fade($('" + this.alert_div + "'));", 4000 );
	},
	
	cancel_timeout: function() {
		// clear error's timeout
		if(this.timeout) {
			clearTimeout(this.timeout);
		}
	},
	
	hide: function() {
		this.cancel_timeout();
		$(this.alert_div).hide();
	}
});


var Error = Class.create({
	initialize: function() {
		this.alert_div = 'errorbox';
		this.timeout;
	},
	
	alert: function(str_message) {
		Message.hide();
		
		// cancel timeout
		this.cancel_timeout();
		
		// show msg
		$(this.alert_div).update(str_message).show();
		
		// scroll
		$('top').scrollTo();
		
		// fade it
		this.fade();
	},
	
	fade: function() {
		this.timeout = setTimeout("new Effect.Fade($('" + this.alert_div + "'));", 8000 );
	},
	
	cancel_timeout: function() {
		// clear timeout
		if(this.timeout) {
			clearTimeout(this.timeout);
		}
	},
	
	hide: function() {
		this.cancel_timeout();
		$(this.alert_div).hide();
	}
});

