
/* error messages */
var Error = Class.create();

Error.prototype = {
	initialize: function(options) {
		this.defaultOptions = {
		  alertBox        : 'noticeWindow',
		  alertDuration   : 8000,
		  alertClassName  : 'errorbox',
		  alertScrollPx   : -24 ,
		  alertForceScroll: 1,
		  alertStyle: {margin : '25px'}
		}
   		this.options = this.defaultOptions
    
   		 Object.extend(this.options, options || {});
	},
	
	alert: function(strContent, options){
		 // overwrite with javascript options
		Object.extend(this.options, options || {});
		
		
		$(this.options.alertBox).setStyle(this.options.alertStyle);
		$(this.options.alertBox).className = "errorbox";
		$(this.options.alertBox).update(strContent);
		$(this.options.alertBox).show();
		
		if(this.options.alertForceScroll){
			new Effect.ScrollTo($(this.options.alertBox), {offset: this.options.alertScrollPx, duration: 0.5});
		}

setTimeout("new Effect.Fade($('" + this.options.alertBox + "'), {onFinish : function(){$('" + this.options.alertBox + "').setStyle({margin:'0'});}});", this.options.alertDuration );
	}
}


/* just messages */
var Message = Class.create();

Message.prototype = {
	initialize: function(options) {
    this.defaultOptions = {
      alertBox        : 'noticeWindow',
      alertDuration   : 4000,
      alertClassName  : 'successbox',
      alertScrollPx   : -24 ,
      alertForceScroll: 1,
      alertStyle: {margin : '25px'}
    }
    this.options = this.defaultOptions
    
    Object.extend(this.options, options || {});
	},
	
	alert: function(strContent, options){
		Object.extend(this.options, options || {});
		
		$(this.options.alertBox).setStyle(this.options.alertStyle);
		$(this.options.alertBox).className = "successbox";
		$(this.options.alertBox).update(strContent);
		$(this.options.alertBox).show();
		
		if(this.options.alertForceScroll){
			new Effect.ScrollTo($(this.options.alertBox), {offset: this.options.alertScrollPx, duration: 0.5});
		}
		
		setTimeout("new Effect.Fade($('" + this.options.alertBox + "'), {onFinish : function(){$('" + this.options.alertBox + "').setStyle({margin:'0'});}});", this.options.alertDuration );
	}
}


/* start it */
Event.observe(window, 'load', function(){ 
	Error = 	new Error; 
	Message = 	new Message; 
});