
function load_payment_type(select) {
	var payment_select = $('select#id_payment_type');
	var consignment_select = $('select#id_consignment_type');
	$.getJSON('/ajax/cart_form/' + select.val() + '/', {}, function(json) {
		if(json.length) {
			response = '';
  			for(i=0; i < json.length; i++) {
    			response += '<option value="' +  json[i].pk + '">' + json[i].fields.name + '</option>'
  			}
			payment_select.html(response);
			payment_select.focus();
			consignment_select.focus();
		}
		load_consignment_type(payment_select);
	});
}

function load_consignment_type(select) {
	var country_select = $('select#id_country');
	var consignment_select = $('select#id_consignment_type');
	$.getJSON('/ajax/cart_form/' + country_select.val() + '/' + select.val() + '/', {}, function(json) {
		if(json.length) {
			response = '';
  			for(i=0; i < json.length; i++) {
    			response += '<option value="' +  json[i].pk + '">' + json[i].fields.name + '</option>'
  			}
			consignment_select.html(response);
			consignment_select.focus();
		}
		load_consignment();
	});
}

function load_consignment() {
	var country_select = $('select#id_country');
	var payment_type_select = $('select#id_payment_type');
	var consignment_type_select = $('select#id_consignment_type');
	$('#consigment-get-price').load('/ajax/cart_form_consignment/' + country_select.val() + '/' + payment_type_select.val() + '/' + consignment_type_select.val() + '/', {}, function() {
		load_full_value();
	});
}

function load_full_value() {
	var country_select = $('select#id_country');
	var payment_type_select = $('select#id_payment_type');
	var consignment_type_select = $('select#id_consignment_type');
	$('#cart-full-value-price').load('/ajax/cart_form_full_value/' + country_select.val() + '/' + payment_type_select.val() + '/' + consignment_type_select.val() + '/');
}