/****** Handles validation errors *******/
function Errors(){
	this.errorMessages = new Array();
	this.showInline = false;
	this.inlineField = '';
}
Errors.prototype.add = function(msg,showNow){
	this.errorMessages[this.errorMessages.length] = msg;
	if(showNow){	this.show();	}
};
Errors.prototype.clear = function(){
	this.errorMessages = new Array();
};
Errors.prototype.show = function(){
	$('#errorWindow').hide();
	$('#errMessage').html('');
	if( this.errorMessages.length > 0 ){
		var list = '';
		var msgCount = this.errorMessages.length;
		for( var e = 0; e < msgCount; e++ ){
			if( msgCount == 1 ){
				list = this.errorMessages[e];
			}
			else{
				list += '<LI>'+this.errorMessages[e]+'</LI>';
			}
		}
		if( this.showInline ){
			$('#'+this.inlineField).html(list);
			$("#"+this.inlineField).fadeIn("normal");
		}
		else{
			$('#errMessage').html('<UL>'+list+'</UL>');
			$("#errorWindow").fadeIn("normal");
		}
		this.clear();
	}
};
Errors.prototype.hide = function(){
	$("#errorWindow").fadeOut("normal");
	if( this.showInline ){
		$("#"+this.inlineField).fadeOut("normal");
		this.inlineField = '';
		this.showInline = false;
	}
	this.clear();
};
Errors.prototype.noErrors = function(){
	if( this.errorMessages.length > 0 ){
		return false;
	}else{
		return true;
	}
};
Errors.prototype.setInline = function(fldId){
	if( fldId != null ){
		this.inlineField = fldId;
		this.showInline = true;
	}
	return this;
};
