$(document).ready(
		function() {
			var els = jQuery('form');

			els.each( function(e) {
				eInputs = $(this).find('input');
				eInputs.each( function() {
					$(this).change(
							function(event) {
								/*console.log($(this).parents('form').attr(
										'action'));*/

								var object = $(this);

								var sMore = '&fields[' + $(this).attr('id') +']=' + $(this).attr('value');
								if ($(this).attr('type') == 'password') {
									var id = $(this).attr('id');
									console.log('id', id);
									if (id[id.length - 1] == '1') {
										var sName = id.replace(1, 0);
										//var sName = id2 + '_0';
										console.log(sName);
									}

									/*if (id[id.length - 1] == '0') {
										var id2 = id.substring(0, id.length - 2);
										var sName = id2 + '_1';

									}*/

									if (sName !== undefined) {
										sMore = sMore + '&fields[' + sName + ']=' + $('#' + sName).attr('value');
									}
								}
									//var newStr = str.substring(0, str.length-1);
								jQuery.getJSON($(this).parents('form').attr('action') + '?&cb=?' + sMore, function(data) {
									/*data.errors.each( function() {
										console.log($(this));
									});*/

									var s = jQuery(event.currentTarget).attr('id');
									var ok = false;
									for (i in data.fields) {
										//console.log($('#' + i + '_errors'));
										$('#' + i + '_errors').empty();
										if (data.fields[i].errors !== undefined && data.fields[i].errors.length > 0) {
											ok = true;
											for (j in data.fields[i].errors) {
												$('#' + i + '_errors').append('<p>' + data.fields[i].errors[j] + '</p>');
												//alert(data.fields[i].errors[j]);
											};
											$('#' + i).addClass('error');
											/*animate(
													{
														className: 'error'
													},
													1000
												);*/
										}
									}
									//console.log('OK', ok);
										if (!ok) {
											//console.log('#' + object.attr('id') + '_errors');
											$('#' + object.attr('id') + '_errors').empty();
											object.removeClass('error');
											/*animate(
													{
														className: ''
													},
													1000
												);*/
										}
									//}



									//$('#' + s).addClass('error');

								});
							});
				});

			});
		});