if (! BasicValidation) {
var BasicValidation = Class.create();

BasicValidation.prototype = {
	initialize: function () {
		this.handlers = {
			email : "isEmail",
			phone : "isPhone",
			telephone : "isPhone",
			creditcard : "isCreditCard",
			securitycode : "isSecurityCode",
			commonusdate: "isCommonUsDate"
		}
	},

	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) {
		var test = value.replace(/[^\d]/g);
		return (test.length >= 13 && test.length <= 16);
	},

	isSecurityCode : function (value) {
		var reSecurityCode = /^\d{3,4}$/; 
		return reSecurityCode.test(value);
	},

	/**
	 * 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]{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] || dateSplit[2].length == 2)) {
					return true;
				}
			} 
		}

		return false;
	}
}
}