function trimString(s){     // return a string with no spaces     var n = ""     if (s)     {          s = s.toString()          for (var i=0; i<s.length; i++)          {               x = s.substring(i,i+1)               if (x!=" ")               {                    n+=x               }          }     }     return(n)}function formatStringCall(id) {     var s = getInputValue(id)     var m = document.getElementById(id).getAttribute("format")     s = formatString(s,m)     setInputValue(id, s)}function formatString(s,m) {     // format with supplied mask      s=621.5    m=#####.##     ml = m.length                     //ml=8     s = trimString(s.toString())     // look for decimal point in value, if one in mask     dp = s.indexOf(".",0)             //dp = 3     mp = m.indexOf(".",0)             //mp = 5     if (mp > -1) {          if (dp == -1)               s += "."                // add . to mask          dp = s.indexOf(".",0)        //dp = 3          sl = s.length                //sl = 5          scad = (sl-dp)-1             //scad = 1          mcad = (ml-mp)-1             //mcad = 2          var rx = 10          for (var i=1; i<mcad; i++)               rx = rx*10          // round          var sf = parseFloat(s)          sf = Math.round(sf*rx)          sf = sf/rx          s = sf.toString()          dp = s.indexOf(".",0)          if (dp == -1)               s += "."          dp = s.indexOf(".",0)          sl = s.length          scad = (sl-dp)-1          mcad = (ml-mp)-1          // pad with zeroes          for (var i=1; i<mcad-scad+1; i++) {   //i=1, i<2               s += "0"                //s = 621.50          }     }     else {          var sf = parseFloat(s)          sf = Math.round(sf)          s = sf.toString()     }     sl = s.length     ns = new String()     var fc, c, mc     if (ml > sl) {          // pad out string          for (var i=0; i<ml-sl; i++) {               s = " "+s          }          for (var i=0; i<ml; i++) {               c = s.substr(i,1)               if (c == " ") {                    mc = m.substr(i,1)                    switch (mc) {                         case "9":                              fc = "0"                              break                         case "#":                              fc = " "                              break                         default:                              fc = mc                              break                    }                    ns += fc               }               else {                    ns += c               }          }     }     else {          ns = s     }     return(ns)}function isNull(x){     if (trimString(x)=="")     {          return (true)     }     else     {          return (false)     }}function onlyNum(fld){     // input is a string field with possible non-numeric chars     // output is a string with only numeric chars     var s = fld     var r = "1234567890"     var n = ""     if (s!="")     {          for (var i=0; i<s.length; i++)          {               t=s.substring(i,i+1)               if (r.indexOf(t,0)!=-1)               {                    n+=s.substring(i,i+1)               }          }     }     return (n)}function toNumInt(x){     if ((testNumeric(x) == false) || (x == ""))     {          return (parseInt(0))     }     else     {          return (parseInt(parseFloat(x)))  // to catch things like "09"     }}function toNumFloat(x){     if ((testNumeric(x) == false) || (x == ""))     {          return (parseFloat(0))     }     else     {          return (parseFloat(x))     }}function testNumericCall(id) {     var val = document.getElementById(id).value     if (testNumeric(val) == false) {          alert("Invalid Number")          setTimeout("focusElement(document.getElementById('" + id + "'))",0)          return (false)     }     else {          return (true)     }}function testNumeric(num) {     if (isNaN(num))          return (false)     else          return (true)}function testEmail(ea) {     var a = ea.split("@")     if (a.length != 2)  // only one @ allowed          return(false)     if (a[0] == "" || a[1] == "") // something before/after the @          return(false)     var b = a[1].split(".")     if (b.length <= 1) // must have one dot          return(false)     if (b[0] == "" || b[1] == "") // something before/after the .          return(false)}