(function(n,t){typeof define=="function"&&define.amd?define(t):n.form2js=t()})(this,function(){"use strict";function u(t,i,r,u,e,o){o=o?!0:!1;(typeof r=="undefined"||r==null)&&(r=!0);(typeof i=="undefined"||i==null)&&(i=".");arguments.length<5&&(e=!1);t=typeof t=="string"?document.getElementById(t):t;var s=[],h,c=0;if(t.constructor==Array||typeof NodeList!="undefined"&&t.constructor==NodeList)while(h=t[c++])s=s.concat(n(h,u,e,o));else s=n(t,u,e,o);return f(s,r,i)}function f(n,t,i){for(var w={},l={},e,s,y,a,h,u,c,f,o,r,b,p,v=0;v<n.length;v++)if(a=n[v].value,!t||a!==""&&a!==null){for(b=n[v].name,p=b.split(i),h=[],u=w,c="",e=0;e<p.length;e++)if(r=p[e].split("]["),r.length>1)for(s=0;s<r.length;s++)if(r[s]=s==0?r[s]+"]":s==r.length-1?"["+r[s]:"["+r[s]+"]",o=r[s].match(/([a-z_]+)?\[([a-z_][a-z0-9_]+?)\]/i),o)for(y=1;y<o.length;y++)o[y]&&h.push(o[y]);else h.push(r[s]);else h=h.concat(r);for(e=0;e<h.length;e++)r=h[e],r.indexOf("[]")>-1&&e==h.length-1?(f=r.substr(0,r.indexOf("[")),c+=f,u[f]||(u[f]=[]),u[f].push(a)):r.indexOf("[")>-1?(f=r.substr(0,r.indexOf("[")),o=r.replace(/(^([a-z_]+)?\[)|(\]$)/gi,""),c+="_"+f+"_"+o,l[c]||(l[c]={}),f==""||u[f]||(u[f]=[]),e==h.length-1?f==""?(u.push(a),l[c][o]=u[u.length-1]):(u[f].push(a),l[c][o]=u[f][u[f].length-1]):l[c][o]||(/^[0-9a-z_]+\[?/i.test(h[e+1])?u[f].push({}):u[f].push([]),l[c][o]=u[f][u[f].length-1]),u=l[c][o]):(c+=r,e<h.length-1?(u[r]||(u[r]={}),u=u[r]):u[r]=a)}return w}function n(n,r,u,f){var e=i(n,r,u,f);return e.length>0?e:t(n,r,u,f)}function t(n,t,r,u){for(var e=[],f=n.firstChild;f;)e=e.concat(i(f,t,r,u)),f=f.nextSibling;return e}function i(n,i,u,f){if(n.disabled&&!f)return[];var h,o,s,c=e(n,u);return h=i&&i(n),h&&h.name?s=[h]:c!=""&&n.nodeName.match(/INPUT|TEXTAREA/i)?(o=r(n,f),s=null===o?[]:[{name:c,value:o}]):c!=""&&n.nodeName.match(/SELECT/i)?(o=r(n,f),s=[{name:c.replace(/\[\]$/,""),value:o}]):s=t(n,i,u,f),s}function e(n,t){return n.name&&n.name!=""?n.name:t&&n.id&&n.id!=""?n.id:""}function r(n,t){if(n.disabled&&!t)return null;switch(n.nodeName){case"INPUT":case"TEXTAREA":switch(n.type.toLowerCase()){case"radio":if(n.checked&&n.value==="false")return!1;case"checkbox":if(n.checked&&n.value==="true")return!0;if(!n.checked&&n.value==="true")return!1;if(n.checked)return n.value;break;case"button":case"reset":case"submit":case"image":return"";default:return n.value}break;case"SELECT":return o(n)}return null}function o(n){var f=n.multiple,r=[],i,t,u;if(!f)return n.value;for(i=n.getElementsByTagName("option"),t=0,u=i.length;t<u;t++)i[t].selected&&r.push(i[t].value);return r}return u}),function(n){var f=-1,r=-1,i=function(n){return parseFloat(n)||0},o=function(t){var f=1,e=n(t),u=null,r=[];return e.each(function(){var t=n(this),e=t.offset().top-i(t.css("margin-top")),o=r.length>0?r[r.length-1]:null;o===null?r.push(t):Math.floor(Math.abs(u-e))<=f?r[r.length-1]=o.add(t):r.push(t);u=e}),r},e=function(t){var i={byRow:!0,property:"height",target:null,remove:!1};return typeof t=="object"?n.extend(i,t):(typeof t=="boolean"?i.byRow=t:t==="remove"&&(i.remove=!0),i)},t=n.fn.matchHeight=function(i){var r=e(i),u;return r.remove?(u=this,this.css(r.property,""),n.each(t._groups,function(n,t){t.elements=t.elements.not(u)}),this):this.length<=1&&!r.target?this:(t._groups.push({elements:this,options:r}),t._apply(this,r),this)},u;t._groups=[];t._throttle=80;t._maintainScroll=!1;t._beforeUpdate=null;t._afterUpdate=null;t._apply=function(r,u){var f=e(u),s=n(r),c=[s],l=n(window).scrollTop(),a=n("html").outerHeight(!0),h=s.parents().filter(":hidden");return h.each(function(){var t=n(this);t.data("style-cache",t.attr("style"))}),h.css("display","block"),f.byRow&&!f.target&&(s.each(function(){var t=n(this),i=t.css("display");i!=="inline-block"&&i!=="inline-flex"&&(i="block");t.data("style-cache",t.attr("style"));t.css({display:i,"padding-top":"0","padding-bottom":"0","margin-top":"0","margin-bottom":"0","border-top-width":"0","border-bottom-width":"0",height:"100px"})}),c=o(s),s.each(function(){var t=n(this);t.attr("style",t.data("style-cache")||"")})),n.each(c,function(t,r){var u=n(r),e=0;if(f.target)e=f.target.outerHeight(!1);else{if(f.byRow&&u.length<=1){u.css(f.property,"");return}u.each(function(){var t=n(this),i=t.css("display"),r;i!=="inline-block"&&i!=="inline-flex"&&(i="block");r={display:i};r[f.property]="";t.css(r);t.outerHeight(!1)>e&&(e=t.outerHeight(!1));t.css("display","")})}u.each(function(){var t=n(this),r=0;f.target&&t.is(f.target)||(t.css("box-sizing")!=="border-box"&&(r+=i(t.css("border-top-width"))+i(t.css("border-bottom-width")),r+=i(t.css("padding-top"))+i(t.css("padding-bottom"))),t.css(f.property,e-r+"px"))})}),h.each(function(){var t=n(this);t.attr("style",t.data("style-cache")||null)}),t._maintainScroll&&n(window).scrollTop(l/a*n("html").outerHeight(!0)),this};t._applyDataApi=function(){var t={};n("[data-match-height], [data-mh]").each(function(){var i=n(this),r=i.attr("data-mh")||i.attr("data-match-height");t[r]=r in t?t[r].add(i):i});n.each(t,function(){this.matchHeight(!0)})};u=function(i){t._beforeUpdate&&t._beforeUpdate(i,t._groups);n.each(t._groups,function(){t._apply(this.elements,this.options)});t._afterUpdate&&t._afterUpdate(i,t._groups)};t._update=function(i,e){if(e&&e.type==="resize"){var o=n(window).width();if(o===f)return;f=o}i?r===-1&&(r=setTimeout(function(){u(e);r=-1},t._throttle)):u(e)};n(t._applyDataApi);n(window).bind("load",function(n){t._update(!1,n)});n(window).bind("resize orientationchange",function(n){t._update(!0,n)})}(jQuery)