function eCart_copyBillingToShipping(cb){
	if(cb.checked){ // Only copy when the checkbox is checked.
		var theForm = cb.form;
		// The number of elements must match in billingFields and shippingFields. The type of input element must also match between the arrays.
		var billingFields = new Array('BillingFirstnames', 'BillingSurname','BillingAddress1', 'BillingAddress2', 'BillingCity', 'BillingState', 'BillingPostCode', 'BillingCountry');
		var shippingFields = new Array('DeliveryFirstnames', 'DeliverySurname', 'DeliveryAddress1', 'DeliveryAddress2', 'DeliveryCity', 'DeliveryState', 'DeliveryPostCode', 'DeliveryCountry');
		
		for(var i=0;i<billingFields.length;i++){
			var billingObj = theForm.elements[billingFields[i]];
			var shippingObj = theForm.elements[shippingFields[i]];
			if(billingObj && shippingObj){
				if(billingObj.tagName){ // non-radio groups
					var tagName = billingObj.tagName.toLowerCase();
					if(tagName == 'select'){
						shippingObj.selectedIndex = billingObj.selectedIndex;
					}
					else if((billingObj.type && shippingObj.type ) && (billingObj.type == 'checkbox' || billingObj.type == 'radio')){
						shippingObj.checked = billingObj.checked;
					}
					else{ // textareas and other inputs
						shippingObj.value = billingObj.value;
					}					
				}
				else if(billingObj.length){ // radio group
					for(var r=0;r<billingObj.length;r++){
						shippingObj[r].checked = billingObj[r].checked;
					}
				}
			}
		}
	}
}
