$("#tf_s1").click(function() {

	if(document.getElementById('s1a').style.display == 'none')
	$('#s1a').show();
	else
	$('#s1a').hide();

	$('#s2a').hide();
	$('#s3a').hide();

	return false;

});
$("#tf_s2").click(function() {

	if(document.getElementById('s2a').style.display == 'none')
	$('#s2a').show();
	else
	$('#s2a').hide();

	$('#s1a').hide();
	$('#s3a').hide();
	return false;

});

$("#tf_s3").click(function() {

	if(document.getElementById('s3a').style.display == 'none')
	$('#s3a').show();
	else
	$('#s3a').hide();

	$('#s1a').hide();
	$('#s2a').hide();

	return false;
});

function sp(s,e) {

	var a,v;

	var t = $('#sp'+s+e).html();

	if(s == 1) {
		if(e == 1) {
			$('#tff7').val('auto');
			a = '/kredit/auto/';
		}
		if(e == 2) {
			$('#tff7').val('potr');
			a = '/kredit/potr/';
		}
		if(e == 3) {
			$('#tff7').val('real');
			a = '/kredit/real/';
		}
		if(e == 4) {
			$('#tff7').val('vklad');
			a = '/depozit/vklad/';
		}
		if(e == 5) {
			$('#tff7').val('vklad');
			a = '/insurance/auto/';
		}

		if(e == 4) {
			$('#tft2').html('дн.');
			$('#tfi2').val(365);
			$('#tff3').val(365);
		}
		else {
			$('#tft2').html('мес.');
			$('#tff3').val(12);
		}

		if(e == 5) {
			$('#tfhidd2').show();
			$('#tfhidd1').hide();
			$('#tff1').val('227');
			$('#tff2_valute').val(227);
			$('#tff0_valute').val(227);
			
			$('#tff11').val('2005');
			$('#tf_s3').html('2005');
			
			
			$('#tf00').show();
			
			$('#tfi1').css("margin-left", "215px");
			$('#tfs2').css("margin-left", "300px");
			
			$('#tf_s2').html('долл.')
			$('#tfi1').val('10 000');

			$('#tff2').val(10000);

		}
		else {
			$('#tf00').show();
			$('#tfi1').css("margin-left", "199px");
			$('#tfs2').css("margin-left", "285px");

			$('#tf00').hide();

			
			$('#tf_s2').html('бел.руб.')

			$('#tfi1').val('2 000 000');


			$('#tfhidd1').show();
			$('#tfhidd2').hide();
			$('#tff2').val(2000000);

			//			$('#tff1').val() = $('#tfi1').html();
		}


		$('#tff10').val(e);

		document.top_form.action =a;
		$('#tf_s1').html(t);
		$('#s1a').hide();
	}
	if(s == 2) {

		if(e == 1) v = 227;
		if(e == 2) v = 228;
		if(e == 3) v = 229;
		if(e == 4) v = 230;

		$('#tff1').val(v);



		$('#tff2_valute').val(v);
		$('#tff0_valute').val(v);


		$('#tf_s2').html(t);
		$('#s2a').hide();
	}




}

tfsubmit = function() {


	var type = $('#tff10').val();

	if(!trim($('#tfi1').val())) {
		$('#tferr').html('заполните сумму!');
		return false
	}


	if(!validate_num_space($('#tfi1').val())) {
		$('#tferr').html('введите число!');
		return false
	}


	$('#tferr').html('');


	if(type == 1) {

		
		$('#tff0').remove();
		$('#tff11').remove();
		$('#tff2_valute').remove();
		$('#tff0_valute').remove();
		$('#tfff7').remove();

	}
	
	if(type == 2) {

		$('#tff0').val(1241);
//		$('#tff0').remove();
		$('#tff11').remove();
		$('#tff2_valute').remove();
		$('#tff0_valute').remove();
		$('#tff9').remove();

	}
	

	if(type == 3) {

		$('#tff0').remove();
		$('#tff11').remove();
		$('#tff2_valute').remove();
		$('#tff0_valute').remove();
		$('#tff9').remove();
		$('#tfff7').remove();

	}
	
	
	if(type == 1 || type == 2 || type == 3) {
		
		if($('#tff1').val() == 229) {
			
			$('#tff12').remove();
			
		}
		
	}
	
	
	

	if(type == 4) {

		
		
		$('#tfff7').remove();

//		return false;
		var sum = $('#tff2').val();
		var srok = $('#tff3').val();
		var valut = $('#tff1').val();

		$('#tff5').val(sum);
		$('#tff6').val(srok);
		$('#tff3').val(valut);

		$('#tff0').remove();
		$('#tff1').remove();
		$('#tff11').remove();
		$('#tff12').remove();
		$('#tff2').remove();
		$('#tff2_valute').remove();
		$('#tff0_valute').remove();
		$('#tff9').remove();

	}


	if(type == 5) {

		
		

				
		var sum = $('#tff2').val();


		var valuta = $('#tff2_valute').val();	

		if(valuta == 227)
		$('#tff12').remove();






		$('#tff2').val(sum);
		$('#tff0').val(sum);



		$('#tff1').val($('#tff11').val());




		$('#tff0').val(remSpace($('#tff0').val()));
		$('#tff2').val(remSpace($('#tff2').val()));

		$('#tff11').remove();
		$('#tff3').remove();
		$('#tfff7').remove();
		$('#tff8').remove();
		$('#tff9').remove();


	}





	wait(1,1);
	$('#top_form').submit();


}

function chY(y) {
	$('#tf_s3').html(y);
	$('#tff11').val(y);
	$('#s3a').hide();
}