/*
* # Fomantic UI - 2.8.4
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2014 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(I,$,O,L){"use strict";I.isFunction=I.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},$=void 0!==$&&$.Math==Math?$:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),I.fn.form=function(C){var w,D=I(this),V=D.selector||"",A=(new Date).getTime(),F=[],R=C,S=arguments[1],T="string"==typeof R,j=[].slice.call(arguments,1);return D.each(function(){var n,f,t,e,p,u,m,g,h,r,c,i,a,l,s,v,d=I(this),b=this,y=[],x=!1,o=!1,k=!1,E=["clean","clean"];(v={initialize:function(){v.get.settings(),T?(s===L&&v.instantiate(),v.invoke(R)):(s!==L&&s.invoke("destroy"),v.verbose("Initializing form validation",d,p),v.bindEvents(),v.set.defaults(),p.autoCheckRequired&&v.set.autoCheck(),v.instantiate())},instantiate:function(){v.verbose("Storing instance of module",v),s=v,d.data(a,v)},destroy:function(){v.verbose("Destroying previous module",s),v.removeEvents(),d.removeData(a)},refresh:function(){v.verbose("Refreshing selector cache"),n=d.find(g.field),f=d.find(g.group),t=d.find(g.message),d.find(g.prompt),e=d.find(g.submit),d.find(g.clear),d.find(g.reset)},submit:function(){v.verbose("Submitting form",d),o=!0,d.submit()},attachEvents:function(e,t){t=t||"submit",I(e).on("click"+l,function(e){v[t](),e.preventDefault()})},bindEvents:function(){v.verbose("Attaching form events"),d.on("submit"+l,v.validate.form).on("blur"+l,g.field,v.event.field.blur).on("click"+l,g.submit,v.submit).on("click"+l,g.reset,v.reset).on("click"+l,g.clear,v.clear),p.keyboardShortcuts&&d.on("keydown"+l,g.field,v.event.field.keydown),n.each(function(e,t){var n=I(t),r=n.prop("type"),i=v.get.changeEvent(r,n);n.on(i+l,v.event.field.change)}),p.preventLeaving&&I($).on("beforeunload"+l,v.event.beforeUnload),n.on("change click keyup keydown blur",function(e){I(this).triggerHandler(e.type+".dirty")}),n.on("change.dirty click.dirty keyup.dirty keydown.dirty blur.dirty",v.determine.isDirty),d.on("dirty"+l,function(e){p.onDirty.call()}),d.on("clean"+l,function(e){p.onClean.call()})},clear:function(){n.each(function(e,t){var n=I(t),r=n.parent(),i=n.closest(f),a=i.find(g.prompt),o=n.closest(g.uiCalendar),l=n.data(m.defaultValue)||"",s=r.is(g.uiCheckbox),u=r.is(g.uiDropdown)&&v.can.useElement("dropdown"),c=0")},fields:function(e){var n=I();return I.each(e,function(e,t){n=n.add(v.get.field(t))}),n},validation:function(r){var i,a;return!!u&&(I.each(u,function(e,n){a=n.identifier||e,I.each(v.get.field(a),function(e,t){if(t==r[0])return n.identifier=a,i=n,!1})}),i||!1)},value:function(e){var t=[];return t.push(e),v.get.values.call(b,t)[e]},values:function(e){var t=Array.isArray(e)?v.get.fields(e):n,m={};return t.each(function(e,t){var n=I(t),r=n.closest(g.uiCalendar),i=n.prop("name"),a=n.val(),o=n.is(g.checkbox),l=n.is(g.radio),s=-1!==i.indexOf("[]"),u=0"+t+""}),I(n+="")},prompt:function(e,t){return I("").addClass(t).html(e[0])}},formatter:{date:function(e){return Intl.DateTimeFormat("en-GB").format(e)},datetime:function(e){return Intl.DateTimeFormat("en-GB",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(e)},time:function(e){return Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(e)},month:function(e){return Intl.DateTimeFormat("en-GB",{month:"2-digit",year:"numeric"}).format(e)},year:function(e){return Intl.DateTimeFormat("en-GB",{year:"numeric"}).format(e)}},rules:{empty:function(e){return!(e===L||""===e||Array.isArray(e)&&0===e.length)},checked:function(){return 0=t},length:function(e,t){return e!==L&&e.length>=t},exactLength:function(e,t){return e!==L&&e.length==t},maxLength:function(e,t){return e!==L&&e.length<=t},match:function(e,t,n){var r,i;return 0<(i=n.find('[data-validate="'+t+'"]')).length?r=i.val():0<(i=n.find("#"+t)).length?r=i.val():0<(i=n.find('[name="'+t+'"]')).length?r=i.val():0<(i=n.find('[name="'+t+'[]"]')).length&&(r=i),r!==L&&e.toString()==r.toString()},different:function(e,t,n){var r,i;return 0<(i=n.find('[data-validate="'+t+'"]')).length?r=i.val():0<(i=n.find("#"+t)).length?r=i.val():0<(i=n.find('[name="'+t+'"]')).length?r=i.val():0<(i=n.find('[name="'+t+'[]"]')).length&&(r=i),r!==L&&e.toString()!==r.toString()},creditCard:function(n,e){var t,r,i={visa:{pattern:/^4/,length:[16]},amex:{pattern:/^3[47]/,length:[15]},mastercard:{pattern:/^5[1-5]/,length:[16]},discover:{pattern:/^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,length:[16]},unionPay:{pattern:/^(62|88)/,length:[16,17,18,19]},jcb:{pattern:/^35(2[89]|[3-8][0-9])/,length:[16]},maestro:{pattern:/^(5018|5020|5038|6304|6759|676[1-3])/,length:[12,13,14,15,16,17,18,19]},dinersClub:{pattern:/^(30[0-5]|^36)/,length:[14]},laser:{pattern:/^(6304|670[69]|6771)/,length:[16,17,18,19]},visaElectron:{pattern:/^(4026|417500|4508|4844|491(3|7))/,length:[16]}},a={},o=!1,l="string"==typeof e&&e.split(",");if("string"==typeof n&&0!==n.length){if(n=n.replace(/[\-]/g,""),l&&(I.each(l,function(e,t){(r=i[t])&&(a={length:-1!==I.inArray(n.length,r.length),pattern:-1!==n.search(r.pattern)}).length&&a.pattern&&(o=!0)}),!o))return!1;if((t={number:-1!==I.inArray(n.length,i.unionPay.length),pattern:-1!==n.search(i.unionPay.pattern)}).number&&t.pattern)return!0;for(var s=n.length,u=0,c=[[0,1,2,3,4,5,6,7,8,9],[0,2,4,6,8,1,3,5,7,9]],d=0;s--;)d+=c[u][parseInt(n.charAt(s),10)],u^=1;return d%10==0&&0=t)},exactCount:function(e,t){return 0==t?""===e:1==t?""!==e&&-1===e.search(","):e.split(",").length==t},maxCount:function(e,t){return 0!=t&&(1==t?-1===e.search(","):e.split(",").length<=t)}}}}(jQuery,window,document);