
function registerCore() {
	this.ident ='';
	
	this.checkFirstName = function(ident) {
		if(ge('firstname_').value!="") {
			ge('firstname_check').innerHTML = 'Ok';
			ge('firstname_check').style.color = '#0a0';
		}
	}
	
	this.checkLastName = function(ident) {
		if(ge('lastname_').value!="") {
			ge('lastname_check').innerHTML = 'Ok';
			ge('lastname_check').style.color = '#0a0';
		}
	}
	
	this.checkCaptcha = function(ident) {
		captcha = ge('captcha_').value;
		if (captcha != '') {
			if (captcha.length > 4) {
				ge('captcha_check').innerHTML = 'Слишком много символов';
				ge('captcha_check').style.color = '#b00';
			} else if (captcha.length == 4) {
				ge('captcha_check').innerHTML = 'Ok';
				ge('captcha_check').style.color = '#0a0';
			} else ge('captcha_check').innerHTML = '';
		} else ge('captcha_check').innerHTML = '';
	}

	this.checkNickname = function(ident) {
		if(ge('nickname_').value!="") {
			ge('nick_check').innerHTML = 'Ok';
			ge('nick_check').style.color = '#0a0';
		}
	}
	
	this.checkEmail = function(ident,inuse) {
		var data = new Object();
		var reg = /^([a-z0-9_\.-]+)@([a-z0-9_\.-]+)\.([a-z\.]{2,6})$/i;
		email = ge('email_').value;
		if(inuse==true) {
			if (reg.test(email)) {
				data['ident'] = ident;
				data['email'] = email;
				data['action'] = 'checkemail';
				data['widget'] = 'register';
				this.InitializeRequest('POST', '/ajax.php');
	         	this.Commit(postquery(data));
			} else {
				ge('email_check').innerHTML = 'Недопустимый e-mail';
				ge('email_check').style.color = '#b00';
			}
		} else {
			if(reg.test(email)) {
				ge('email_check').innerHTML = 'OK';
				ge('email_check').style.color = '#0b0';
			} else {
				ge('email_check').innerHTML = 'Недопустимый e-mail';
				ge('email_check').style.color = '#b00';
			}
		}
	}

	this.checkPassword = function(ident) {
		pass = ge('password_').value;
		
			if (pass.length < 6) {
				ge('password_check').innerHTML = 'Слишком короткий пароль';
				ge('password_check').style.color = '#b00';
				ge('password_confirm_').style.background='#BBB';
				ge('password_confirm_').disabled=true;
			} else {
				ge('password_check').innerHTML = 'Ok';
				ge('password_check').style.color = '#0a0';
				ge('password_confirm_').style.background='';
				ge('password_confirm_').disabled=false;
			}
		
	}

	
	this.checkPasswordConfirm = function(ident) {
		pass1 = ge('password_').value;
		pass2 = ge('password_confirm_').value;
		if (pass2.length >= pass1.length) {
			if (pass1 != pass2) {
				ge('password_confirm_check').innerHTML = 'Пароль и подтверждение пароля не совпадают';
				ge('password_confirm_check').style.color = '#b00';
			} else {
				ge('password_confirm_check').innerHTML = 'Ok';
				ge('password_confirm_check').style.color = '#0a0';
			}
		} else ge('password_confirm_check').innerHTML = '';
	}
	
	
	
	this.OnSuccess = function()
      {
      	eval(this.GetResponseText());
      }

}

registerCore.prototype = new ajax();
register = new registerCore();

