$(document).ready(function() {
	$('#differs_from_billing_address').click(function(e) {
		var check_bool = !$(this).attr('checked')
		var attr = ['company', 'honorific', 'firstname', 'surname', 'street', 'house_number', 'zip_code', 'city', 'country'];
		
		for(var i in attr) {
			$(':input[name="shipping_' + attr[i] +'"]').attr('disabled', check_bool);
		}
		
		$('input[name="save_shipping_address"]').attr('disabled', check_bool);
		
		$('#shipping_address').attr('disabled', check_bool);
		
		$('#shipping_address_bock').slideToggle();
	});
	
	$('#billing_address').change(function(e) {
		var billing = $(this).val();
		if(billing >= 0) {
			var address = addresses[billing];
			for(var key in address) {
				$(':input[name="billing_' + key +'"]').val(address[key]);
			}
		}
	});
	
	$('#shipping_address').change(function(e) {
		var shipping = $(this).val();
		if(shipping >= 0) {
			var address = addresses[shipping];
			for(var key in address) {
				$(':input[name="shipping_' + key +'"]').val(address[key]);
			}
		}
	});
});
