if (! BasicValidation) {
var BasicValidation = Class.create();

BasicValidation.prototype = {
	initialize: function () {
		this.handlers = {
			email : "isEmail",
			phone : "isPhone",
			telephone : "isPhone",
			creditcard : "isCreditCard",
			commonusdate: "isCommonUsDate",
			numeric: "isNumeric"
		}
	},

	getHandlers : function () {
		return this.handlers;
	},

	isEmail : function (value) {
		var emailRegex = /^[a-zA-Z_0-9-'\+~]+(\.[a-zA-Z_0-9-'\+~]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$/;
		// Trim whitespace
		value = value.replace(/^\s+/,'').replace(/\s+$/,'');
		// Test email regex
		return emailRegex.test(value);
	},

	isPhone : function (value) {
		// Remove all non-digits
		value = value.replace(/\D/g, '');
		// Check for a length between 10 and 15
		return (value.length >= 10 && value.length <= 15) ? true : false;
	},

	isCreditCard : function (value) {
		return (value.replace(/[^\d]/g).length == 16);
	},

	/**
	 * Returns true if the given year, month, and day represent a valid date.
	 */
	isCommonUsDate : function (value) {
		if (value.match(/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/)) {
			var dateSplit = value.split("/");

			// Subtract 1 from month because JS dates use 0 offset
			dateSplit[0] = dateSplit[0] - 1;

			if (dateSplit.length == 3) {
				testDate = new Date(dateSplit[2], dateSplit[0], dateSplit[1]);

				if (testDate.getDate() == dateSplit[1]
					&& testDate.getMonth() == dateSplit[0]
					&& testDate.getFullYear() == dateSplit[2]) {
					return true;
				}
			}
		}

		return false;
	},

	isNumeric : function (value) {
		//  check for valid numeric strings	
		var strValidChars = "0123456789.-";
		var strChar;
		var blnResult = true;
		
		if (value.length == 0) return false;
		//  test strString consists of valid characters listed above
		for (i = 0; i < value.length && blnResult == true; i++) {
			strChar = value.charAt(i);
			if (strValidChars.indexOf(strChar) == -1) {
				blnResult = false;
			}
		}
		return blnResult;
	},
	
	isEqual : function(value, options) {
		var field = $(options.compareTo);
		
		if(field) {
			return value = field.value;
		} else {
			return false;
		}
	}
}
}
