function init_all_the_ninja_things(){function ninja_forms_countdown(a,b){$countdown=jQuery("#"+a),counter=parseInt($countdown.data("countdown"))-1,$countdown.val(counter).data("countdown",counter).find("span").html(counter),counter<=0&&(window.clearInterval(window.ninja_forms_timer.index),$countdown.removeAttr("disabled").html($countdown.data("text")))}jQuery(".ninja-forms-form input").bind("keypress",function(a){if(13==a.keyCode){jQuery(this).attr("type")}}),jQuery(document).ready(function(){if(jQuery("div.label-inside input, div.label-inside textarea").focus(function(){var a=jQuery("#"+this.id+"_label_hidden").val();this.value==a&&(this.value="")}),jQuery("div.label-inside input, div.label-inside textarea").blur(function(){var a=jQuery("#"+this.id+"_label_hidden").val();""==this.value&&(this.value=a)}),jQuery.fn.mask){jQuery(".ninja-forms-mask").each(function(){var a=jQuery(this).data("mask");a=a.toString(),jQuery(this).mask(a)});var a=ninja_forms_settings.date_format;a=a.replace(/m/g,9),a=a.replace(/d/g,9),a=a.replace(/y/g,99),a=a.replace(/Y/g,9999),jQuery(".ninja-forms-date").mask(a)}jQuery.fn.datepicker&&jQuery(".ninja-forms-datepicker").datepicker(ninja_forms_settings.datepicker_args),jQuery.fn.autoNumeric&&jQuery(".ninja-forms-currency").autoNumeric({aSign:ninja_forms_settings.currency_symbol,aSep:thousandsSeparator,aDec:decimalPoint})}),jQuery.fn.qtip&&jQuery(".ninja-forms-help-text").qtip({style:{classes:"qtip-shadow qtip-dark"}}),jQuery(document).ready(function(){jQuery(".input-limit").each(function(){var a=jQuery(this).data("input-limit"),b=jQuery(this).data("input-limit-type"),c=jQuery(this).data("input-limit-msg");jQuery(this).counter({count:"down",goal:a,type:b,msg:c})})}),jQuery(".ninja-forms-form").each(function(){var a=this.id.replace("ninja_forms_form_",""),b=window["ninja_forms_form_"+a+"_settings"];if("undefined"!=typeof b?ajax=b.ajax:ajax=0,1==ajax){var c={beforeSerialize:function(a,b){"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave()},beforeSubmit:ninja_forms_before_submit,success:ninja_forms_response,dataType:"json"};jQuery(this).ajaxForm(c),jQuery(this).on("submitResponse.default",function(a,b){return ninja_forms_default_response(b)}),jQuery(this).on("beforeSubmit.default",function(a,b,c,d){return ninja_forms_default_before_submit(b,c,d)})}else jQuery(this).submit(function(a){var b=jQuery(this).serialize(),c=this,d="";return ninja_forms_before_submit(b,c,d)})}),jQuery(".pass1").val("").keyup(function(){var a=this.value,b=this.id.replace("pass1","pass2");b=jQuery("#"+b).val(),check_pass_strength(a,b)}),jQuery(".pass2").val("").keyup(function(){var a=this.value,b=this.id.replace("pass2","pass1");b=jQuery("#"+b).val(),check_pass_strength(b,a)}),jQuery(".countdown-timer").each(function(a){jQuery(this).attr("disabled","disabled").parents(".field-wrap:first").find("input.no-js").remove(),id=jQuery(this).attr("id"),window.ninja_forms_timer&&window.clearInterval(window.ninja_forms_timer.index),window.ninja_forms_timer={index:window.setInterval(function(){ninja_forms_countdown(id,a)},1e3)}});var calc_fields=jQuery(".ninja-forms-field-calc-listen");calc_fields.each(function(a,b){if("checkbox"==this.type)if(this.checked)var c="checked";else var c="unchecked";else if("undefined"==typeof this.type)var c=jQuery(this).prop("innerHTML");else var c=jQuery(this).val();var d=ninja_forms_get_form_id(this),e=jQuery(this).attr("rel"),f=window["ninja_forms_form_"+d+"_calc_settings"];for(calc_id in f.calc_fields)calc_id!=e&&jQuery(b).data(calc_id+"-oldValue",c)}),jQuery("body").on("focus",".ninja-forms-field-list-options-span-calc-listen",function(a){var b=jQuery(this).attr("rel");if("list"==jQuery("#ninja_forms_field_"+b+"_type").val()&&"radio"==jQuery("#ninja_forms_field_"+b+"_list_type").val()){var c=ninja_forms_get_form_id(this),d=window["ninja_forms_form_"+c+"_calc_settings"];for(calc_id in d.calc_fields)calc_id!=b&&jQuery(this).data(calc_id+"-oldValue",jQuery("input[name='ninja_forms_field_"+b+"']:checked").val())}}),jQuery("body").on("mousedown",".ninja-forms-field-list-options-span-calc-listen",function(a){var b=jQuery(this).attr("rel");if("list"==jQuery("#ninja_forms_field_"+b+"_type").val()&&"radio"==jQuery("#ninja_forms_field_"+b+"_list_type").val()){var c=ninja_forms_get_form_id(this),d=window["ninja_forms_form_"+c+"_calc_settings"];for(calc_id in d.calc_fields)calc_id!=b&&jQuery(this).data(calc_id+"-oldValue",jQuery("input[name='ninja_forms_field_"+b+"']:checked").val())}}),jQuery("body").on("change",".ninja-forms-field-calc-listen",function(event){if(this==event.target){var form_id=ninja_forms_get_form_id(this),field_id=jQuery(this).attr("rel"),calc_settings=window["ninja_forms_form_"+form_id+"_calc_settings"],visible=jQuery("#ninja_forms_field_"+field_id+"_div_wrap").data("visible");for(calc_id in calc_settings.calc_fields)if(calc_id!=field_id){var calc_method=calc_settings.calc_fields[calc_id].method,calc_places=calc_settings.calc_fields[calc_id].places;if("fields"==calc_method){for(var change=!1,i=calc_settings.calc_fields[calc_id].fields.length-1;i>=0;i--)if(calc_settings.calc_fields[calc_id].fields[i].field==field_id){change=!0;break}}else if("eq"==calc_method){var change=!1;if("undefined"!=typeof calc_settings.calc_fields[calc_id].fields)for(var i=calc_settings.calc_fields[calc_id].fields.length-1;i>=0;i--)if(calc_settings.calc_fields[calc_id].fields[i]==field_id){change=!0;break}}if(("fields"==calc_method||"eq"==calc_method)&&change||"auto"==calc_method){if("auto"==calc_method||"fields"==calc_method){var key=jQuery(this).val(),new_value="";if(old_value=jQuery(this).data(calc_id+"-oldValue"),"list"==jQuery("#ninja_forms_field_"+field_id+"_type").val()){var key=jQuery(this).val();if("checkbox"==jQuery("#ninja_forms_field_"+field_id+"_list_type").val())this.checked?jQuery(this).data(calc_id+"-oldValue","checked"):jQuery(this).data(calc_id+"-oldValue","unchecked"),this.checked&&1==visible?old_value=0:this.checked&&1!=visible?(old_value=key,new_value=0):this.checked||1!=visible?this.checked||1==visible||(old_value="checked"==old_value?key:0,new_value=0):(old_value="checked"==old_value?key:0,new_value=0);else if("radio"==jQuery("#ninja_forms_field_"+field_id+"_list_type").val()){var span=jQuery(this).parent().parent().parent().parent();old_value=jQuery(span).data(calc_id+"-oldValue"),"undefined"==typeof old_value&&this.checked&&(old_value=jQuery(this).val()),this.checked&&1==visible?old_value==key&&(old_value=0):this.checked&&1!=visible?new_value=0:this.checked||(old_value=0,new_value=0),this.checked&&jQuery(span).data(calc_id+"-oldValue",key)}else if("multi"==jQuery("#ninja_forms_field_"+field_id+"_list_type").val()){if(jQuery.isArray(key)){for(var tmp=0,i=key.length-1;i>=0;i--)"undefined"!=typeof calc_settings.calc_value[field_id][key[i]]&&(tmp+=parseFloat(calc_settings.calc_value[field_id][key[i]]));new_value=tmp}if(jQuery.isArray(old_value)){for(var tmp=0,i=old_value.length-1;i>=0;i--)"undefined"!=typeof calc_settings.calc_value[field_id][old_value[i]]&&(tmp+=parseFloat(calc_settings.calc_value[field_id][old_value[i]]));old_value=tmp}}else var old_value=jQuery(this).data(calc_id+"-oldValue")}else if("checkbox"==jQuery("#ninja_forms_field_"+field_id+"_type").val())if(this.checked&&1==visible){var key="checked";old_value="unchecked"}else if(this.checked&&1!=visible){var key="unchecked";old_value="checked"==jQuery(this).data(calc_id+"-oldValue")||"undefined"==typeof jQuery(this).data(calc_id+"-oldValue")?"checked":0}else if(this.checked||1==visible){var key="unchecked";old_value="checked"==jQuery(this).data(calc_id+"-oldValue")||"undefined"==typeof jQuery(this).data(calc_id+"-oldValue")?"checked":0}else{var key="unchecked";old_value=0}else"calc"==jQuery("#ninja_forms_field_"+field_id+"_type").val()&&""==key&&(key=jQuery("#ninja_forms_field_"+field_id).prop("innerHTML"));if(""===new_value)if("undefined"!=typeof calc_settings.calc_value[field_id]&&"undefined"!=typeof calc_settings.calc_value[field_id][key])var new_value=calc_settings.calc_value[field_id][key];else{if("undefined"==typeof this.type)var new_value=this.innerHTML;else var new_value=this.value;"undefined"!=typeof ninja_forms_settings.currency_symbol&&(f_value=new_value.replace(ninja_forms_settings.currency_symbol,""),f_value=f_value.replace(/thousandsSeparator/g,""),"."!=decimalPoint&&(f_value=f_value.replace(decimalPoint,"."))),isNaN(new_value)&&(new_value=0)}if("undefined"!=typeof calc_settings.calc_value[field_id]&&"undefined"!=typeof calc_settings.calc_value[field_id][old_value]?old_value=calc_settings.calc_value[field_id][old_value]:""==old_value||"undefined"==typeof old_value?old_value=0:isNaN(old_value)&&"undefined"!=typeof ninja_forms_settings.currency_symbol&&(old_value=old_value.replace(ninja_forms_settings.currency_symbol,""),old_value=old_value.replace(/,/g,"")),"text"==jQuery("#ninja_forms_field_"+calc_id).attr("type"))var current_value=jQuery("#ninja_forms_field_"+calc_id).val();else var current_value=jQuery("#ninja_forms_field_"+calc_id).html();if(current_value=current_value.replace(/thousandsSeparator/g,""),"."!=decimalPoint&&(current_value=current_value.replace(decimalPoint,".")),"undefined"!=typeof ninja_forms_settings.currency_symbol&&"undefined"!=typeof current_value&&(f_value=current_value.replace(ninja_forms_settings.currency_symbol,""),f_value=f_value.replace(/thousandsSeparator/g,""),"."!=decimalPoint&&(f_value=f_value.replace(decimalPoint,"."))),current_value=isNaN(current_value)?0:parseFloat(current_value),"auto"==calc_method){var old_op="subtract",new_op="add";jQuery(this).hasClass("ninja-forms-field-calc-auto")||(old_value="",new_value="")}else if("fields"==calc_method)for(var i=calc_settings.calc_fields[calc_id].fields.length-1;i>=0;i--)if(calc_settings.calc_fields[calc_id].fields[i].field==field_id)var old_op=ninja_forms_find_opposite_op(calc_settings.calc_fields[calc_id].fields[i].op),new_op=calc_settings.calc_fields[calc_id].fields[i].op;if(old_value&&!isNaN(old_value)&&0!=old_value&&""!=old_value&&!jQuery(this).hasClass("ninja-forms-field-calc-no-old-op")){old_value=parseFloat(old_value);var asdf=current_value;tmp=new ninja_forms_var_operator(old_op),current_value=tmp.evaluate(current_value,old_value)}if(!new_value||isNaN(new_value)||0==new_value||""==new_value||jQuery(this).hasClass("ninja-forms-field-calc-no-new-op"))var calc_value=current_value;else{new_value=parseFloat(new_value),tmp=new ninja_forms_var_operator(new_op);var calc_value=tmp.evaluate(current_value,new_value)}}else if("eq"==calc_method){for(var tmp_eq=calc_settings.calc_fields[calc_id].eq,i=calc_settings.calc_fields[calc_id].fields.length-1;i>=0;i--){var f_id=calc_settings.calc_fields[calc_id].fields[i],key=jQuery("#ninja_forms_field_"+f_id).val(),f_value="";if("list"==jQuery("#ninja_forms_field_"+f_id+"_type").val()){if("radio"==jQuery("#ninja_forms_field_"+f_id+"_list_type").val())key=jQuery(".ninja-forms-field-"+f_id+"-options :checked").val();else if("multi"==jQuery("#ninja_forms_field_"+f_id+"_list_type").val()){if(jQuery.isArray(key)){for(var tmp=0,x=key.length-1;x>=0;x--)"undefined"!=typeof calc_settings.calc_value[f_id][key[x]]&&(tmp+=parseFloat(calc_settings.calc_value[f_id][key[x]]));f_value=tmp}}else if("checkbox"==jQuery("#ninja_forms_field_"+f_id+"_list_type").val()){var tmp=0;jQuery(".ninja-forms-field-"+f_id+"-options :checked").each(function(){"undefined"!=typeof calc_settings.calc_value[f_id][this.value]&&(tmp+=parseFloat(calc_settings.calc_value[f_id][this.value]))}),f_value=tmp}}else if("checkbox"==jQuery("#ninja_forms_field_"+f_id+"_type").val())if(jQuery("#ninja_forms_field_"+f_id).attr("checked"))var key="checked";else var key="unchecked";else"calc"==jQuery("#ninja_forms_field_"+f_id+"_type").val()&&""==key&&(f_value=jQuery("#ninja_forms_field_"+f_id).prop("innerHTML"));""==f_value&&(f_value="undefined"!=typeof calc_settings.calc_value[f_id]&&"undefined"!=typeof calc_settings.calc_value[f_id][key]?calc_settings.calc_value[f_id][key]:key),"undefined"!=typeof f_value&&"string"==typeof f_value&&f_value.indexOf("%")>=0&&(f_value=f_value.replace("%",""),isNaN(f_value)||(f_value=parseFloat(f_value)/100)),"undefined"==typeof this.type&&""==key&&(f_value=this.innerHTML),"undefined"!=typeof ninja_forms_settings.currency_symbol&&isNaN(f_value)&&"undefined"!=typeof f_value&&(f_value=f_value.replace(ninja_forms_settings.currency_symbol,""),f_value=f_value.replace(/thousandsSeparator/g,""),"."!=decimalPoint&&(f_value=f_value.replace(decimalPoint,"."))),!isNaN(f_value)&&""!=f_value&&f_value&&"undefined"!=typeof f_value||(f_value=0);var find="field_"+f_id,re=new RegExp(find,"g");tmp_eq=tmp_eq.replace(re,f_value)}var calc_value=eval(tmp_eq)}if("text"==jQuery("#ninja_forms_field_"+calc_id).attr("type"))var current_value=jQuery("#ninja_forms_field_"+calc_id).val();else var current_value=jQuery("#ninja_forms_field_"+calc_id).html();"undefined"!=typeof ninja_forms_settings.currency_symbol&&"undefined"!=typeof current_value&&(current_value=current_value.replace(ninja_forms_settings.currency_symbol,"")),current_value=isNaN(current_value)?0:parseFloat(current_value),current_value!==calc_value&&("checkbox"!=jQuery("#ninja_forms_field_"+field_id+"_list_type").val()&&jQuery(this).data(calc_id+"-oldValue",key),"checkbox"==jQuery("#ninja_forms_field_"+field_id+"_list_type").val()||"radio"==jQuery("#ninja_forms_field_"+field_id+"_list_type").val()?jQuery("#ninja_forms_field_"+field_id+"_div_wrap").find(".ninja-forms-field").each(function(){jQuery(this).removeClass("ninja-forms-field-calc-no-old-op")}):jQuery(this).removeClass("ninja-forms-field-calc-no-old-op"),calc_value=calc_value.toFixed(calc_places),"."!=decimalPoint&&(calc_value=calc_value.toString().replace(".",decimalPoint)),"text"==jQuery("#ninja_forms_field_"+calc_id).attr("type")?jQuery("#ninja_forms_field_"+calc_id).val(calc_value):jQuery("#ninja_forms_field_"+calc_id).html(calc_value),jQuery("#ninja_forms_field_"+calc_id).trigger("change"))}}}})}function ninja_forms_before_submit(a,b,c){var d=jQuery(b).prop("id").replace("ninja_forms_form_","");jQuery("#nf_submit_"+d).hide(),jQuery("#nf_processing_"+d).show(),jQuery(document).data("submit_action","submit");var e=jQuery(b).triggerHandler("beforeSubmit",[a,b,c]);return e!==!1&&(e=jQuery("body").triggerHandler("beforeSubmit",[a,b,c])),e!==!1&&(e=jQuery(document).triggerHandler("beforeSubmit",[a,b,c])),e}function ninja_forms_response(a,b,c,d){var e=a.form_id;if(jQuery("#nf_processing_"+e).hide(),jQuery("#nf_submit_"+e).show(),"inline"==ninja_forms_settings.ajax_msg_format){var f=jQuery(d).triggerHandler("submitResponse",[a]);return f!==!1&&(f=jQuery("body").triggerHandler("submitResponse",[a])),f!==!1&&(f=jQuery(document).triggerHandler("submitResponse",[a])),f}}function ninja_forms_default_before_submit(a,b,c){var d=jQuery(b).prop("id").replace("ninja_forms_form_","");return jQuery("#ninja_forms_form_"+d+"_response_msg").prop("innerHTML",""),jQuery("#ninja_forms_form_"+d+"_response_msg").removeClass("ninja-forms-error-msg"),jQuery("#ninja_forms_form_"+d+"_response_msg").removeClass("ninja-forms-success-msg"),jQuery(".ninja-forms-field-error").prop("innerHTML",""),jQuery(".ninja-forms-error").removeClass("ninja-forms-error"),!0}function ninja_forms_default_response(a){a.form_id;return ninja_forms_update_error_msgs(a),ninja_forms_update_success_msg(a),0==a.errors&&"undefined"!=typeof a.form_settings.landing_page&&""!=a.form_settings.landing_page&&(window.location=a.form_settings.landing_page),!0}function ninja_forms_update_success_msg(a){var b="",c=a.form_id,d=a.success,e=a.form_settings,f=e.hide_complete,g=e.clear_complete;if(0!=d){for(var h in d)b+="<p>"+d[h]+"</p>";""!=b&&(jQuery("#ninja_forms_form_"+c+"_response_msg").removeClass("ninja-forms-error-msg"),jQuery("#ninja_forms_form_"+c+"_response_msg").addClass("ninja-forms-success-msg"),jQuery("#ninja_forms_form_"+c+"_response_msg").prop("innerHTML",b),jQuery("#ninja_forms_form_"+c+"_response_msg").show()),1==f&&jQuery("#ninja_forms_form_"+c).hide(),1==g&&(jQuery("#ninja_forms_form_"+c).clearForm(),jQuery("div.label-inside input.ninja-forms-field, div.label-inside textarea.ninja-forms-field").each(function(){var a=jQuery("#"+this.id+"_label_hidden").val();this.value=a}),"rating"in jQuery("input[type=radio].ninja-forms-star")&&jQuery("input[type=radio].ninja-forms-star").rating("drain"))}}function ninja_forms_update_error_msgs(a){var b="",c=a.form_id,d=a.errors;if(0!=d){for(var e in d)if("general"==d[e].location)b+="<p>"+d[e].msg+"</p>";else{var f=d[e].location;jQuery("#ninja_forms_field_"+f+"_error").show(),jQuery("#ninja_forms_field_"+f+"_error").prop("innerHTML",d[e].msg),jQuery("#ninja_forms_field_"+f+"_div_wrap").addClass("ninja-forms-error")}""!=b&&(jQuery("#ninja_forms_form_"+c+"_response_msg").removeClass("ninja-forms-success-msg"),jQuery("#ninja_forms_form_"+c+"_response_msg").addClass("ninja-forms-error-msg"),jQuery("#ninja_forms_form_"+c+"_response_msg").prop("innerHTML",b))}}function ninja_forms_html_decode(a){if(a){var b=jQuery("<div />").html(a).text();return b=jQuery("<div />").html(b).text()}return""}function ninja_forms_toggle_login_register(a,b){var c="ninja_forms_form_"+b+"_"+a+"_form";if("login"==a)var d="ninja_forms_form_"+b+"_register_form";else var d="ninja_forms_form_"+b+"_login_form";var e=document.getElementById(c),f=document.getElementById(d);"block"==e.style.display?e.style.display="none":(e.style.display="block",f.style.display="none")}function ninja_forms_get_form_id(a){var b=jQuery(a).closest("form").prop("id");return"undefined"!=typeof b&&(b=b.replace("ninja_forms_form_",""),""!=b&&"ninja_forms_admin"!=b||(b=jQuery("#_form_id").val()),b)}function check_pass_strength(a,b){if(jQuery("#pass-strength-result").removeClass("short bad good strong"),!a)return void jQuery("#pass-strength-result").html(ninja_forms_password_strength.empty);switch(strength=passwordStrength(a,b),strength){case 2:jQuery("#pass-strength-result").addClass("bad").html(ninja_forms_password_strength.bad);break;case 3:jQuery("#pass-strength-result").addClass("good").html(ninja_forms_password_strength.good);break;case 4:jQuery("#pass-strength-result").addClass("strong").html(ninja_forms_password_strength.strong);break;case 5:jQuery("#pass-strength-result").addClass("short").html(ninja_forms_password_strength.mismatch);break;default:jQuery("#pass-strength-result").addClass("short").html(ninja_forms_password_strength.short)}}function passwordStrength(a,b){var i,j,c=1,d=2,e=3,f=4,g=5,h=0;return a!=b&&b.length>0?g:a.length<4?c:(a.match(/[0-9]/)&&(h+=10),a.match(/[a-z]/)&&(h+=26),a.match(/[A-Z]/)&&(h+=26),a.match(/[^a-zA-Z0-9]/)&&(h+=31),i=Math.log(Math.pow(h,a.length)),j=i/Math.LN2,j<40?d:j<56?e:f)}function ninja_forms_find_opposite_op(a){switch(a){case"add":return"subtract";case"subtract":return"add";case"multiply":return"divide";case"divide":return"multiply"}}function ninja_forms_var_operator(a){this.operation=a,this.evaluate=function(b,c){switch(this.operation){case"add":return b+c;case"subtract":return b-c;case"multiply":return b*c;case"divide":return b/c}}}init_all_the_ninja_things();