/* This javascript file contains the functions used by the online calculator Date Developer Remark ---------------------------------------------------------- 2004/04/08 Rain First version */ function checkKeyPressOnlyInteger(){ if (event.keyCode >= 48 && event.keyCode <= 57) return true; else return false; } function checkKeyPressOnlyInteger(e){ var keyCode; (isIE()) ? keyCode = e.keyCode : keyCode = e.which; if ((keyCode >= 48 && keyCode <= 57) || keyCode==8 || keyCode==0) return true; else return false; } function checkKeyPressOnlyDouble(){ if ( ( event.keyCode >= 48 && event.keyCode <= 57 ) || event.keyCode== 46 ) return true; else return false; } function checkKeyPressOnlyDouble(e){ var keyCode; (isIE()) ? keyCode = e.keyCode : keyCode = e.which; if ( ( keyCode >= 48 && keyCode <= 57 ) || keyCode== 46 || keyCode==8 || keyCode==0) return true; else return false; } function round(n,X) { // rounds number to X decimal places, defaults to 2 X = (!X ? 2 : X); if (Number.prototype.toFixed != '') { n = new Number(n); return n.toFixed(X); } return Math.round(n*Math.pow(10,X))/Math.pow(10,X); } function floor(n,X) { // truncate number to X decimal places, defaults to 2 X = (!X ? 2 : X); //if (Number.prototype.toFixed != '') { // n = new Number(n); // return n.toFixed(X); //} return Math.floor(n*Math.pow(10,X))/Math.pow(10,X); } function raiseP(x,y) { total=1; for (j=0; j 1) { return arrNumber.join(''); } else { return arrNumber[0].split('.')[0]; } } } var winRate; function popRateMessageBox(ebwUrl) { sTitle = "Exchange_Rate_Table"; sUrl = ebwUrl; sProps = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=750,height=450,left=" + getXPos(750) + ",top=" + getYPos(450); var isActive = new String( typeof(winRate)); if (isActive!="object" || winRate.closed) { winRate = window.open(sUrl,sTitle,sProps); winRate.window.focus(); } else { winRate.window.location.href = sUrl; winRate.window.focus(); } } //remove the leading zero in the amount input box function removeLeadZero(num, decimalNum, bolLeadingZero, bolParens) /* IN - num: the number to be formatted decimalNum: the number of decimals after the digit bolLeadingZero: true / false to use leading zero bolParens: true / false to use parenthesis for - num RETVAL - formatted number */ { var tmpNum = num; // Return the right number of decimal places tmpNum *= Math.pow(10,decimalNum); tmpNum = Math.floor(tmpNum); tmpNum /= Math.pow(10,decimalNum); var tmpStr = new String(tmpNum); // See if we need to hack off a leading zero or not if (!bolLeadingZero && num < 1 && num > -1 && num !=0) if (num > 0) tmpStr = tmpStr.substring(1,tmpStr.length); else // Take out the minus sign out (start at 2) tmpStr = "-" + tmpStr.substring(2,tmpStr.length); // See if we need to put parenthesis around the number if (bolParens && num < 0) tmpStr = "(" + tmpStr.substring(1,tmpStr.length) + ")"; return tmpStr; } function CurrencyFormatted(amount) { var i = parseFloat(amount); if(isNaN(i)) { i = 0.00; } var minus = ''; if(i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .005) * 100); i = i / 100; s = new String(i); if(s.indexOf('.') < 0) { s += '.00'; } if(s.indexOf('.') == (s.length - 2)) { s += '0'; } s = minus + s; return s; } function appendZero(val) { val = String(val); dec = val.indexOf("."); if (dec > 0) { dollars = val.substring(0,dec); cents = val.substring(dec+1,dec+3); cents = (cents.length < 2) ? cents + "0" : cents; val = dollars + "." + cents; } else { val = val + "." + "00"; } return val; } function formatNumComma(inStr) { var splittedStr = "", convertStr = ""; if (inStr.indexOf(".") == -1) { convertStr = inStr; } else { // split string splittedStr = inStr.split(/\./); convertStr = splittedStr[0]; } // insert commas var threeNoRE = new RegExp('(-?[0-9]+)([0-9]{3})'); while(threeNoRE.test(convertStr)) { convertStr= convertStr.replace(threeNoRE, '$1,$2'); } if (inStr.indexOf(".") != -1) { convertStr = convertStr + "." + splittedStr[1]; } return convertStr; } function displayInteger(n) { return commaSplit(n); } function displayFloat(n) { return commaSplit(appendZero(n)); } function log10(i) { return Math.log( i ) * Math.LOG10E; }