var datamints_feuser_formId=0;
window.onload=function(){if(!(datamints_feuser_config==null||datamints_feuser_inputids==null))for(datamints_feuser_formId in datamints_feuser_inputids)if(typeof datamints_feuser_inputids[datamints_feuser_formId]=="object"){var c=document.getElementById("datamints_feuser_"+datamints_feuser_formId+"_form");addEvent(c,"submit",formCheck);for(var b=0;b<datamints_feuser_inputids[datamints_feuser_formId].length;b++)c=document.getElementById(datamints_feuser_inputids[datamints_feuser_formId][b]),c.type==
"checkbox"?addEvent(c,"click",inputItemCheck):addEvent(c,"change",inputItemCheck)}};
function formCheck(c){var b,a=!1;datamints_feuser_formId=getEventTarget(c).id.split("_")[2];for(fieldId in datamints_feuser_inputids[datamints_feuser_formId])if(typeof datamints_feuser_inputids[datamints_feuser_formId][fieldId]=="string"&&(b=inputItemCheck(null,document.getElementById(datamints_feuser_inputids[datamints_feuser_formId][fieldId])),b==!0&&a==!1))a=!0,window.event?event.returnValue=!1:c.preventDefault()}
function inputItemCheck(c,b){var a=null,d=null,f=d=a=null;c!=null&&(b=getEventTarget(c));var e=b.value.replace(/\s+$/,"").replace(/^\s+/,"");if(b.type=="select-multiple"){d=0;e=[];for(a=0;a<b.options.length;a++)if(b.options[a]!=null&&b.options[a].selected)e[d]=b.options[a].value,d++}if(b.type=="checkbox")if(b.id.lastIndexOf("_item_")>=0){e=!1;a=b.id.slice(0,b.id.lastIndexOf("_item_"));d=document.getElementById(a+"_wrapper").getElementsByTagName("input");for(a=0;a<d.length;a++)d[a]!=null&&d[a].checked&&
(e=!0)}else e=b.checked;if(b.type=="radio"){e=!1;a=b.id.slice(0,b.id.lastIndexOf("_item_"));d=document.getElementById(a+"_wrapper").getElementsByTagName("input");for(a=0;a<d.length;a++)d[a]!=null&&d[a].checked&&(e=!0)}a=b.name.split("[")[2].split("]")[0];a.split("_").reverse()[0]=="rep"&&(a=a.slice(0,a.length-4));removeInfo(a);datamints_feuser_formId=b.id.split("_")[2];if(datamints_feuser_config[datamints_feuser_formId][a]!=null)if(d=datamints_feuser_config[datamints_feuser_formId][a].validation,
datamints_feuser_config[datamints_feuser_formId][a].required&&(!e||typeof e=="object"&&!e.length))return showInfo(a,"required"),!0;else if(d)switch(d.type){case "password":var g=(b.id.split("_").reverse()[0]!="rep"?document.getElementById(b.id+"_rep"):document.getElementById(b.id.slice(0,b.id.length-4))).value;if(e!=""||g!="")if(f=["6"],e==g){if(d.size&&(f=d.size.replace(" ","").split(",")),!e.match(RegExp("^.{"+f[0]+","+(f[1]!=void 0?f[1]:"")+"}$")))return showInfo(a,"size"),!0}else return showInfo(a,
"equal"),!0;break;case "email":if(!e.match(/^[a-zA-Z0-9\._%+-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,6}$/))return showInfo(a,"valid"),!0;break;case "username":if(!e.match(/^[^ ]*$/))return showInfo(a,"valid"),!0;break;case "zero":if(e=="0")return showInfo(a,"valid"),!0;break;case "emptystring":if(e=="")return showInfo(a,"valid"),!0;break;case "custom":if(d.regexp)if(typeof e=="object")for(f in f=0,e){if(!e[f].match(d.regexp))return showInfo(a,"valid"),!0}else if(!e.match(d.regexp))return showInfo(a,"valid"),
!0;if(d.size&&(f=d.size.replace(" ","").split(","),e.length<f[0]||f[1]!=void 0&&e.length>f[1]))return showInfo(a,"size"),!0}return!1}function addEvent(c,b,a){c.addEventListener?c.addEventListener(b,a,!1):c.attachEvent&&(c["e"+b+a]=a,c[b+a]=function(){c["e"+b+a](window.event)},c.attachEvent("on"+b,c[b+a]))}function getEventTarget(c){return c.target?c.target:c.srcElement}
function showInfo(c,b){var a=getErrorItemFather(c);if(a!=void 0){a.lastChild.className=="form_error "+c+"_error"&&a.removeChild(a.lastChild);var d=document.createElement("div");d.className="form_error "+c+"_error";d.innerHTML=datamints_feuser_config[datamints_feuser_formId][c][b];a.appendChild(d)}}function removeInfo(c){var b=getErrorItemFather(c);b!=void 0&&b.lastChild.className=="form_error "+c+"_error"&&b.removeChild(b.lastChild)}
function getErrorItemFather(c){var b=c;datamints_feuser_config[datamints_feuser_formId][c].validation&&datamints_feuser_config[datamints_feuser_formId][c].validation.type=="password"&&(b=c+"_rep");return document.getElementById("datamints_feuser_"+datamints_feuser_formId+"_"+b+"_wrapper")};
