$(document).ready(function () {


//
  $('#9tr, #10tr, #57tr, #19tr, #20tr, #21tr, #22tr, #58tr, #32tr, #64tr, #65tr, #77tr, #78tr, #42tr, #8tr, #86tr, #87tr, #88tr, #89tr, #90tr, #91tr').css({'display' : 'none'});

  var removed9 = '';
  var removed10 = '';

//
  $('#property_155').change(function () {
    $('#32tr').css({'display' : 'table-row'});
  });
  
  $('#property_156').change(function () {
    $('#32tr').css({'display' : 'none'});
  });

//
  $('#property_238').change(function () {
    $('#65tr').css({'display' : 'table-row'});
  });
  
  $('#property_239').change(function () {
    $('#65tr').css({'display' : 'none'});
  });

//
  $('#property_250').change(function () {
    $('#78tr').css({'display' : 'table-row'});
  });
  
  $('#property_251').change(function () {
    $('#78tr').css({'display' : 'none'});
  });

//
  $('#75').change(function () {
	
	if ( $(this).val() == 243 || $(this).val() == 244 ) {
		$('#77tr').css({'display' : 'none'});
	}
	else {
      $('#77tr').css({'display' : 'table-row'});
    }
	
  });

//
  $('#29').change(function () {
	
	if ( $(this).val() == 147 || $(this).val() == 148 ) {
		$('#31tr').css({'display' : 'none'});
	}
	else {
      $('#31tr').css({'display' : 'table-row'});
    }
	
  });
  
//
  $('#31tr').css({'display' : 'none'});

//
  $('#62').change(function () {
	
	if ( $(this).val() == 231 || $(this).val() == 232 ) {
		$('#64tr').css({'display' : 'none'});
	}
	else {
      $('#64tr').css({'display' : 'table-row'});
    }
	
  });

//
  $('#property_86').change(function () {
    $('#20tr, #21tr, #22tr').css({'display' : 'table-row'});
	$('#19tr, #58tr').css({'display' : 'none'});
	$('#property_226, #property_227').attr('checked', false);
  });

  $('#property_87').change(function () {
    $('#58tr').css({'display' : 'table-row'});
	$('#20tr, #21tr, #22tr').css({'display' : 'none'});
  });

//
  $('#property_226, #property_227').change(function () {
    $('#19tr, #20tr, #21tr, #22tr').css({'display' : 'table-row'});
  });

//
  $('#2').change(function () {
    if ( $(this).val() == 154 ) {
      $('#57tr').css({'display' : 'table-row'});
    }
    else {

      $('#57tr').css({'display' : 'none'});
    }
  });

  $('#property_30').change(function () {
    $('#8tr').after(removed9);
    $('#9tr').css({'display' : 'table-row'});
    removed10 = $('#10tr').remove();
  });

  $('#property_31').change(function () {
    $('#8tr').after(removed10);
    $('#10tr').css({'display' : 'table-row'});
    removed9 = $('#9tr').remove();
  });

//
  var valuta_str = '';

  $('#5').change(function () {
    valuta_str = ' ' + $("#5 option:selected").text();
    $('.span_for_valuta').text(valuta_str);
  });

  $('#7').attr('size', 11);
  $('#6').after('<span class="span_for_valuta"> руб.</span>');
  $('#7').after('<span class="span_for_valuta"> руб.</span>');

//
  $('#27tr, #28tr').css({'display' : 'none'});

  var removed27 = '';
  var removed28 = '';

  $('#property_91').change(function () {
    $('#26tr').after(removed27);
    $('#27tr').css({'display' : 'table-row'});
    removed28 = $('#28tr').remove();
  });

  $('#property_92').change(function () {
    $('#26tr').after(removed28);
    $('#28tr').css({'display' : 'table-row'});
    removed27 = $('#27tr').remove();
  });

//
  $('#23').change(function () {
    valuta_str = ' ' + $("#23 option:selected").text();
    $('.span_for_valuta').text(valuta_str);
  });

  $('#24, #25, #6, #46').attr('size', 11);
  $('#60, #73').attr('size', 10);
  $('#24, #25').after('<span class="span_for_valuta"> руб.</span>');
  $('#26').after('<span> лет</span>');
//
  $('#45').change(function () {
    valuta_str = ' ' + $("#45 option:selected").text();
    $('.span_for_valuta').text(valuta_str);
  });
  
  $('#46').after('<span class="span_for_valuta"> руб.</span>');
//
  $('#59').change(function () {
    valuta_str = ' ' + $("#59 option:selected").text();
    $('.span_for_valuta').text(valuta_str);
  });
  
  $('#60').after('<span class="span_for_valuta"> руб.</span>');
//
  $('#72').change(function () {
    valuta_str = ' ' + $("#72 option:selected").text();
    $('.span_for_valuta').text(valuta_str);
  });
  
  $('#73').after('<span class="span_for_valuta"> руб.</span>');

//
  $('#48tr, #49tr').css({'display' : 'none'});

  var removed48 = '';
  var removed49 = '';

  $('#property_168').change(function () {
    $('#47tr').after(removed48);
    $('#48tr').css({'display' : 'table-row'});
    removed49 = $('#49tr').remove();
  });

  $('#property_169').change(function () {
    $('#47tr').after(removed49);
    $('#49tr').css({'display' : 'table-row'});
    removed48 = $('#48tr').remove();
  });

// Проверяем поле "Электронная почта" в заявке "Заявка на ипотеку"
var regV = /^[0-9a-z_\-\.]+@[0-9a-z\-\.]+\.[a-z]{2,6}$/i;

$('#17').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV) == -1) {
		alert('Внимание! Адрес электронной почты написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Телефон" в заявке "Заявка на ипотеку"
var regV2 = /^( +)?((\+?7|8) ?)?((\(\d{3}\))|(\d{3}))?( )?(\d{3}[\- ]?\d{2}[\- ]?\d{2})( +)?$/;

$('#16').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV2) == -1) {
		alert('Внимание! Номер телефона написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Электронная почта" в заявке "Заявка на кредит под залог недвижимости"
$('#56').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV) == -1) {
		alert('Внимание! Адрес электронной почты написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Телефон" в заявке "Заявка на кредит под залог недвижимости"
$('#55').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV2) == -1) {
		alert('Внимание! Номер телефона написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Электронная почта" в заявке "Заявка на автокредит"
$('#38').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV) == -1) {
		alert('Внимание! Адрес электронной почты написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Телефон" в заявке "Заявка на автокредит"
$('#37').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV2) == -1) {
		alert('Внимание! Номер телефона написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Электронная почта" в заявке "Заявка на экспресс кредит"
$('#71').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV) == -1) {
		alert('Внимание! Адрес электронной почты написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Телефон" в заявке "Заявка на экспресс кредит"
$('#70').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV2) == -1) {
		alert('Внимание! Номер телефона написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Электронная почта" в заявке "Заявка на кредит наличными"
$('#84').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV) == -1) {
		alert('Внимание! Адрес электронной почты написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Телефон" в заявке "Заявка на кредит наличными"
$('#83').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV2) == -1) {
		alert('Внимание! Номер телефона написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Электронная почта" в заявке "Заявка на кредитную историю"
$('#98').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV) == -1) {
		alert('Внимание! Адрес электронной почты написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Телефон" в заявке "Заявка на кредитную историю"
$('#97').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV2) == -1) {
		alert('Внимание! Номер телефона написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Электронная почта" в заявке "Заявка на бизнес кредит"
$('#116').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV) == -1) {
		alert('Внимание! Адрес электронной почты написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

// Проверяем поле "Телефон" в заявке "Заявка на бизнес кредит"
$('#115').blur(function() {
	if ($(this).val() == '') {
		$(this).val($(this).attr('defaultValue'));
	}
	else if ($(this).val().search(regV2) == -1) {
		alert('Внимание! Номер телефона написан некорректно. Пожалуйста, удостоверьтесь в правильности его написания!');
	}
});

//
var removedNAMEtr = $('#NAMEtr').remove();
$('#33tr, #51tr, #12tr, #66tr, #79tr, #95tr, #111tr').after(removedNAMEtr);

//
$('.data-table tr:not(.data-table tr:first):not(.data-table tr:last)').hover(function () {
	$(this).css({'background-color' : '#FFFFCC'});
}, function () {
	$(this).css({'background-color' : '#FFFFFF'});
});

//
$('#43, #44').css({'margin-top' : '11px'});

//
$('#v_kontakte, #t_witter').hover(function(){ 
    $(this).stop().animate({'opacity':'0.5'},400); 
},function(){ 
    $(this).stop().animate({'opacity':'1.0'},400); 
});


//
$('.partner').find("img").hover(function(){ 
    $(this).stop().animate({'opacity':'0.5'},400); 
},function(){ 
    $(this).stop().animate({'opacity':'1.0'},400); 
});


//
$('#form_zayavka input:radio + label').after('<div></div>');
$('#form_zayavka input:radio + label + div').css({'margin-top' : '-10px'});

//
$('#82tr td input, #54tr td input, #36tr td input, #69tr td input, #15tr td input').css({'width' : '176px'});

//
$('#41').change(function () {
	
	if ( $(this).val() == 442 ) {
      $('#42tr').css({'display' : 'table-row'});
    }
	else {
      $('#42tr').css({'display' : 'none'});
    }
	
});

//
$('#3').change(function () {
	
	if ( $(this).val() == 27 ) {
      $('#8tr').css({'display' : 'table-row'});
	  $('#85tr').css({'display' : 'none'});
    }
	else {
      $('#8tr, #9tr, #10tr').css({'display' : 'none'});
	  $('#85tr').css({'display' : 'table-row'});
	  $('#property_30, #property_31').attr('checked', false);
    }
	
});

$('#85').after('<span> лет</span>');

//
$('#30').change(function () {
	
  if ( $(this).val() == 153 ) {
    $('#86tr').css({'display' : 'table-row'});
	alert('Извините, но на данный момент мы работаем с клиентами, проживающими в Санкт-Петербурге или Ленинградской области!');
  }
  else {
    $('#86tr').css({'display' : 'none'});
  }
  
});

//
$('#63').change(function () {
	
  if ( $(this).val() == 237 ) {
    $('#87tr').css({'display' : 'table-row'});
	alert('Извините, но на данный момент мы работаем с клиентами, проживающими в Санкт-Петербурге или Ленинградской области!');
  }
  else {
    $('#87tr').css({'display' : 'none'});
  }
  
});

//
$('#76').change(function () {
	
	if ( $(this).val() == 249 ) {
		$('#88tr').css({'display' : 'table-row'});
		alert('Извините, но на данный момент мы работаем с клиентами, проживающими в Санкт-Петербурге или Ленинградской области!');
	}
	else {
		$('#88tr').css({'display' : 'none'});
	}
  
});

//
$('#75').change(function () {
	
	if ( $(this).val() == 246 ) {
		$('#89tr').css({'display' : 'table-row'});
	}
	else {
		$('#89tr').css({'display' : 'none'});
	}
  
});

//
$('#62').change(function () {
	
	if ( $(this).val() == 234 ) {
		$('#90tr').css({'display' : 'table-row'});
	}
	else {
		$('#90tr').css({'display' : 'none'});
	}
  
});

//
$('#29').change(function () {
	
	if ( $(this).val() == 150 ) {
		$('#91tr').css({'display' : 'table-row'});
	}
	else {
		$('#91tr').css({'display' : 'none'});
	}
  
});

//
$('#bx_incl_area_5 img:first').css({'top' : '-60px'});
$('img[src*="/images/box/10.png"]').css({'top' : '-60px'});

/*
$('.logo1').hover(function () {
    $(this).hide().attr('src', '/images/01.png').show();
}, function () {
    $(this).hide().attr('src', '/images/1.png').show();
});

$('.logo2').hover(function () {
    $(this).hide().attr('src', '/images/6color.jpg').show();
}, function () {
    $(this).hide().attr('src', '/images/2.jpg').show();
});

$('.logo3').hover(function () {
    $(this).hide().attr('src', '/images/6color.jpg').show();
}, function () {
    $(this).hide().attr('src', '/images/3.jpg').show();
});

$('.logo4').hover(function () {
    $(this).hide().attr('src', '/images/6color.jpg').show();
}, function () {
    $(this).hide().attr('src', '/images/4.jpg').show();
});

$('.logo5').hover(function () {
    $(this).hide().attr('src', '/images/6color.jpg').show();
}, function () {
    $(this).hide().attr('src', '/images/5.jpg').show();
});

$('.logo6').hover(function () {
    $(this).hide().attr('src', '/images/6color.jpg').show();
}, function () {
    $(this).hide().attr('src', '/images/6.jpg').show();
});

$('.logo7').hover(function () {
    $(this).hide().attr('src', '/images/01.png').show();
}, function () {
    $(this).hide().attr('src', '/images/1.png').show();
});

$('.logo8').hover(function () {
    $(this).hide().attr('src', '/images/6color.jpg').show();
}, function () {
    $(this).hide().attr('src', '/images/2.jpg').show();
});

$('.logo9').hover(function () {
    $(this).hide().attr('src', '/images/6color.jpg').show();
}, function () {
    $(this).hide().attr('src', '/images/3.jpg').show();
});

$('.logo10').hover(function () {
    $(this).hide().attr('src', '/images/6color.jpg').show();
}, function () {
    $(this).hide().attr('src', '/images/4.jpg').show();
});*/

});
