if(typeof (fmutil)=="undefined"){fmutil={}}fmutil.regex={};fmutil.regex.base=function(A,C,B){this.re=A;this.msg=C;this.keys=B};fmutil.regex.email=new fmutil.regex.base(/^([A-Z0-9.'_%+-]+@[A-Z0-9.-]+\.[A-Z]{2,10})?$/i,"Please enter a valid email address");fmutil.regex.email_req=new fmutil.regex.base(/^[A-Z0-9.'_%+-]+@[A-Z0-9.-]+\.[A-Z]{2,10}$/i,"Required. Please enter a valid email address");fmutil.regex.alpha=new fmutil.regex.base(/^[\w &,%$+-.']*$/i,"Only alphanumeric characters and the following characters may be entered: & , _ + - . % $");fmutil.regex.alpha_req=new fmutil.regex.base(/^[\w &,%$+-.']+$/i,"Required. Only alphanumeric characters and the following characters may be entered: & , _ + - . % $");fmutil.regex.phone=new fmutil.regex.base(/^[\d\s\(\)-]*$/,"Only numbers 0-9, spaces, brackets and dashes may be entered.");fmutil.regex.phone_req=new fmutil.regex.base(/^[\d\s\(\)-]+$/,"Required. Only numbers 0-9, spaces, brackets and dashes may be entered.");fmutil.regex.currency=new fmutil.regex.base(/^[+-]?[$]?[0-9]{0,3}(?:,?[0-9]{3})*(?:\.[0-9]{2})?$/,"Enter a number to 2 decimal places.");fmutil.regex.currency_req=new fmutil.regex.base(/^[+-]?[$]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]{2})?$/,"Required. Enter a number to 2 decimal places.");fmutil.regex.password_req=new fmutil.regex.base(/^[\w ,+-.]+$/i,"Required. Only alphanumeric characters and the following characters may be entered: & , _ + - .");fmutil.regex.integer=new fmutil.regex.base(/^[\d]*$/,"Only digits 0-9 may be entered.");fmutil.regex.integer_req=new fmutil.regex.base(/^[\d]+$/,"Required. Only digits 0-9 may be entered.");fmutil.regex.numeric=new fmutil.regex.base(/^[+-]?[\d]*(.[\d]*)?$/,"Only digits 0-9 may be entered.");fmutil.regex.numeric_req=new fmutil.regex.base(/^[+-]?[\d]+(.[\d]*)?$/,"Required. Only digits 0-9 may be entered.");fmutil.regex.check_req=new fmutil.regex.base(/\S/,"Required.");fmutil.regex.select_req=new fmutil.regex.base(/\S/,"Required. Please select a value from the list.");fmutil.regex.date=new fmutil.regex.base(/^((0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.](19|20)\d\d)?$/,"Please enter dates in the format dd/mm/yyyy",/[\d\/]/);fmutil.regex.date_req=new fmutil.regex.base(/^((0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.](19|20)\d\d){1}$/,"Required. Please enter dates in the format dd/mm/yyyy",/[\d\/]/,true);fmutil.regex.base.prototype.checkError=function(A){return(!this.re.test(A))};fmutil.FormOnSubmit=function(I){var E="";var D=false;var B="";var K={};var J={};var F=false;var A=I.getElementsByTagName("input");var G=wsfe.collectionToArray(A);for(i=0;i<G.length;i++){E=G[i].getAttribute("wsregex");if(E&&fmutil.regex[E]){D=fmutil.regex[E];if(G[i].type.search(/^(text|password)$/gi)==0){B=G[i].value;if(D.checkError(B)){fmutil.showError(G[i],D.msg);F=true}else{fmutil.hideError(G[i])}}if(G[i].type.search(/^checkbox$/i)==0){var H=G[i].name;if(!J[H]){J[H]={firstCheck:G[i],validationRule:D,values:[]}}if(G[i].checked){B=G[i].value;J[H].values.push(B);if(D.checkError(B)){fmutil.showError(J[H].firstCheck,D.msg);F=true}else{fmutil.hideError(J[H].firstCheck)}}}if(G[i].type.search(/^radio$/i)==0){var H=G[i].name;if(!K[H]){K[H]={firstRadio:G[i],validationRule:D,value:""}}if(G[i].checked){B=G[i].value;K[H].value=B;if(D.checkError(B)){fmutil.showError(K[H].firstRadio,D.msg);F=true}else{fmutil.hideError(K[H].firstRadio)}}}}}for(var C in J){if(J[C].firstCheck&&J[C].values.length==0){if(J[C].validationRule.checkError("")){fmutil.showError(J[C].firstCheck,J[C].validationRule.msg);F=true}else{fmutil.hideError(J[C].firstCheck)}}}for(var C in K){if(K[C].firstRadio&&!K[C].value){if(K[C].validationRule.checkError("")){fmutil.showError(K[C].firstRadio,K[C].validationRule.msg);F=true}else{fmutil.hideError(K[C].firstRadio)}}}A=I.getElementsByTagName("textarea");G=wsfe.collectionToArray(A);for(i=0;i<G.length;i++){E=(G[i].wsregex)?G[i].wsregex:"";if(E&&fmutil.regex[E]){D=fmutil.regex[E];B=G[i].value;if(D.checkError(B)){fmutil.showError(G[i],D.msg);F=true}else{fmutil.hideError(G[i])}}}A=I.getElementsByTagName("select");G=wsfe.collectionToArray(A);for(i=0;i<G.length;i++){E=G[i].getAttribute("wsregex");if(E&&fmutil.regex[E]){B=G[i].options[G[i].selectedIndex].value;D=fmutil.regex[E];if(D.checkError(B)){fmutil.showError(G[i],D.msg);F=true}else{fmutil.hideError(G[i])}}}return !F};fmutil.showError=function(A,C){if(!A.previousSibling||A.previousSibling.name!="error_msg"){var B=document.createElement("div");B.name="error_msg";B.innerHTML=C;B.className="error_msg";A.parentNode.insertBefore(B,A);A.className+=" validation_failed";A.focus()}};fmutil.hideError=function(A){if(A.previousSibling&&A.previousSibling.name=="error_msg"){A.className=A.className.replace(" validation_failed","");A.parentNode.removeChild(A.previousSibling)}};