Message = function()
{
	this.error = '';
	this.message = '';
	this.block = 'msg';
};


Message.prototype.add = function( type, text )
{
	if ( type == 'error' )
	{
		this.error += (this.error ? '<br />' : '') + text;
		$('#' + this.block + ' p:eq(1)').html( this.error );
	}
	else if ( type == 'message' )
	{
		this.message += (this.message ? '<br />' : '') + text;
		$('#' + this.block + ' p:eq(1)').html( this.message );
	}
	
	return this;
}


Message.prototype.show = function( options, force )
{
	if ( !this.error && !this.message && !force )
		return;
	
	this.setStyle();
	obPopup.show( this.block, options );
	this.clear();
}


Message.prototype.setStyle = function()
{
	if ( this.error )
		$('#' + this.block + ' p:eq(1)').css( 'color', '#C60000' );
	else if ( this.message )
		$('#' + this.block + ' p:eq(1)').css( 'color', '#3C3C3C' );
}


Message.prototype.clear = function()
{
	this.error = this.message = '';
}


Message.prototype.getErrors = function()
{
	return this.error;
}


var obMessage = new Message();
