var FV_MSG_PREFIX = "[Form Validator]";

/*========================
#
#		Constructor
*/
function FormValidator(){

	this.data_validator = new DataValidator();

	// methods
	this.is_valid 	= fv__is_valid;
	this.warn 		= fv__warn;
}

/*========================
#
#	Form field validation
*/
function fv__is_valid( obj, data_type, error_msg ){

	if ( typeof(obj) != "object" || typeof(data_type) == "undefined" ){
		this.warn("Invalid usage of is_valid function\nUsage: is_valid(object, data_type, error_message)");
		return false;
	}

	var result = true;

	if (! this.data_validator.is_valid( obj.value, data_type ) ){

		// set result flag
		result = false;

		// alert message if any
		if ( typeof(error_msg) != "undefined" ){
			alert( error_msg );
		}

		// focus on the field
		obj.focus();
	}

	return result;

}


/*========================
#
#	Error Message method
*/
function fv__warn( msg ){
	alert( FV_MSG_PREFIX + "\n" + msg);
}
