(function ($) {
    //
    // Based on code from http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
    $.fn.valign = function() {
        return this.each(function(i){
            var ah = $(this).height();
            var ph = $(this).parent().height();
            var mh = (ph - ah) / 2;
            //
            // Because these elements are floated, their position must be set as
            // relative and their top must be adjusted.
            $(this).css({top: mh, position: 'relative'});
        });
    };
    
    $('#billing_same').click(function() {
                   if (this.checked){
                       $('#old_billing_div').hide();
                       $('#shipoldbtn').attr('value','Ship To Selected Address');
                       $('#hide_button').show();
                   } else {
                       $('#new_shipping_div').hide();
                         $('#old_billing_div').show();
                         $('#new_shipping_tips').show();
                         $('#shipoldbtn').attr('value','Submit');
                         //$('select#address[Country]').clone().attr('id', 'newOptions').appendTo('#billold[Country]');
                         //$('#billing_same').clone().appendTo('#billing_same');
                          $('#hide_button').hide();
                   }

                    
		});
      $('#new_bill_check').click(function() {
          
                   if (this.checked){
                      $('#ship_copy_btn').attr('value','Ship To Entered Address');
                      $('#new_billing_div').hide();
                      $('#hide_button').show();
                   } else {
                       $('#hide_button').hide();
                         $('#new_billing_div').slideDown();
                         
                         $('#ship_copy_btn').attr('value','Submit');
                   }

                    
		});          
                $('#new_bill_check2').click(function() {
          
                   if (this.checked){
                      $('#ship_copy_btn').attr('value','Ship To Entered Address');
                      $('#new_billing_div').hide();
                      $('#hide_button2').show();
                   } else {
                       $('#hide_button2').hide();
                         $('#new_billing_div').slideDown();
                         
                         $('#ship_copy_btn').attr('value','Submit');
                   }

                    
		});
     $('#new_shipping_tips').click(function() {
         $('#old_billing_div').hide();
         $('#new_shipping_div').slideDown();
             if ($('#billing_same1').is(':checked')){
                 $('#new_billing_div').hide();
             }
         $('#new_shipping_tips').hide();
        });
     
     $('#ship_selected_btn').click(function() {
         copyAddress();
     });
})(jQuery);

function copyAddress()
{
    alert("test");
}
