$(document).ready(function() {
    $("#contact-form input:text, #contact-form textarea").focus(function() {
        if($(this).val() == $(this).get(0).defaultValue) {
            $(this).val("");
        }
    });

    $("#contact-form input:text, #contact-form textarea").blur(function() {
        if($(this).val() == "") {
            $(this).val($(this).get(0).defaultValue);
        }
    });

    $(".accordion li .question").click(function() {
        $(this).next(".answer").slideToggle("fast");
        return false;
    })
//
//    $('#contact-form #submit').click(function() {
//        submitContactForm();
//    });
});

function submitContactForm() {
  var hasError = false;
  $('#contact-form .required').each(function() {
    if(jQuery.trim($(this).val()) == '') {
      $(this).addClass("error");
      hasError = true;
    } else if($(this).hasClass('email')) {
      var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
      if(!emailReg.test(jQuery.trim($(this).val()))) {
        $(this).addClass("error");
        hasError = true;
      } else {
        $(this).removeClass("error");
      }
    } else {
      $(this).removeClass("error");
    }
  });
  if(!hasError) {
//    $('#contact-form').submit();
    return true;
  }

  return false;
}
