


//Copyright© 2002. gk@techtrade.se, All rights reserved.
//var strThuSep="<%=thousandSeparator%>";
//var strDecSep="<%=decimalCharacter%>";

//var strThuSep=document.body.thousandSeparator;
//var strDecSep=document.body.decimalCharacter;

//var strThuSep=document.body.attributes.getNamedItem("thousandSeparator").value;
//var strDecSep=document.body.attributes.getNamedItem("decimalCharacter").value;

var strThuSep = ' ';
var strDecSep = ',';

//**Start Encode**

//convert from formated numeric string to number
function strToNum(fmtNumStr) {
  var nText=fmtNumStr;
  var i=0;
  var numVal=0;
  var strThuSepDisp = String.fromCharCode(strThuSep.charCodeAt(0) & 127);
  var strDecSepDisp = String.fromCharCode(strDecSep.charCodeAt(0) & 127);
//  return 10;
  var msg="";
    msg = msg + "strToNum: fmtNumStr='" + nText + "'\n";
    msg = msg + "strThuSep.charCodeAt(0)=" + strThuSep.charCodeAt(0) + "\n";
    msg = msg + "strDecSep.charCodeAt(0)=" + strDecSep.charCodeAt(0) + "\n";
    msg = msg + "strThuSepDisp.charCodeAt(0)=" + strThuSepDisp.charCodeAt(0) + "\n";
    msg = msg + "strDecSepDisp.charCodeAt(0)=" + strDecSepDisp.charCodeAt(0) + "\n";
//    alert(msg);
    i=nText.indexOf(strThuSepDisp);
    msg = msg + "nText.indexOf(strThuSepDisp)=" + i + "\n";
//  msg = msg + "nText.charCodeAt(0)=" + nText.charCodeAt(0) + "\n";
//  msg = msg + "nText.charCodeAt(1)=" + nText.charCodeAt(1) + "\n";
//  msg = msg + "nText.charCodeAt(2)=" + nText.charCodeAt(2) + "\n";
    while (i > -1) {
      msg = msg + "removing " + strThuSepDisp + " in " + nText + "  i=" + i + "\n";
      nText = nText.substring(0, i) + nText.substr(i+1);
      i=nText.indexOf(strThuSepDisp, i);
    }
    i=nText.indexOf(strDecSepDisp);
    msg = msg + "nText.indexOf(strDecSepDisp)=" + i + "\n";
    while (i > -1) {
      msg = msg + "replacing " + strDecSepDisp + " in " + nText + "  i=" + i + "\n";
      nText = nText.substring(0, i) + "." + nText.substr(i+1);
      i=nText.indexOf(strDecSepDisp, i+1);
    }
//  alert(msg);
    numVal = parseFloat(nText);
    return(numVal);
}


//convert from number to formated currency string
function numToCur(numVal, zFmt) {
  var nVal=Math.round(100*numVal);
  var nStr=nVal.toString(10);
  var oStr=" ";
    if (typeof(zFmt) != 'undefined' && nVal == 0)
      oStr=zFmt;
//  if (nVal!=0) {
    else {
      oStr = strDecSep + nStr.substr(nStr.length-2, 2);
      var d=nStr.length-3;
      for (var i=d;i>=0;i--) {
        if ((d-i)%3==0 && i!=d)
          oStr = strThuSep + oStr;
        oStr = nStr.substr(i, 1) + oStr;
      }
    }
    return(oStr);
}





