Names=new Array();av=new Array();cq=new Array();cr=new Array();au="";ag="";function set_variables(name,hc,message,hd){var i=Names.length;Names[i]=name;av[i]=hc;cq[i]=message;cr[i]=hd}function cz(form){for(i=0;i<Names.length;i++){bk=form.elements[Names[i]].type;u=form.elements[Names[i]];aw=cq[i];cv=cr[i];if(bk=="text"||bk=="textarea"||bk=="password"||bk=="file"){if(av[i]=="US Phone")he(u,aw);else if(av[i]=="Phone")hf(u,aw);else if(av[i]=="Email")hg(u,aw);else if(av[i]=="Numeric")isNumeric(u,aw);else if(av[i]=="Credit Card")hh(u,aw);else if(av[i]=="Maximum Length")hi(u,aw,cv);else if(av[i]=="Minimum Length")hj(u,aw,cv);else if(av[i]=="Alpha-Numeric")isAlphaNumeric(u,aw);else if(av[i]=="File Extension")hl(u,aw,cv);else if(av[i]=="Confirm"){cw=eval('form.'+cv);hm(u,cw,aw);}else if(av[i]=="Date")hn(u,aw);else bx(u,aw);}else if(bk=="select-one"||bk=="select-multiple")ho(u,aw);else if(bk=="checkbox"||bk=="radio")hp(u,aw);else if(!bk)hq(u,aw);else{}}return hr();}function hr(){if(au!=""){alert("Please fix the following required fields:\n"+au);au="";if(window.focus){if(ag!=""){hs=ag;ag="";hs.focus();}}return false}return true}function bx(u,ac){if(u.value==""){au+=ac+"\n";if(ag=="")ag=u}}function ho(u,ac){selected=u.selectedIndex;if(u[selected].value==""){au+=ac+"\n";if(ag=="")ag=u}}function hp(u,ac){if(!u.checked)au+=ac+"\n"}function hq(u,ac){var fh=0;for(var i=0;i<u.length;i++){if(u[i].checked)fh=1}if(!fh)au+=ac+"\n"}function hi(u,ac,ht){if(u.value.length>ht){au+=ac+"\n";if(ag=="")ag=u}}function hj(u,ac,hu){if(u.value.length<hu){au+=ac+"\n";if(ag=="")ag=u}}function hh(u,ac){var ej=u.value;if(!(isVisa(ej)||isMasterCard(ej)||isAmericanExpress(ej))){au+=ac+": invalid card number\n";if(ag=="")ag=u}}function isCreditCard(st){if(st.length>19)return(false);sum=0;cx=1;l=st.length;for(i=0;i<l;i++){digit=st.substring(l-i-1,l-i);ek=parseInt(digit,10)*cx;if(ek>=10)sum+=(ek%10)+1;else sum+=ek;if(cx==1)cx++;else cx--}if((sum%10)==0)return(true);else return(false);}function isVisa(aq){aq=stripNotAllowable(aq,"1234567890");if(((aq.length==16)||(aq.length==13))&&(aq.substring(0,1)==4))return(isCreditCard(aq));return false}function isMasterCard(aq){aq=stripNotAllowable(aq,"1234567890");el=aq.substring(0,1);seconddig=aq.substring(1,2);if((aq.length==16)&&(el==5)&&((seconddig>=1)&&(seconddig<=5)))return(isCreditCard(aq));return false}function isAmericanExpress(aq){aq=stripNotAllowable(aq,"1234567890");el=aq.substring(0,1);seconddig=aq.substring(1,2);if((aq.length==15)&&(el==3)&&((seconddig==4)||(seconddig==7)))return(isCreditCard(aq));return false}function stripNotAllowable(s,hv){var returnString="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(hv.indexOf(c)!=-1)returnString+=c}return returnString}function hf(u,ac){bx(u,ac+' cannot be empty');if(u.value.length>0){var bb=0;var str=stripNotAllowable(u.value,"1234567890.()- ");bb=(str.length<u.value.length)?1:0;Phone=stripNotAllowable(u.value,"1234567890");bb=(Phone.length<10||bb)?1:0;if(bb){au+=ac+": wrong format\n";if(ag=="")ag=u}}}function he(u,ac){bx(u,ac+' cannot be empty');if(u.value.length>0){var bb=0;var str=stripNotAllowable(u.value,"1234567890.()- ");bb=(str.length<u.value.length)?1:0;hw=stripNotAllowable(u.value,"1234567890");bb=(hw.length!=10||bb)?1:0;if(bb){au+=ac+": wrong format\n";if(ag=="")ag=u}}}function hg(u,ac){bx(u,ac+' cannot be empty');if(u.value.length>0){var email=u.value;var en=email.length;var bb=false;illegalChars=stripNotAllowable(email,"'\"\\/()`~!#$%^&*+}{|:;?><,[]");hx=stripNotAllowable(email.charAt(0),".@");hy=stripNotAllowable(email.charAt(en-1),".@");if(en<5||email.indexOf('@')==-1||hx!=""||hy!="")bb=true;else{var fi=email.indexOf('@');var fj=email.substring(fi+1,en);var hz=stripNotAllowable(fj,"@");var ja=stripNotAllowable(fj,".");bb=(hz.length>0||ja==0||email.charAt(fi+1)=='.'||illegalChars!='')?true:false}if(bb){au+=ac+": wrong format\n";if(ag=="")ag=u}}}function hm(u,cw,ac){if(u.value!=cw.value){au+=ac+"\n";if(ag=="")ag=cw}}function isNumeric(u,ac){bx(u,ac+' cannot be empty');if(u.value.length>0){if(isNaN(String(u.value).replace(/\D/g,""))){au+=ac+" must be numeric\n";if(ag=="")ag=u}}}function isAlphaNumeric(u,ac){bx(u,ac+' cannot be empty');if(u.value.length>0){Alpha=stripNotAllowable(u.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");Numeric=stripNotAllowable(u.value,"0123456789");if(Alpha.length==0||Numeric.length==0||(Alpha.length+Numeric.length)<u.value.length){au+=ac+" must be alpha-numeric\n";if(ag=="")ag=u}}}function hl(u,ac,eo){bx(u,ac+' cannot be empty');if(u.value.length>0){var cb=new Array();var fk=0;eo=eo.toLowerCase();file=u.value.toLowerCase();jb=file.substring(file.indexOf('.')+1,file.length);by=eo;var commaIndex=by.indexOf(',');while(commaIndex>0){sublist=by.substring(0,commaIndex);cb[cb.length]=sublist;by=by.substring(commaIndex+1,by.length);commaIndex=by.indexOf(',');if(commaIndex<0)cb[cb.length]=by}for(var i=0;i<cb.length;i++){if(cb[i]==jb)fk=1}if(!fk){au+=ac+": wrong file extension\n";if(ag=="")ag=u}}}function hn(u,ac){if(u.value.length>0){var date=Date.parse(u.value);if(isNaN(date)){au+=ac+"\n";if(ag=="")ag=u}}}function fl(u){var i,szNames,szCheckFor,szErrors,szExtraInfo,fm=0;for(i=0;i<Names.length;i++){if(Names[i]==u){Names[i]="";av[i]="";cq[i]="";cr[i]="";break}}fm=(i+1)==Names.length;szNames=String(Names);szCheckFor=String(av);szErrors=String(cq);szExtraInfo=String(cr);if(fm){szNames=szNames.substr(0,szNames.length-1);szCheckFor=szCheckFor.substr(0,szCheckFor.length-1);szErrors=szErrors.substr(0,szErrors.length-1);szExtraInfo=szExtraInfo.substr(0,szExtraInfo.length-1);}Names=szNames.split(",");av=szCheckFor.split(",");cq=szErrors.split(",");cr=szExtraInfo.split(",");}