	Validator = {
		
		//Different Validation Regular Expressions 
		alphaRegxp 		: /^([-A-Za-z ]+)$/,
		nameRegxp 		: /^([-A-Za-z\-\_ ]+)$/,
		uriRegxp		: /^([0-9A-Za-z\_\s\-\.\,\#]+)$/,
		alphaNumRegxp 	: /^([0-9A-Za-z ]+)$/,
		numRegxp 		: /^([0-9 ]+)$/,
		emailRegxp 		: /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/,
		passwordRegxp	: /^([a-zA-Z0-9@*#]{6,15})$/,
		regexUse		: '',
		/**
		 * The errors array stores the amount of current errors
		 */
		errors 			: [],
		started			: false,
		/**
		 * Add a Validation to a field
		 * @param {string} field - Id of the Field Name to Validate
		 * @param {string} testType - Type of Event ( blur, change, keyup, focus etc.. )
		 * @param {string} errorMsg - The message you would like to display to the user
		 */
		addValidation : function ( field, type, event_type, errorMsg ){
			var errorOccurred;
			Event.observe(field, event_type, function(e){
				Validator.started = true;
				var target = e.target;
				var fieldValue = target.value;
				regExp =  Validator.getRegex( type );
				
				if( regExp.test(fieldValue) ) {
					$(field).style.borderColor= 'Silver';
					//$(target.id + '_msg').innerHTML = '';
					Validator.errors.splice( Validator.errors.indexOf( target.id ),  1 );			
				} else {
					//$(target.id + '_msg').innerHTML = errorMsg;
					$(field).style.borderColor= 'Red';
					//$(target.id + '_msg').addClassName('form_error');
					Validator.errors.push( target.id );
					Validator.errors = Validator.errors.uniq();			
				}
			});
		
		},
		/**
		 * Validate a field VIA Ajax request, the codes should be returned in JSON
		 * 
		 * ie( {"success":1,"message":"Message Here!"} ) 
		 * @param {String} field
		 * @param {String} url
		 * @param {String} type
		 * @param {Boolean} persistant would you like it to keep updating?
		 */
		validateJSON : function ( field, url, type){
			Validator.started = true;
			var errorOccurred;
			Event.observe( field, type, function(e){
				var target = e.target;	
					new Ajax.Request(url, {
					  method: 'post',
					  parameters: { string: target.value },
					  onSuccess: function(res) {	
						var response = eval('(' + res.responseText + ')');
		
						if( response.success == 1 ) {
							$(field).style.borderColor= 'Silver';
							$(target.id + '_msg').innerHTML = response.message;
							$(target.id + '_msg').addClassName('form_success');
							$(target.id + '_msg').removeClassName('form_error');
							Validator.errors.splice( Validator.errors.indexOf( target.id ),  1 );
						}
						if( response.success == 0 ) {
							$(field).style.borderColor= 'Red';
							$(target.id + '_msg').innerHTML = response.message;
							$(target.id + '_msg').addClassName('form_error');
							$(target.id + '_msg').addClassName('form_success');
							Validator.errors.push( target.id );
							Validator.errors = Validator.errors.uniq();			
						}
					}
				});		
			});		
		},
		/**
		 * Give this function two fields, this will validate that they match
		 * 
		 * @param {String} field1
		 * @param {String} field2
		 * @param {String} type
		 */
		mustMatch : function( field1, field2, type ){
			Validator.started = true;
			Event.observe( field1, type, function( e ){ 
				var target = e.target;
				if( $(field2).value == target.value ) {
					$(field1).style.borderColor= 'Silver';
					$(field2).style.borderColor= 'Silver';				
					$(target.id + '_msg').innerHTML = '';
					$(target.id + '_msg').addClassName('form_success');				
					$(target.id + '_msg').removeClassName('form_error');				
					Validator.errors.splice( Validator.errors.indexOf( target.id ),  1 );
				} else {
					$(field1).style.borderColor= 'Red';
					$(field2).style.borderColor= 'Red';				
					$(target.id + '_msg').innerHTML = 'Fields must match!';
					$(target.id + '_msg').addClassName('form_error');				
					$(target.id + '_msg').removeClassName('form_success');								
					Validator.errors.push( target.id );
					Validator.errors = Validator.errors.uniq();			
				}
				
			});
				
		},
		/**
		 * Private Function returns the regular expression you need
		 * 
		 * @param {String} type
		 */
		getRegex : function ( type ){			
				switch( type ) {
				case 'alpha'	: 	return this.alphaRegxp; break;
				case 'uri'		:	return this.uriRegxp;   break;			
				case 'num'		: 	return this.numRegxp;	break;
				case 'name'		:	return this.nameRegxp;	break;
				case 'alphaNum'	:	return this.alphaNumRegxp; break;
				case 'email'	:	return this.emailRegxp; break;
				case 'password'	:	return this.passwordRegxp; break;
				}
		},
		/**
		 * Will validate that there are no errors on the page
		 * 
		 */
		validateErrors : function ( ){
			if( Validator.started == true ) {
				Validator.errors = Validator.errors.uniq();							
				if( Validator.errors.length <= 0 ) {
					return true;	
				} else {
					return false;
				}
			} else {
				return false;
			}
		}
	};	
	
	function submitForm(){
		var errors = Validator.validateErrors();
		if( errors == false ) {
			alert("You did not fill out the form correctly!")
		} else {
			$('subscription_form').submit();
		}
		
	}