function checkform() {
  $('submit').disabled = true;
  $('submit').value = "Processing.  Please Wait...";
        
  var error_status = 0;
  document.getElementById('warning').innerHTML = '';
  
  var txt_warning = '<p class="warning"><b>Oops. Looks like something is missing.</b><br />To provide you with the right services, we need the following information:<br />';
  var txt_contact=""; 
  var txt_service="";
  
  var form_warning = [];
  if (document.appointment.name.value == '')      {form_warning.push("name");}
  if (document.appointment.email.value == '')     {form_warning.push("e-mail address");}
  if (document.appointment.address.value == '')   {form_warning.push("address");}
  if (document.appointment.city.value == '')      {form_warning.push("city");}
  if (document.appointment.state.value == '')     {form_warning.push("state");}
  if (document.appointment.zip.value == '')       {form_warning.push("zip code");}
  if (document.appointment.phone.value == '')     {form_warning.push("phone number");}
  
  if (0 < form_warning.length) {
    error_status = 1;
    if (3 <= form_warning.length) {
      form_warning[form_warning.length - 1] = " and " + form_warning[form_warning.length - 1]
      txt_contact += form_warning.join(', ');
    }
    else {
      txt_contact += form_warning.join(' and ');
    }    
    txt_contact = "Please enter your "+txt_contact+". ";
  }
  
  if (document.appointment.wall_to_wall_carpet_cleaning.checked == false &&
      document.appointment.water_damage_repair_and_restoration.checked == false &&
      document.appointment.hardwood_floor_cleaning_and_restoration.checked == false &&
      document.appointment.tile_and_grout_cleaning.checked == false &&
      document.appointment.area_rug_cleaning.checked == false &&
      document.appointment.upholstery_cleaning.checked == false &&
      document.appointment.other_text.value == '') {
    error_status = 1;
    txt_service = (form_warning.length == 0) ? "P" : "Also, p";
    txt_service += "lease select a service or at least tell us something about the work you need done.</p>"    
  }

  if (error_status == 1) {
    document.getElementById('warning').innerHTML += txt_warning + txt_contact + txt_service; 
      $('submit').value = 'Submit';
      $('submit').disabled = false;
      document.getElementById('warning').focus();
      window.scrollTo(0,300); 
      return false;
  }
  
  //check captcha
  $('appointment').request({
    onSuccess: function(transport) 
      {
        if (transport.responseText.match(/^OK/) != null) {
          document.getElementById('captcha_warning').innerHTML = '<p><b>Success!</b><br />Your appointment request was successfully submitted.<br /> You should receive an email of this request within a few minutes.<br />If not, please check your bulk mail folder.<br />We will try to contact you as soon as possible to confirm the appointment.<br />Thank you very much!<br />PCS Cleaning Services<br />718.749.6110<br /></p>';
        }
        else {					
          document.getElementById('captcha').src = 'securimage/securimage_show.php?' + Math.random();

          document.getElementById('captcha_warning').innerHTML = '<p><b>Oops! The codephrase didn\'t match the picture.</b><br />Please try again. (Sorry for the inconvenience, but we have to do this to prevent attacks on our inbox.)</p>';
          $('submit').value = 'Submit';
          $('submit').disabled = false;		
        }
      }
    });
    return false;
}
