Module.createNamespace('com.wjstc.Validation');Module.require('com.wjstc.Util',1.1);com.wjstc.Validation.NAME='com.wjstc.Validation';com.wjstc.Validation.VERSION=1.1;com.wjstc.Validation.g=function(s0){var s=s0+'';if(s==''){return false;}return('0123456789'.indexOf(s.charAt(0)))>=0;};com.wjstc.Validation.j=function(s0,n){var s=s0+'';var len=s.length;var i,k=0;var c=s.charAt(0);if(c=='+'||c=='-')++k;for(i=k;i<len;++i)if(!com.wjstc.Validation.g(s.charAt(i)))return false;if((len-k)>n)return false;return true;};com.wjstc.Validation.B=function(s,n,from,to){var aa=com.wjstc.Util.strToInt(s,n);if((aa-0)<(from-0))return from-0;if((aa-0)>(to-0))return to-0;return aa;};com.wjstc.Validation.cellValueIsValidInt=function(t,f,n,k){var v=f[n].value+'';var da=com.wjstc.Util.strToInt(v,k);var ss;var temp=da.length;ss=(temp>k)?da.substring(temp-k,temp):da;if(f.status.value!=n)if(!com.wjstc.WebTable.refocus(t,f))return false;if(t.forms[f.name].fo!=n)return false;if(com.wjstc.Validation.j(v,k)){f[n].value=da;f.status.value='';com.wjstc.WebTable.saveField(t,f,n);return true;}if(confirm('The integer you entered ('+v+') is invalid.\n\n'+'Would you like to use ('+ss+') instead?\n')){f[n].value=ss;f.status.value='';com.wjstc.WebTable.saveField(t,f,n);return true;}f.status.value=n;return false;};com.wjstc.Validation.cellValueIsRestrictedInt=function(t,f,n,k,min,max,def,onSuccessFn){var fieldChanged=false;var v=f[n].value+'';var da=com.wjstc.Util.strToInt(v,k);var ss;var temp=da.length;ss=(temp>k)?da.substring(temp-k,temp):da;if(f.status.value!=n)if(!com.wjstc.WebTable.refocus(t,f))return false;if(t.forms[f.name].fo!=n)return false;if(com.wjstc.Validation.j(v,k)&&da>=min&&da<=max){f[n].value=da;f.status.value='';fieldChanged=com.wjstc.WebTable.saveField(t,f,n);if(typeof(onSuccessFn)!='undefined'&&fieldChanged){eval(onSuccessFn);}return true;}if(da<min){if(typeof(def)=='undefined'){ss=com.wjstc.Util.formatFloat(min+'',0);}else{ss=com.wjstc.Util.formatFloat(def+'',0);}}if(da>max){if(typeof(def)=='undefined'){ss=com.wjstc.Util.formatFloat(max+'',0);}else{ss=com.wjstc.Util.formatFloat(def+'',0);}}if(confirm('The integer you entered ('+v+') is invalid.\n\n'+'Would you like to use ('+ss+') instead?\n')){f[n].value=ss;f.status.value='';fieldChanged=com.wjstc.WebTable.saveField(t,f,n);if(typeof(onSuccessFn)!='undefined'&&fieldChanged){eval(onSuccessFn);}return true;}f.status.value=n;return false;};com.wjstc.Validation.strToDate=function(inDate,format,mo){var mMap=com.wjstc.Util.getMonthMap(mo);var n=new Date();var d=n.getDate();var m=n.getMonth();var y=n.getFullYear();var fo=com.wjstc.Util.strCompressDateFormat(format);var a={s:inDate};var fr='';var c;for(var i=0;i<fo.length;++i){c=fo.charAt(i);fr=com.wjstc.Util.strSelectFragment(a,7);if(c=='s'){continue;}if(c=='y'){if(fr!=''){y=com.wjstc.Util.strToLimitedInt(fr,4,1,9999);if(y<100){y=(y-0)+2000;}}}else if(c=='d'){if(fr!=''){d=com.wjstc.Util.strToLimitedInt(fr,2,1,31);if(y<100){y=(y-0)+2000;}}}else{if(fr!=''){if(fr.charAt(0)>='0'&&fr.charAt(0)<='9'){m=com.wjstc.Util.strToLimitedInt(fr,2,1,12)-1;}else{m=com.wjstc.Util.getMonthIntFromStr(fr,mMap);}}}}var max=com.wjstc.Util.getDaysInMonth((m-0)+1,y);if((d-0)>max){d=max;}return com.wjstc.DatePicker.dp.formatDate(d,m,y,format);};com.wjstc.Validation.strToRestrictedDate=function(inDate,format,mo,from,to,def){if(typeof(from)=='undefined'){from=new Date('Jan 01, 1971');}if(typeof(to)=='undefined'){to=new Date('Dec 11, 9999');}var mMap=com.wjstc.Util.getMonthMap(mo);var n=new Date();var d=n.getDate();var m=n.getMonth();var y=n.getFullYear();var fo=com.wjstc.Util.strCompressDateFormat(format);var a={s:inDate};var fr='';var c;for(var i=0;i<fo.length;++i){c=fo.charAt(i);fr=com.wjstc.Util.strSelectFragment(a,7);if(c=='s'){continue;}if(c=='y'){if(fr!=''){y=com.wjstc.Util.strToLimitedInt(fr,4,1,9999);if(y<100){y=(y-0)+2000;}}}else if(c=='d'){if(fr!=''){d=com.wjstc.Util.strToLimitedInt(fr,2,1,31);if(y<100){y=(y-0)+2000;}}}else{if(fr!=''){if(fr.charAt(0)>='0'&&fr.charAt(0)<='9'){m=com.wjstc.Util.strToLimitedInt(fr,2,1,12)-1;}else{m=com.wjstc.Util.getMonthIntFromStr(fr,mMap);}}}}var max=com.wjstc.Util.getDaysInMonth((m-0)+1,y);if((d-0)>max){d=max;}var rd=new Date(y,m,d);if(rd<from||rd>to){if(typeof(def)!='undefined'){rd=def;}else if(rd<from){rd=from;}else{rd=to;}d=rd.getDate();m=rd.getMonth();y=rd.getFullYear();}return com.wjstc.DatePicker.dp.formatDate(d,m,y,format);};com.wjstc.Validation.l=function(s0,n,m){var s=s0+'';var len=s.length;var i=0;var it=0;var de=0;var c=s.charAt(0);if(c=='+'||c=='-')++i;for(;i<len;++i){c=s.charAt(i);if(c=='.')break;if(!com.wjstc.Validation.g(c))return false;++it;}for(++i;i<len;++i){if(!com.wjstc.Validation.g(s.charAt(i)))return false;++de;}if(it>n||de>m)return false;return true;};com.wjstc.Validation.C=function(s0,n,m,from,to,def){var s=s0+'';var aa=com.wjstc.Util.strToFloat(s,n,m);if((aa-0)<(from-0)){alert('Value must be must be bigger than or equal to the number '+from);if(typeof(def)=='undefined'){return from;}else{return def;}}if((aa-0)>(to-0)){alert('Value must be must be less than or equal to the number '+to);if(typeof(def)=='undefined'){return to;}else{return def;}}return aa;};com.wjstc.Validation.cellValueIsValidFloat=function(t,f,n,k,m){var v=f[n].value+'';var da=com.wjstc.Util.strToFloat(v,k,m);var temp,ss;temp=da.length;ss=(temp>k)?da.substring(temp-k,temp):da;if(f.status.value!=n)if(!com.wjstc.WebTable.refocus(t,f))return false;if(t.forms[f.name].fo!=n)return false;if(com.wjstc.Validation.l(v,k,m)&&da.length<=k){f[n].value=da;f.status.value='';com.wjstc.WebTable.saveField(t,f,n);return true;}if(confirm('The number you entered ('+v+') is invalid.\n\n'+'Would you like to use ('+ss+') instead?\n')){f[n].value=ss;f.status.value='';com.wjstc.WebTable.saveField(t,f,n);return true;}f.status.value=n;return false;};com.wjstc.Validation.cellValueIsRestrictedFloat=function(t,f,n,k,m,min,max,def,onSuccessFn){var fieldChanged=false;var v=f[n].value+'';var da=com.wjstc.Util.strToFloat(v,k,m);var temp,ss;temp=da.length;ss=(temp>k)?da.substring(temp-k,temp):da;if(f.status.value!=n)if(!com.wjstc.WebTable.refocus(t,f))return false;if(t.forms[f.name].fo!=n)return false;if(com.wjstc.Validation.l(v,k,m)&&(da+'').length<=k&&da>=min&&da<=max){f[n].value=da;f.status.value='';fieldChanged=com.wjstc.WebTable.saveField(t,f,n);if(typeof(onSuccessFn)!='undefined'&&fieldChanged){eval(onSuccessFn);}return true;}if(da<min){if(typeof(def)=='undefined'){ss=com.wjstc.Util.formatFloat(min+'',m);}else{ss=com.wjstc.Util.formatFloat(def+'',m);}}if(da>max){if(typeof(def)=='undefined'){ss=com.wjstc.Util.formatFloat(max+'',m);}else{ss=com.wjstc.Util.formatFloat(def+'',m);}}var cc=confirm('The number you entered ('+v+') is invalid.\n\n'+'Would you like to use ('+ss+') instead?\n');if(cc){f[n].value=ss;f.status.value='';fieldChanged=com.wjstc.WebTable.saveField(t,f,n);if(typeof(onSuccessFn)!='undefined'&&fieldChanged){eval(onSuccessFn);}return true;}f.status.value=n;return false;};com.wjstc.Validation.r=function(s0){var s=s0+'';var len=s.length;var d='';var i,c;for(i=0;i<len;i++){c=s.charAt(i);if(c>='0'&&c<='9')d+=c;}return d;};com.wjstc.Validation.A=function(s0){var s=s0+'';var len=s.length;var d='';var i,c;if(s=='')return s;for(i=0;i<len;i++){c=s.charAt(i);if(c>='0'&&c<='9')d+=c;}if(d.length==10)return '('+d.substr(0,3)+') '+d.substr(3,3)+'-'+d.substr(6);return s;};com.wjstc.Validation.cellValueIsPhone=function(t,f,n,defArea){var v=f[n].value+'';var d=com.wjstc.Validation.r(v);var ss;var dl=d.length;if(f.status.value!=n)if(!com.wjstc.WebTable.refocus(t,f))return false;if(t.forms[f.name].fo!=n)return false;if(dl==10)f[n].value='('+d.substr(0,3)+') '+d.substr(3,3)+'-'+d.substr(6);else if(dl==7){f[n].value='';if(defArea.length==3)f[n].value='('+defArea+') ';f[n].value+=d.substr(0,3)+'-'+d.substr(3);}f.status.value='';com.wjstc.WebTable.saveField(t,f,n);return true;};com.wjstc.Validation.keyValidateHexColor=function(event,o){var v=o.value=o.value.toLowerCase();var c=com.wjstc.Util.getKeyValue(event);var e=event||window.event;if((c==46)||(c==37)||(c==39)||(c<32)){return true;}if(((c>=48)&&(c<=57))||((c>=65)&&(c<=70))){if(e.shiftKey){if((c==51)){if(v==''){return true;}else{o.value+=String.fromCharCode(c);return false;}}else{if(v==''){o.value='#';}o.value+=String.fromCharCode(c).toLowerCase();return false;}}else{if(v==''){o.value='#';}return true;}}return false;};com.wjstc.Validation.toValidHexColor=function(s){var i,c;var sl=s.length;var v='';s=s.toLowerCase();for(i=0;i<sl;++i){c=s.charAt(i);if('0123456789abcdef'.indexOf(c)>=0){v+=c;}}sl=v.length;if(sl>6){s=s.slice(0,6);}else{for(i=v.length;i<6;++i){v+='0';}}return '#'+v;};com.wjstc.Validation.keyValidateFloat=function(event,o,n,m,d){var c=com.wjstc.Util.getKeyValue(event);var e=event||window.event;if((c==46)||(c==37)||(c==39)||(c<32)){return true;}var v=o.value+'';if(v.length>=n){o.value=v.slice(0,n);return false;}if((c>=48)&&(c<=57)){if(e.shiftKey){return false;}return true;}if(m){if(c==109&& !e.shiftKey){if(v.indexOf('-')<0&&v.indexOf('+')<0){o.value='-'+v;}return false;}if(c==61&&e.shiftKey){if(v.indexOf('-')<0&&v.indexOf('+')<0){o.value='+'+v;}return false;}if(c==190&& !e.shiftKey){if(v.indexOf('.')<0){return true;}return false;}return false;}if(d>0){if(c==190&& !e.shiftKey){if(v.indexOf('.')<0){return true;}return false;}return false;}return false;}