//on page load
$(document).ready(function() {
    
    //when the checkbox is checked or unchecked
    $('#copyaddress').click(function() {
            
        // If checked
        if ($("#copyaddress").is(":checked")) {
            
            //for each input field
            $('#shipping_fields input', ':visible', document.body).each(function(i) { 
                //copy the values from the billing_fields inputs
                //to the equiv inputs on the shipping_fields
                $(this).val( $('#billing_fields input').eq(i).val() );
//				fieldvalidation(this);
                });
        
        } else {
    
            //for each input field
            $('#shipping_fields input', ':visible', document.body).each(function(i) { 
                //set shipping_fields inputs to blank
                $(this).val(""); 
//				fieldvalidation(this);
//			document.write(document.getElementById("c2s_shippingaddress1"));
                });


	    }
			fieldvalidation(document.getElementById("c2s_shippingaddress1"));
			fieldvalidation(document.getElementById("c2s_shippingcity"));
			fieldvalidation(document.getElementById("c2s_shippingpostcode"));
    });

});

