/***** Custom validation functions *****/

function checkCountry(field, rules, i, options) {
	var country = $("#country option:selected").val();
	var district = $("#district option:selected").val();
	
	if (country == 'HK' && district == 3686) {
		return options.allrules.checkCountry.alertText;
	}
}

function checkShipCountry(field, rules, i, options) {
	var shipcountry = $("#shipcountry option:selected").val();
	var shipdistrict = $("#shipdistrict option:selected").val();
	
	if (shipcountry == 'HK' && shipdistrict == 3686) {
		return options.allrules.checkShipCountry.alertText;
	}
}

/****** end ******/

function step1CheckDeliveryType() {
	var country = $("#country option:selected").val();
	if (country != 'HK') {
		// no "self-pickup" option of not Hong Kong
		//$(".delivery_type").removeAttr('checked');
		//$(".delivery_type").filter("[value=1]").attr("checked","checked");
		//$(".delivery_type").filter("[value=2]").attr('disabled', 'disabled');
		//$("div#delivery_type_2").hide();
		$("#shiptablelink").hide();
	} else {
		//$(".delivery_type").filter("[value=2]").removeAttr('disabled');
		//$("div#delivery_type_2").show();
		$("#shiptablelink").show();
	}
	
	var delivery_type = $(".delivery_type:checked").val();
	
	if (delivery_type == 1) {
		// delivery
		$(".shipinfo").show();
		// enable / disble shipping address fields depends on end user choosed "same shipping address" or not
		if ($(".sameshipinfo").attr('checked')) {
			disableShipinfo();
		} else {
			if ($("#shipfirstname").val() == '') {
				enableShipinfo();
			}
		}
	} else {
		// self-pickup
		$(".shipinfo").hide();
		//disableShipinfo();
	}
}

function changeDistrictStatus(country) {
	if (country == 'CN') {	
		$("#district").attr('disabled', 'disabled');
		$("#district").addClass('disabled');
		$("#district").removeClass('validate[required,funcCall[checkCountry]]');
		
		$("#province").removeAttr('disabled', 'disabled');
		$("#province").removeClass('disabled');
		$("#province").addClass('validate[required]');
	} else if (country != 'HK') {
		$("#district").attr('disabled', 'disabled');
		$("#district").addClass('disabled');
		$("#district").removeClass('validate[required,funcCall[checkCountry]]');
		
		$("#province").attr('disabled', 'disabled');
		$("#province").addClass('disabled');
		$("#province").removeClass('validate[required]');
	} else {
		$("#district").removeAttr('disabled');
		$("#district").removeClass('disabled');
		$("#district").addClass('validate[required,funcCall[checkCountry]]');
		
		$("#province").attr('disabled', 'disabled');
		$("#province").addClass('disabled');
		$("#province").removeClass('validate[required]');
		
		$("#shiptablelink").show();
	}
}

function changeShipDistrictStatus(country) {
	if (country == 'CN') {	
		$("#shipdistrict").attr('disabled', 'disabled');
		$("#shipdistrict").addClass('disabled');
		$("#shipdistrict").removeClass('validate[required,funcCall[checkCountry]]');
		
		$("#shipprovince").removeAttr('disabled', 'disabled');
		$("#shipprovince").removeClass('disabled');
		$("#shipprovince").addClass('validate[required]');
		
		$("#shiptablelink").hide();
	} else if (country != 'HK') {
		$("#shipdistrict").attr('disabled', 'disabled');
		$("#shipdistrict").addClass('disabled');
		$("#shipdistrict").removeClass('validate[required,funcCall[checkShipCountry]]');
		
		$("#shipprovince").attr('disabled', 'disabled');
		$("#shipprovince").addClass('disabled');
		$("#shipprovince").removeClass('validate[required]');
		
		$("#shiptablelink").hide();
	} else {
		$("#shipdistrict").removeAttr('disabled');
		$("#shipdistrict").removeClass('disabled');
		$("#shipdistrict").addClass('validate[required,funcCall[checkShipCountry]]');
		
		$("#shipprovince").attr('disabled', 'disabled');
		$("#shipprovince").addClass('disabled');
		$("#shipprovince").removeClass('validate[required]');
		
		$("#shiptablelink").show();
	}
}

function checkCountryValue(country) {
	if (country == 'CN') {
		$("#district option[value='3686']").attr("selected", "selected");
		$("#province option[value='']").attr("selected", "selected");
	} else if (country != 'HK') {
		// change the value to "Outside HK"
		$("#district option[value='3686']").attr("selected", "selected");
		$("#province option[value='']").attr("selected", "selected");
	} else {
		$("#district option[value='']").attr("selected", "selected");
		$("#province option[value='']").attr("selected", "selected");
	}
	
	changeDistrictStatus(country);
}

function checkShipCountryValue(country) {
	if (country == 'CN') {
		shipCountryCnAction()
	} else if (country != 'HK') {
		// change the value to "Outside HK"
		$("#shipdistrict option[value='3686']").attr("selected", "selected");
		$("#shipprovince option[value='']").attr("selected", "selected");
		$("#shiptablelink").hide();
	} else {
		$("#shipdistrict option[value='']").attr("selected", "selected");
		$("#shipprovince option[value='']").attr("selected", "selected");
		$("#shiptablelink").show();
	}
	
	changeShipDistrictStatus(country);
}

function initCheckShipCountryValue(country) {
	if (country == 'CN') {
		initShipCountryCnAction();
	} else if (country != 'HK') {
		shipCountryOverseaAction();
	}
	
	changeShipDistrictStatus(country);
}

function shipCountryCnAction() {
	$("#shipdistrict option[value='3686']").attr("selected", "selected");
	$("#shipprovince option[value='']").attr("selected", "selected");
	$("#shiptablelink").hide();
}

function initShipCountryCnAction() {
	$("#shipdistrict option[value='3686']").attr("selected", "selected");
	$("#shiptablelink").hide();
}

function shipCountryOverseaAction() {
	// change the value to "Outside HK"
	$("#shipdistrict option[value='3686']").attr("selected", "selected");
	$("#shipprovince option[value='']").attr("selected", "selected");
	$("#shiptablelink").hide();
}

function disableShipinfo() {
	//$(".shipinfo").hide();
	
	$("#ship_sa option[value='" + $("select#buyer_sa option:selected").val() + "']").attr("selected", "selected");
	$("#ship_sa").removeClass('validate[required]');
	$("#ship_sa").attr('disabled', 'disabled');
	$("#ship_sa").addClass('disabled');
	
	$("#shipfirstname").val($("input#firstname").val());
	$("#shipfirstname").attr('readonly', 'readonly');
	$("#shipfirstname").addClass('disabled');
	$("#shipfirstname").removeClass('validate[required]');
	
	$("#shiplastname").val($("input#lastname").val());
	$("#shiplastname").attr('readonly', 'readonly');
	$("#shiplastname").addClass('disabled');
	$("#shiplastname").removeClass('validate[required]');
	
	$("#shipflat").val($("input#flat").val());
	$("#shipflat").attr('readonly', 'readonly');
	$("#shipflat").addClass('disabled');
	
	$("#shipfloor").val($("input#floor").val());
	$("#shipfloor").attr('readonly', 'readonly');
	$("#shipfloor").addClass('disabled');
	
	$("#shipblock").val($("input#block").val());
	$("#shipblock").attr('readonly', 'readonly');
	$("#shipblock").addClass('disabled');
	
	$("#shipaddress1").val($("input#address1").val());
	$("#shipaddress1").attr('readonly', 'readonly');
	$("#shipaddress1").addClass('disabled');
	
	$("#shipaddress2").val($("input#address2").val());
	$("#shipaddress2").attr('readonly', 'readonly');
	$("#shipaddress2").addClass('disabled');
	
	$("#shipaddress3").val($("input#address3").val());
	$("#shipaddress3").attr('readonly', 'readonly');
	$("#shipaddress3").addClass('disabled');
	
	$("#shipcountry option[value='" + $("select#country option:selected").val() + "']").attr("selected", "selected");
	$("#shipcountry").removeClass('validate[required]');
	$("#shipcountry").attr('disabled', 'disabled');
	$("#shipcountry").addClass('disabled');
	
	var country = $("#shipcountry option:selected").val();
	
	$("#shipdistrict option[value='" + $("select#district option:selected").val() + "']").attr("selected", "selected");
	$("#shipdistrict").removeClass('validate[required,funcCall[checkShipCountry]]');
	$("#shipdistrict").attr('disabled', 'disabled');
	$("#shipdistrict").addClass('disabled');
	if (country == 'HK') {
		$("#shiptablelink").show();
	} else {
		$("#shiptablelink").hide();
	}
	
	$("#shipprovince option[value='" + $("select#province option:selected").val() + "']").attr("selected", "selected");
	$("#shipprovince").attr('disabled', 'disabled');
	$("#shipprovince").addClass('disabled');
	$("#shipprovince").removeClass('validate[required]');
	
	$("#shiptel").val($("input#tel").val());
	$("#shiptel").attr('readonly', 'readonly');
	$("#shiptel").addClass('disabled');
	$("#shiptel").removeClass('validate[required,custom[phone]]');
}

function enableShipinfo() {
	//$(".shipinfo").hide();
	$("#ship_sa option[value='1']").attr("selected", "selected");
	$("#ship_sa").removeAttr('disabled');
	$("#ship_sa").removeClass('disabled');
	$("#ship_sa").addClass('validate[required]');
	
	$("#shipfirstname").val('');
	$("#shipfirstname").removeAttr('readonly');
	$("#shipfirstname").removeClass('disabled');
	$("#shipfirstname").addClass('validate[required]');
	
	$("#shiplastname").val('');
	$("#shiplastname").removeAttr('readonly');
	$("#shiplastname").removeClass('disabled');
	$("#shiplastname").addClass('validate[required]');
	
	$("#shipflat").val('');
	$("#shipflat").removeAttr('readonly');
	$("#shipflat").removeClass('disabled');
	
	$("#shipfloor").val('');
	$("#shipfloor").removeAttr('readonly');
	$("#shipfloor").removeClass('disabled');
	
	$("#shipblock").val('');
	$("#shipblock").removeAttr('readonly');
	$("#shipblock").removeClass('disabled');
	
	$("#shipaddress1").val('');
	$("#shipaddress1").removeAttr('readonly');
	$("#shipaddress1").removeClass('disabled');
	
	$("#shipaddress2").val('');
	$("#shipaddress2").removeAttr('readonly');
	$("#shipaddress2").removeClass('disabled');
	
	$("#shipaddress3").val('');
	$("#shipaddress3").removeAttr('readonly');
	$("#shipaddress3").removeClass('disabled');
	
	$("#shipcountry option[value='']").attr("selected", "selected");
	$("#shipcountry").removeAttr('disabled');
	$("#shipcountry").removeClass('disabled');
	$("#shipcountry").addClass('validate[required]');
	
	var country = $("#shipcountry option:selected").val();
	
	if (country == 'HK' || country == '') {
		$("#shipdistrict option[value='']").attr("selected", "selected");
		$("#shipdistrict").removeAttr('disabled');
		$("#shipdistrict").removeClass('disabled');
		
		$("#shipprovince").attr('disabled', 'disabled');
		$("#shipprovince").addClass('disabled');
		$("#shipprovince option[value='']").attr("selected", "selected");
		
		if (country == 'HK') {
			$("#shiptablelink").show();
		}
	}
	$("#shipdistrict").addClass('validate[required,funcCall[checkShipCountry]]');
	
	$("#shiptel").val('');
	$("#shiptel").removeAttr('readonly');
	$("#shiptel").removeClass('disabled');
	$("#shiptel").addClass('validate[required,custom[phone]]');
}

function checkPaymentGateway() {
	var val = $(".paygateway:checked").val();
	switch(val) {
		case 'MASTER':
			$(".creditcard").show();
			$(".creditcard_others").show();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardAddClass(val);
			break;
		case 'VISA':
			$(".creditcard").show();
			$(".creditcard_others").show();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardAddClass(val);
			break;
		case 'AE':
			$(".creditcard").show();
			$(".creditcard_others").hide();
			$(".creditcard_ae").show();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardAddClass(val);
			break;
		case 'COD':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardRemoveClass();
			break;
		case 'wingon':
			$(".creditcard").show();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").show();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardAddClass(val);
			break;
		case 'tt1':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardRemoveClass();
			break;
		case 'tt2':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardRemoveClass();
			break;
		case 'bankin1':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardRemoveClass();
			break;
		case 'bankin2':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardRemoveClass();
			break;
		case 'boc':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=2]").attr('checked', 'checked');
			creditCardRemoveClass();
			break;
		default:
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			$(".paymentmethod[value=1]").attr('checked', 'checked');
			creditCardRemoveClass();
			break;
	}
}

function creditCardAddClass(payment_method) {
	if (payment_method == 'AE') {
		creditCardRemoveValidate();
		
		aeAddValidate();
		
		wingonRemoveValidate();
	} else if (payment_method == 'wingon') {
		creditCardRemoveValidate();
		
		aeRemoveValidate();
		
		wingonAddValidate();
	} else {
		creditCardAddValidate();
		
		aeRemoveValidate();
		
		wingonRemoveValidate();
	}
	$('#credit_card_name').addClass('validate[required]');
	$('#credit_card_expiry_month').addClass('validate[required]');
	$('#credit_card_expiry_year').addClass('validate[required]');
}

function creditCardRemoveClass() {
	creditCardRemoveValidate();
	
	aeRemoveValidate();
	
	wingonRemoveValidate();
	
	$('#credit_card_name').removeClass('validate[required]');
	$('#credit_card_expiry_month').removeClass('validate[required]');
	$('#credit_card_expiry_year').removeClass('validate[required]');
}

function creditCardAddValidate() {
	// Visa, Master
	$('#credit_card_number1').addClass('validate[required]');
	$('#credit_card_number2').addClass('validate[required]');
	$('#credit_card_number3').addClass('validate[required]');
}

function creditCardRemoveValidate() {
	// Visa, Master
	$('#credit_card_number1').removeClass('validate[required]');
	$('#credit_card_number2').removeClass('validate[required]');
	$('#credit_card_number3').removeClass('validate[required]');
}

function aeAddValidate() {
	// American Express
	$('#ae_credit_card_number1').addClass('validate[required]');
	$('#ae_credit_card_number2').addClass('validate[required]');
	$('#ae_credit_card_number3').addClass('validate[required]');
}

function aeRemoveValidate() {
	// American Express
	$('#ae_credit_card_number1').removeClass('validate[required]');
	$('#ae_credit_card_number2').removeClass('validate[required]');
	$('#ae_credit_card_number3').removeClass('validate[required]');
}

function wingonAddValidate() {
	// Wing On Charge Card
	$('#wingon_credit_card_number1').addClass('validate[required]');
	$('#wingon_credit_card_number2').addClass('validate[required]');
}

function wingonRemoveValidate() {
	//Wing On Charge Card
	$('#wingon_credit_card_number1').removeClass('validate[required]');
	$('#wingon_credit_card_number2').removeClass('validate[required]');
}

function checkDeliveryMethod() {
	var val = $(".delivery:checked").val();
	if (val == 1) {
		$(".offline_delivery").show();
		$(".deliverymethod").addClass('validate[required]');
		$(".online_delivery").hide();
	} else {
		$(".offline_delivery").hide();
		$(".deliverymethod").removeClass('validate[required]');
		$(".online_delivery").show();
	}
}

function displayPaymentMethods() {
	$(".paygateway").addClass('validate[required]');
	var paygateway = $(".paygateway:checked").val();
	
	switch(paygateway) {
		case 'MASTER':
			$(".creditcard").show();
			$(".creditcard_others").show();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardAddClass(paygateway);
			break;
		case 'VISA':
			$(".creditcard").show();
			$(".creditcard_others").show();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardAddClass(paygateway);
			break;
		case 'AE':
			$(".creditcard").show();
			$(".creditcard_others").hide();
			$(".creditcard_ae").show();
			$(".creditcard_wingon").hide();
			creditCardAddClass(paygateway);
			break;
		case 'COD':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardRemoveClass();
			break;
		case 'wingon':
			$(".creditcard").show();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").show();
			creditCardAddClass(paygateway);
			break;
		case 'tt1':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardRemoveClass();
			break;
		case 'tt2':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardRemoveClass();
			break;
		case 'bankin1':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardRemoveClass();
			break;
		case 'bankin2':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardRemoveClass();
			break;
		case 'boc':
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardRemoveClass();
			break;
		default:
			$(".creditcard").hide();
			$(".creditcard_others").hide();
			$(".creditcard_ae").hide();
			$(".creditcard_wingon").hide();
			creditCardRemoveClass();
			break;
	}
}

function checkGiftCoRegsitrantAddr() {
	var value = $(".co_registrant_addr:checked").val();
	if (value == 1) {
		copyCheckGiftCoAddrValue1();
	} else {
		$("#co_registrant_flat").val('');
		$("#co_registrant_flat").removeAttr('readonly');
		$("#co_registrant_flat").removeClass('disabled');
		$("#co_registrant_floor").val('');
		$("#co_registrant_floor").removeAttr('readonly');
		$("#co_registrant_floor").removeClass('disabled');
		$("#co_registrant_block").val('');
		$("#co_registrant_block").removeAttr('readonly');
		$("#co_registrant_block").removeClass('disabled');
		$("#co_registrant_addr1").val('');
		$("#co_registrant_addr1").removeAttr('readonly');
		$("#co_registrant_addr1").removeClass('disabled');
		$("#co_registrant_addr2").val('');
		$("#co_registrant_addr2").removeAttr('readonly');
		$("#co_registrant_addr2").removeClass('disabled');
		$("#co_registrant_addr3").val('');
		$("#co_registrant_addr3").removeAttr('readonly');
		$("#co_registrant_addr3").removeClass('disabled');
		$("#co_registrant_district option[value='']").attr("selected", "selected");
		$("#co_registrant_district").removeAttr('disabled');
		$("#co_registrant_district").removeClass('disabled');
	}
}

function initCheckGiftCoRegsitrantAddr() {
	var value = $(".co_registrant_addr:checked").val();
	if (value == 1) {
		copyCheckGiftCoAddrValue1();
	}
}

function copyCheckGiftCoAddrValue1() {
	$("#co_registrant_flat").val($("#registrant_flat").val());
	$("#co_registrant_flat").attr('readonly', 'readonly');
	$("#co_registrant_flat").addClass('disabled');
	$("#co_registrant_floor").val($("#registrant_floor").val());
	$("#co_registrant_floor").attr('readonly', 'readonly');
	$("#co_registrant_floor").addClass('disabled');
	$("#co_registrant_block").val($("#registrant_block").val());
	$("#co_registrant_block").attr('readonly', 'readonly');
	$("#co_registrant_block").addClass('disabled');
	$("#co_registrant_addr1").val($("#registrant_addr1").val());
	$("#co_registrant_addr1").attr('readonly', 'readonly');
	$("#co_registrant_addr1").addClass('disabled');
	$("#co_registrant_addr2").val($("#registrant_addr2").val());
	$("#co_registrant_addr2").attr('readonly', 'readonly');
	$("#co_registrant_addr2").addClass('disabled');
	$("#co_registrant_addr3").val($("#registrant_addr3").val());
	$("#co_registrant_addr3").attr('readonly', 'readonly');
	$("#co_registrant_addr3").addClass('disabled');
	$("#co_registrant_district option[value=" + $("#registrant_district option:selected").val() + "]").attr('selected', 'selected');
	$("#co_registrant_district").attr('disabled', 'disabled');
	$("#co_registrant_district").addClass('disabled');
}

function checkGiftShippingAddr() {
	var value = $(".ship_addr:checked").val();
	if (value == 1) {
		copyGiftShippingValue1();
	} else if (value == 2) {
		copyGiftShippingValue2();
	} else {
		$("#ship_flat").val('');
		$("#ship_flat").removeAttr('readonly');
		$("#ship_flat").removeClass('disabled');
		$("#ship_floor").val('');
		$("#ship_floor").removeAttr('readonly');
		$("#ship_floor").removeClass('disabled');
		$("#ship_block").val('');
		$("#ship_block").removeAttr('readonly');
		$("#ship_block").removeClass('disabled');
		$("#ship_addr1").val('');
		$("#ship_addr1").removeAttr('readonly');
		$("#ship_addr1").removeClass('disabled');
		$("#ship_addr2").val('');
		$("#ship_addr2").removeAttr('readonly');
		$("#ship_addr2").removeClass('disabled');
		$("#ship_addr3").val('');
		$("#ship_addr3").removeAttr('readonly');
		$("#ship_addr3").removeClass('disabled');
		$("#ship_district option[value='']").attr("selected", "selected");
		$("#ship_district").removeAttr('disabled');
		$("#ship_district").removeClass('disabled');
	}
}

function initCheckGiftShippingAddr() {
	var value = $(".ship_addr:checked").val();
	if (value == 1) {
		copyGiftShippingValue1();
	} else if (value == 2) {
		copyGiftShippingValue2();
	}
}

function copyGiftShippingValue1() {
	$("#ship_flat").val($("#registrant_flat").val());
	$("#ship_flat").attr('readonly', 'readonly');
	$("#ship_flat").addClass('disabled');
	$("#ship_floor").val($("#registrant_floor").val());
	$("#ship_floor").attr('readonly', 'readonly');
	$("#ship_floor").addClass('disabled');
	$("#ship_block").val($("#registrant_block").val());
	$("#ship_block").attr('readonly', 'readonly');
	$("#ship_block").addClass('disabled');
	$("#ship_addr1").val($("#registrant_addr1").val());
	$("#ship_addr1").attr('readonly', 'readonly');
	$("#ship_addr1").addClass('disabled');
	$("#ship_addr2").val($("#registrant_addr2").val());
	$("#ship_addr2").attr('readonly', 'readonly');
	$("#ship_addr2").addClass('disabled');
	$("#ship_addr3").val($("#registrant_addr3").val());
	$("#ship_addr3").attr('readonly', 'readonly');
	$("#ship_addr3").addClass('disabled');
	$("#ship_district option[value=" + $("#registrant_district option:selected").val() + "]").attr('selected', 'selected');
	$("#ship_district").attr('disabled', 'disabled');
	$("#ship_district").addClass('disabled');
}

function copyGiftShippingValue2() {
	$("#ship_flat").val($("#co_registrant_flat").val());
	$("#ship_flat").attr('readonly', 'readonly');
	$("#ship_flat").addClass('disabled');
	$("#ship_floor").val($("#co_registrant_floor").val());
	$("#ship_floor").attr('readonly', 'readonly');
	$("#ship_floor").addClass('disabled');
	$("#ship_block").val($("#co_registrant_block").val());
	$("#ship_block").attr('readonly', 'readonly');
	$("#ship_block").addClass('disabled');
	$("#ship_addr1").val($("#co_registrant_addr1").val());
	$("#ship_addr1").attr('readonly', 'readonly');
	$("#ship_addr1").addClass('disabled');
	$("#ship_addr2").val($("#co_registrant_addr2").val());
	$("#ship_addr2").attr('readonly', 'readonly');
	$("#ship_addr2").addClass('disabled');
	$("#ship_addr3").val($("#co_registrant_addr3").val());
	$("#ship_addr3").attr('readonly', 'readonly');
	$("#ship_addr3").addClass('disabled');
	$("#ship_district option[value=" + $("#co_registrant_district option:selected").val() + "]").attr('selected', 'selected');
	$("#ship_district").attr('disabled', 'disabled');
	$("#ship_district").addClass('disabled');
}
