!function(e,n){"undefined"!=typeof exports&&"undefined"!=typeof module&&module.exports?module.exports=n():"function"==typeof define&&define.amd?define(n):e.form2js=n()}(this,function(){"use strict";function e(e,r,u,i,a,l){l=!!l,void 0!==u&&null!=u||(u=!0),void 0!==r&&null!=r||(r="."),arguments.length<5&&(a=!1);var o,c=[],s=0;if((e="string"==typeof e?document.getElementById(e):e).constructor==Array||"undefined"!=typeof NodeList&&e.constructor==NodeList)for(;o=e[s++];)c=c.concat(t(o,i,a,l));else c=t(e,i,a,l);return n(c,u,r)}function n(e,n,t){var r,u,i,a,l,o,c,s,f,d,h,m,g={},p={};for(r=0;r1)for(i=0;i-1&&u==o.length-1?(s+=f=h.substr(0,h.indexOf("[")),c[f]||(c[f]=[]),c[f].push(l)):h.indexOf("[")>-1?(p[s+="_"+(f=h.substr(0,h.indexOf("[")))+"_"+(d=h.replace(/(^([a-z_]+)?\[)|(\]$)/gi,""))]||(p[s]={}),""==f||c[f]||(c[f]=[]),u==o.length-1?""==f?(c.push(l),p[s][d]=c[c.length-1]):(c[f].push(l),p[s][d]=c[f][c[f].length-1]):p[s][d]||(/^[0-9a-z_]+\[?/i.test(o[u+1])?c[f].push({}):c[f].push([]),p[s][d]=c[f][c[f].length-1]),c=p[s][d]):(s+=h,u0?a:r(e,n,t,i)}function r(e,n,t,r){for(var i=[],a=e.firstChild;a;)i=i.concat(u(a,n,t,r)),a=a.nextSibling;return i}function u(e,n,t,u){if(e.disabled&&!u)return[];var l,o,c,s=i(e,t);return l=n&&n(e),l&&l.name?c=[l]:""!=s&&e.nodeName.match(/INPUT|TEXTAREA/i)?c=null===(o=a(e,u))?[]:[{name:s,value:o}]:""!=s&&e.nodeName.match(/SELECT/i)?(o=a(e,u),c=[{name:s.replace(/\[\]$/,""),value:o}]):c=r(e,n,t,u),c}function i(e,n){return e.name&&""!=e.name?e.name:n&&e.id&&""!=e.id?e.id:""}function a(e,n){if(e.disabled&&!n)return null;switch(e.nodeName){case"INPUT":case"TEXTAREA":switch(e.type.toLowerCase()){case"radio":if(e.checked&&"false"===e.value)return!1;case"checkbox":if(e.checked&&"true"===e.value)return!0;if(!e.checked&&"true"===e.value)return!1;if(e.checked)return e.value;break;case"button":case"reset":case"submit":case"image":return"";default:return e.value}break;case"SELECT":return l(e)}return null}function l(e){var n,t,r,u=[];if(!e.multiple)return e.value;for(t=0,r=(n=e.getElementsByTagName("option")).length;t