function editCustomer(id) {
   $.post('customerInformation.php', {id: id}, editCustomerCallback);
}

function editCustomerCallback(data) {
   var objCustomer = JSON.parse(data);
   
   if (objCustomer.Id == 0) {
      alert('There was an error loading the customer object');
   } else {
      $('#mainForm').find(':input').each(function (input, element) {
         if ($(this).attr('type') == 'checkbox')  {
            if (objCustomer[$(this).attr('id')] == 1) {
               $(this).attr('checked', true);
            } else {
               $(this).attr('checked', false);
            }
         } else if ($(this).attr('type') == 'radio') {
            //do later
         } else if ($(this).attr('type') == 'button' || $(this).attr('type') == 'reset' || $(this).attr('type') == 'submit') {
            //do nothing
         } else {
            if ($(this).attr('id') != 'CustomerPassword') {
               $(this).val(objCustomer[$(this).attr('id')]);
            }
         }
      });
      $("#CustomerPassword").removeClass( "required" );
      
      $('html, body').animate({
        scrollTop: $("#Id").offset().top
       }, 1000);
   }
}

function clearCustomerForm() {
   $('#mainForm').find(':input').each(function (input, element) {
      if ($(this).attr('type') == 'checkbox')  {
         $(this).attr('checked', false);
      } else if ($(this).attr('type') == 'radio') {
         //do later
      } else if ($(this).attr('type') == 'button' || $(this).attr('type') == 'reset' || $(this).attr('type') == 'submit') {
         //do nothing
      } else {
         $(this).val('');
      }

      $("#CustomerPassword").removeClass( "required" );
      $("#CustomerPassword").addClass( "required" );
   });
    $('html, body').animate({
        scrollTop: $("#recordList").offset().top
    }, 1000);
}




function editUser(id) {
   $.post('userInformation.php', {id: id}, editUserCallback);
}

function editUserCallback(data) {
   var objUser = JSON.parse(data);
   
   if (objUser.Id == 0) {
      alert('There was an error loading the customer object');
   } else {
      $("#mainForm").inputs( objUser );
      $("#UserPassword").removeClass( "required" );
      
      $('html, body').animate({
        scrollTop: $("#Id").offset().top
       }, 1000);
   }
}

function clearEditForm() {
   $('#mainForm').find(':input').each(function (input, element) {
      if ($(this).attr('type') == 'checkbox')  {
         $(this).attr('checked', false);
      } else if ($(this).attr('type') == 'radio') {
         //do later
      } else if ($(this).attr('type') == 'button' || $(this).attr('type') == 'reset' || $(this).attr('type') == 'submit') {
         //do nothing
      } else {
         $(this).val('');
      }

      $("#UserPassword").removeClass( "required" );
      $("#UserPassword").addClass( "required" );
   });
    $('html, body').animate({
        scrollTop: $("#recordList").offset().top
    }, 1000);
}
