var cKeyValSep="=";var cEntrySep="|";var cShortDateFmt="ShortDateFmt";var cDateSep="DateSep";var cDecimalSep="DecimalSep";var cThousandSep="ThousandSep";var g_FormatConverter=null;function FormatConverter(d,b,c,a){this.ShortDateFmt=d;this.DateSep=b;this.DecimalSep=c;this.ThousandSep=a;this.SaveToStr=FormatConverter_SaveToStr;this.ReadFromStr=FormatConverter_ReadFromStr;this.GetValidFloatFormatMask=function(){return"#"+this.ThousandSep+"##0"+this.DecimalSep+"#"};this.IsNumberFormatOk=function(e){var h=trim(String(e));var g="";g+="(^[-]?[1-9][0-9]{0,}(["+this.DecimalSep+"][0-9]{1,})?$)";g+="|(^[-]?[1-9][0-9]{0,2}(["+this.ThousandSep+"][0-9]{3}){0,}(["+this.DecimalSep+"][0-9]{1,})?$)";g+="|(^[-+]?[0-9]+["+this.DecimalSep+"]?[0-9]*([eE][-+]?[0-9]+)?$)";g+="|((^[-]?[0])(["+this.DecimalSep+"][0-9]{1,})?$)";var f=new RegExp(g,"g");return f.test(h)};this.CheckFloatDecimal=function(f){var e=new Object();e.Value=f;e.Correct=this.IsNumberFormatOk(f);if(e.Correct||(f=="")){return e}var j="";for(var h=0;h<f.length;++h){switch(f.substring(h,h+1)){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":break;default:if(""!=j){return e}j=f.substring(h,h+1);break}}if(""!=j){var g=VsxReplaceAll(f,j,this.DecimalSep);if(this.IsNumberFormatOk(g)){e.Value=g;e.Correct=true;return e}}return e};this.StrToFloat=function(f,g){if("number"==typeof f){return f}var e=this.CheckFloatDecimal(f);if(!e.Correct){return g}f=e.Value;f=VsxReplaceAll(f,this.ThousandSep,"");if(this.DecimalSep!="."){f=String(f).replace(this.DecimalSep,".")}var h=parseFloat(f);if(isNaN(h)){h=("number"==typeof g)?g:0}return h};this.FloatToStr=function(e){if("string"==typeof e){return e}if("undefined"==typeof e){return""}return e.toString().replace(".",this.DecimalSep)};this.StrToInt=function(e,f){if("number"==typeof e){return e}var g=parseInt(e,10);if(isNaN(g)){g=("number"==typeof f)?f:0}return g};this.DecodeShortDate=function(q,g){var f=g.split(this.DateSep);var p=q.split(this.DateSep);if((f.length!=p.length)||(3!=f.length)||(3!=p.length)){assert(false)}var l=0;var r="";var e,n,o,m="";for(var k=0;k<f.length;++k){m=trim(p[k]).toUpperCase();l=0;r=m.charAt(0);for(var h=0;h<m.length;++h){l++;if(r!=m.charAt(h)){assert(false)}if(h!=(m.length-1)){continue}switch(m.charAt(h)){case"M":switch(l){case 1:n=f[k];while(2>n.length){n="0"+n}break;case 2:n=f[k];break;default:assert(false)}break;case"D":switch(l){case 1:o=f[k];while(2>o.length){o="0"+o}break;case 2:o=f[k];break;default:assert(false)}break;case"Y":switch(l){case 2:e="20"+e;break;case 4:e=f[k];break;default:assert(false)}break;default:assert(false)}}}if((""==e)||(""==n)||(""==o)){assert(false)}return e+"-"+n+"-"+o};this.CheckDoubleInput=function(f){var e=this.CheckFloatDecimal(f.value);if(!e.Correct){return false}f.value=e.Value;return true}}function setFormatConverter(d,b,c,a){g_FormatConverter=new FormatConverter(d,b,c,a)}function setFormatConverterFromString(a){g_FormatConverter=new FormatConverter("","","","");g_FormatConverter.ReadFromStr(a)}function FormatConverter_SaveToStr(){var a="";a+=AddEntry(cShortDateFmt,this.ShortDateFmt,a);a+=AddEntry(cDateSep,this.DateSep,a);a+=AddEntry(cDecimalSep,this.DecimalSep,a);a+=AddEntry(cThousandSep,this.ThousandSep,a);return a}function FormatConverter_ReadFromStr(b){var a=b.split(cEntrySep);var d=null;for(var c=0;c<a.length;c++){d=a[c].split(cKeyValSep);switch(d[0]){case cShortDateFmt:this.ShortDateFmt=d[1];break;case cDateSep:this.DateSep=d[1];break;case cDecimalSep:this.DecimalSep=d[1];break;case cThousandSep:this.ThousandSep=d[1];break;default:ASSERT(false)}}}function DecodeShortDate(b,a){return g_FormatConverter.DecodeShortDate(b,a)}function AddEntry(c,a,b){if((""==c)||(""==a)||((cShortDateFmt!=c)&&(cDateSep!=c)&&(cDecimalSep!=c)&&(cThousandSep!=c))){ASSERT(false)}if(""==b){return c+cKeyValSep+a}else{return cEntrySep+c+cKeyValSep+a}};
