function PowermailForm(e){"use strict";this.initialize=function(){a(),t(),i(),r(),o(),n(),s(),l()};var a=function(){e.fn.powermailTabs&&e(".powermail_morestep").each(function(){e(this).powermailTabs()})},t=function(){e("form[data-powermail-ajax]").length&&p()},i=function(){e(".powermail_fieldwrap_location input").length&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(a){var t=a.coords.latitude,i=a.coords.longitude,r=x()+"/index.php?eID=powermailEidGetLocation";jQuery.ajax({url:r,data:"lat="+t+"&lng="+i,cache:!1,beforeSend:function(){e("body").css("cursor","wait")},complete:function(){e("body").css("cursor","default")},success:function(a){a&&e(".powermail_fieldwrap_location input").val(a)}})})},r=function(){e.fn.datetimepicker&&e(".powermail_date").each(function(){var a=e(this);if("date"===a.prop("type")||"datetime-local"===a.prop("type")||"time"===a.prop("type")){if(!a.data("datepicker-force")){if(e(this).data("date-value")){var t=w(e(this).data("date-value"),e(this).data("datepicker-format"),a.prop("type"));null!==t&&e(this).val(t)}return}a.prop("type","text")}var i=!0,r=!0;"date"===a.data("datepicker-settings")?r=!1:"time"===a.data("datepicker-settings")&&(i=!1),a.datetimepicker({format:a.data("datepicker-format"),timepicker:r,datepicker:i,lang:"en",i18n:{en:{months:a.data("datepicker-months").split(","),dayOfWeek:a.data("datepicker-days").split(",")}}})})},o=function(){e(".powermail_all_type_password.powermail_all_value").html("********")},n=function(){e.fn.parsley&&e(".powermail_reset").on("click","",function(){e('form[data-parsley-validate="data-parsley-validate"]').parsley().reset()})},l=function(){window.Parsley&&(_(),g())},p=function(){var a,t=!1;e(document).on("submit","form[data-powermail-ajax]",function(i){var r=e(this);r.data("powermail-ajax-uri")&&(a=r.data("powermail-ajax-uri"));var o=r.data("powermail-form");t||(e.ajax({type:"POST",url:r.prop("action"),data:new FormData(r.get(0)),contentType:!1,processData:!1,beforeSend:function(){e(".powermail_submit",r).parent().append(h()),e(".powermail_confirmation_submit, .powermail_confirmation_form",r).closest(".powermail_confirmation").append(h())},complete:function(){e(".powermail_fieldwrap_submit",r).find(".powermail_progressbar").remove(),s()},success:function(i){var n=e('*[data-powermail-form="'+o+'"]:first',i);n.length?(e('*[data-powermail-form="'+o+'"]:first').closest(".tx-powermail").html(n),e.fn.powermailTabs&&e(".powermail_morestep").powermailTabs(),e.fn.parsley&&e('form[data-parsley-validate="data-parsley-validate"]').parsley(),f()):(a?window.location=a:r.submit(),t=!0)}}),i.preventDefault())})},s=function(){e(".powermail_fieldwrap_file_inner").find(".deleteAllFiles").each(function(){d(e(this).closest(".powermail_fieldwrap_file_inner").find('input[type="file"]'))}),e(".deleteAllFiles").click(function(){c(e(this).closest(".powermail_fieldwrap_file_inner").children('input[type="hidden"]')),e(this).closest("ul").fadeOut(function(){e(this).remove()})})},d=function(e){e.prop("disabled","disabled").addClass("hide").prop("type","hidden")},c=function(e){e.prop("disabled",!1).removeClass("hide").prop("type","file")},f=function(){e("img.powermail_captchaimage").each(function(){var a=u(e(this).prop("src"));e(this).prop("src",a+"?hash="+m(5))})},u=function(e){var a=e.split("?");return a[0]},m=function(e){for(var a="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;e>i;i++)a+=t.charAt(Math.floor(Math.random()*t.length));return a},w=function(e,a,t){var i=Date.parseDate(e,a);if(null===i)return null;var r=new Date(i),o=r.getFullYear()+"-";o+=("0"+(r.getMonth()+1)).slice(-2)+"-",o+=("0"+r.getDate()).slice(-2);var n=("0"+r.getHours()).slice(-2)+":"+("0"+r.getMinutes()).slice(-2),l=o+"T"+n;return"date"===t?o:"datetime-local"===t?l:"time"===t?n:null},h=function(){return e("
").addClass("powermail_progressbar").html(e("
").addClass("powermail_progress").html(e("
").addClass("powermail_progess_inner")))},v=function(e){for(var a=e.get(0),t=0,i=0;it&&(t=r.size)}return parseInt(t)},_=function(){window.Parsley.addValidator("powermailfilesize",function(a,t){if(-1!==t.indexOf(",")){var i=t.split(","),r=parseInt(i[0]),o=e('*[name="tx_powermail_pi1[field]['+i[1]+'][]"]');if(o.length&&v(o)>r)return!1}return!0},32).addMessage("en","powermailfilesize","Error")},g=function(){window.Parsley.addValidator("powermailfileextensions",function(a,t){var i=e('*[name="tx_powermail_pi1[field]['+t+'][]"]');return i.length?y(b(a),i.prop("accept")):!0},32).addMessage("en","powermailfileextensions","Error")},y=function(e,a){return-1!==a.indexOf("."+e)},b=function(e){return e.split(".").pop()},x=function(){var a;return a=e("base").length>0?jQuery("base").prop("href"):"https:"!=window.location.protocol?"http://"+window.location.hostname:"https://"+window.location.hostname}}jQuery(document).ready(function(e){"use strict";var a=new window.PowermailForm(e);a.initialize()});