var checkform = function() {
	this._elements = new Array();	
	this._types = new Array('text', 'email');
	
	this.set = function(id, type) {
		flag = false;
		for(i=0; i<this._types.length; i++) {
			if (type == this._types[i]) { flag = true; }
		}
		if(!flag) return false; 
		
		this._elements.push(new Array(id, type));
	}
	
	this._checkemail = function(value) {
		value = new String(value);
		message = "Пожалуйста, введите корректный email адрес";
		if(value == '') return message;
		if(value.indexOf ( "@" ,1 ) == -1 ) return message;
		return false;
	}
	
	this._checktext = function(value) {
		message = "Пожалуйста, заполните все обязательные поля";
		if(value == '') return message;
		return false;
	
	}
	
	this.check = function() {
		for(i=0; i<this._elements.length; i++) {
			elmt = document.getElementById(this._elements[i][0]);
			value = elmt.value;
			retVal = false;
			evalStr = "retVal = this._check"+this._elements[i][1]+"(value.replace(this.replacePattern, \"$1\"));"
			eval(evalStr);
			if(retVal) {
				alert(retVal);
				elmt.focus();
				return false;
			}
		}
		return true;
	}	
	
}
