function formValidation(fieldsArray, formSubmitBtn, form, init){
	this.errorMessage = new errorMessage('Please correct the following errors');
	this.fieldArray = fieldsArray;
	this.formSubmitBtn = formSubmitBtn;
	this.form = form;
	if (init == true){
		this.init();
	}
	else{
		this.checkFields();
	}
}

formValidation.prototype = {
	init: function(){
		var instance = this;
		$(this.formSubmitBtn).click(function(){instance.checkFields();});
	},
	
	checkFields: function(){
		this.errorMessage.hideError();
		this.errorMessage.resetLabels();
		
		var fieldArrayLength = this.fieldArray.length;
		var errors = 0;
		for (var i=0; i<fieldArrayLength; i++){
			//if field of radio buttons is the form row need to check if any radio button has been checked
			if (this.fieldArray[i].is(':radio')){
				var radioChecked = 0;
				this.fieldArray[i].each(function(i){
					if ($(this).is(':checked') == true){
						radioChecked++;
					}
				});
				
				//if no radio button has been checked throw an error
				if (radioChecked < 1){
					this.errorMessage.addErrorMessage(this.fieldArray[i].parents('div.formRow').attr('title'));
					this.fieldArray[i].parents('div.formRow').find('label:first').addClass('error');
				}
			}
			else if (this.fieldArray[i].val() == ''){
				//add an error message from the inputs parent div's title attr
				this.errorMessage.addErrorMessage(this.fieldArray[i].parents('div.formRow').attr('title'));
				this.fieldArray[i].parents('div.formRow').find('label:first').addClass('error');
				errors++;
			}
		}
		if (errors > 0){
			this.errorMessage.showError();
		}
		else{
			$(this.form).submit();
		};
	}
}