!function(e){var n=window.jQuery;if("function"!=typeof n||!n.fn.jquery)throw"Fail to init ajaxFormBuilder";var t=function(e,n){this.init(e,n)};t.prototype={init:function(e){if(n(e).length){n(e).attr("action");var t=n(e).attr("class").match(/formBuilder-(\d+)/);if(t.length){var r=t[1];n(e).submit(function(t){var i=n(e).find("label.required"),a=!0,o="__formerror"+r;if(n(e).prev("#"+o).remove(),n(i).each(function(t,r){var i=n(r).attr("for"),o=null,c=!1;i.match(/captcha/)&&(c=!0);var s=n(r).parents(".form-element");if(n(e).find(s).removeClass("container-error"),n(s).hasClass("container_type_allowother")){o=n(s).find("input").val();var l=n(s).find("input").attr("id"),d="other"+(l=l.replace(/[^\d]+/,"")),f=!1,p=n(e).find("dd#"+l+"-element");n(p).parents(".form-element").hasClass("container_type_dropdown")?f=n(p).find("option:selected").val()===d:n(p).parents(".form-element").hasClass("container_type_checkbox")?f=n(p).find("input[value="+d+"]:checked").length:n(p).parents(".form-element").hasClass("container_type_multi_choice")&&(f=n(p).find("input[value="+d+"]:checked").length),f||(o="1")}else n(s).hasClass("container_type_multi_choice")?o=(o=n(s).find("input:checked").length)||"":n(s).hasClass("container_type_checkbox")?o=(o=n(s).find("input:checked").length)||"":n(s).hasClass("container_type_fileupload")?o=n(s).find("input[type=hidden]").val():c?o=n(r).parents(".container_type_captcha").find(".g-recaptcha-response").val():(o=n(e).find("#"+i).val(),n(e).find("#"+i).attr("showif")&&!n(e).find("#"+i).parents(".fb-v2-form-element").is(":visible")&&(o="1"));n.trim(o)||(a=!1,n(e).find(s).addClass("container-error"))}),n(e).find(".container_type_tnc").length&&n(e).find(".container_type_tnc").each(function(e,t){n(t).find("div.type_tnc").removeClass("input_error"),n(t).removeClass("container-error"),n(t).find("input[type=checkbox]:checked").length||(a=!1,n(t).addClass("container-error"),n(t).find("div.type_tnc").addClass("input_error"))}),!a)return n(e).before('There are errors on form. Please fix them before continuing.'),n(e).parent(),t.preventDefault(),t.stopPropagation(),setTimeout(function(){n(e).find('input[type="submit"]').removeAttr("disabled")},100),!1})}}}},n.fn.ajaxFormBuilder=function(e){return this.each(function(){n.data(this,"ajaxFormBuilder")||n.data(this,"ajaxFormBuilder",new t(this,e))})}}();