main.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. function popup(poppage,popwidth,popheight){
  2. var popwd=window.open(poppage,'erp','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+popwidth+',height='+popheight+'');
  3. popwd.focus()
  4. }
  5. function popupstandard(poppage){
  6. var popwd=window.open(poppage,'erp','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=800,height=600');
  7. popwd.focus()
  8. }
  9. function mOvr(src) {
  10. src.bgColor = "#DEEFFF";
  11. }
  12. function mOut(src, col) {
  13. if (col.indexOf("#") == -1) {
  14. src.bgColor = "#"+col;
  15. } else {
  16. src.bgColor = colr;
  17. }
  18. }
  19. function trim(stringToTrim) {
  20. return stringToTrim.replace(/^\s+|\s+$/g,"");
  21. }
  22. function IsNumeric(ObjVal){
  23. //var NumericRegExp = "^[0-9.]$";
  24. var NumericRegExp = /^(-)?(\d*)(\.?)(\d*)$/
  25. var regex = new RegExp(NumericRegExp);
  26. return regex.test(ObjVal);
  27. }
  28. function formatCurrency(num) {
  29. num = num.toString().replace(/\$|\,/g,'');
  30. if (isNaN(num))
  31. num = "0";
  32. sign = (num == (num = Math.abs(num)));
  33. num = Math.floor(num*100+0.50000000001);
  34. cents = num%100;
  35. num = Math.floor(num/100).toString();
  36. if (cents<10)
  37. cents = "0" + cents;
  38. for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
  39. num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
  40. //return (((sign)?'':'-') + '$' + num + '.' + cents);
  41. return (((sign)?'':'-') + num + '.' + cents);
  42. }
  43. function doDisable(frm, objectType) {
  44. if (frm) {
  45. var el = frm.getElementsByTagName("input");
  46. for (var i=0; i<el.length; i++) {
  47. if (el[i] && el[i].type.toLowerCase() == objectType.toLowerCase()) {
  48. el[i].disabled = true;
  49. }
  50. }
  51. }
  52. }
  53. function doEnable(frm, objectType) {
  54. if (frm) {
  55. var el = frm.getElementsByTagName("input");
  56. for (var i=0; i<el.length; i++) {
  57. if (el[i] && el[i].type.toLowerCase() == objectType.toLowerCase()) {
  58. el[i].disabled = false;
  59. }
  60. }
  61. }
  62. }
  63. function checkLength(field, maxChars) {
  64. if (field) {
  65. if (field.value.length >= maxChars) {
  66. field.value = field.value.substring(0, maxChars);
  67. //event.returnValue = false;
  68. //return false;
  69. }
  70. var label = document.getElementById("_" + field.name);
  71. if (label) {
  72. label.innerHTML = maxChars - field.value.length;
  73. }
  74. }
  75. }
  76. /*
  77. function maxLengthPaste(field, maxChars) {
  78. event.returnValue = false;
  79. if ((field.value.length + window.clipboardData.getData("Text").length) > maxChars) {
  80. return false;
  81. }
  82. event.returnValue=true;
  83. }
  84. */