var InputValidator = new Class({
	initialize: function(options) {
		this.options = options;
		this.options.element.onfocus = function() {
			if(this.getStyle('color') == "red") {
				this.setStyle('color', 'black');
				this.value = "";
			}
		}
	},
	test: function() {
		var isInvalid = false;

		switch(this.options.type) {
			case "email":
				if(this.options.element.getValue().length == 0 || this.options.element.getValue().indexOf("@") == -1 || this.options.element.getValue().indexOf(".") == -1) {
					isInvalid = true;
				}
				
				break;
			default:
				if(this.options.element.getTag() == "textarea") {
					isInvalid = this.options.element.value.length == 0;
				} else if(this.options.element.getValue().length == 0) {
					isInvalid = true;
				}
				
				break;
		}
		
		if(!isInvalid) {
			return true;
		}
		
		this.options.element.setStyle('color', 'red');
		
		if(this.options.element.getTag() == "textarea") {
			this.options.element.setHTML(this.options.errorMessage);
		} else {
			this.options.element.value = this.options.errorMessage;
		}
		
		return false;
	}
})
