jQuery(document).ready(function () {
  jQuery.support.placeholder = (function () {
    var i = document.createElement('input');
    return 'placeholder' in i;
  })();
  if (jQuery.support.placeholder) {
    jQuery('.wpcf7-form li').each(function () {
      if (!jQuery(this).hasClass('js-unhighlight-label')) {
        jQuery(this).addClass('js-hide-label');
      }
    });
  }
  jQuery('.wpcf7-form li').find('input, textarea').on('keyup blur focus', function (e) {

        // Cache our selectors
        var jQuerythis = jQuery(this),
        jQueryparent = jQuerythis.parent();

        // Add or remove classes
        if (e.type == 'keyup') {
          if (jQuerythis.val() == '') {
            jQueryparent.addClass('js-hide-label');
          } else {
            jQueryparent.removeClass('js-hide-label');
          }
        }
        else if (e.type == 'blur') {
          if (jQuerythis.val() == '') {
            jQueryparent.addClass('js-hide-label');
          }
          else {
            jQueryparent.removeClass('js-hide-label').addClass('js-unhighlight-label');
          }
        }
        else if (e.type == 'focus') {
          if (jQuerythis.val() !== '') {
            jQueryparent.removeClass('js-unhighlight-label');
          }
        }
      });
});
