// JQuery document
// Display input alerts when no input is provided
$(document).ready(function() {
  $('#contact_form').submit(function() {
    var do_submit = true;
    $('.error_msg').hide('slow');
    $('.required').each(function() {
        switch($(this).attr('type')) {
        case 'text':
          if (!$(this).val()) {
            do_submit = false;
            $(this).prev('.alert_msg').show('slow');
          }
          else {
            $(this).prev('.alert_msg').hide('slow');
          }
          break;
        
        case 'checkbox':
          if (!$(this).attr('checked')) {
            do_submit = false;
            $(this).prev('.alert_msg').show('slow');
          }
          else {
            $(this).prev('.alert_msg').hide('slow');
          }
          break;
        
        default:
          if (!$(this).val()) {
            do_submit = false;
            $(this).prev().children('.alert_msg').show('slow');
          }
          else {
            $(this).prev().children('.alert_msg').hide('slow');
          }
        }
        
    });
    return do_submit;
  })
});
