//=========================================================================== // Module : docroot/scripts // File : nbtools.js // Author : Bilal A. Chouman // Version : // Date : October 16, 2001 // Decription : //=========================================================================== // // // Copyright 2001 Nav Link, Inc. All Rights Reserved. // // This software is the proprietary information of Nav-Link, Inc. // Use is subject to license terms. // // // // This function generates a random number // of minimum sz digits and maximum 2*sz // digits. (16 based) // function fnNBRandomNumber_JS(sz) { var num = new Array(sz); var i; var randomNumber = ""; for (i=0; i= 6) { sub3 = nstr3.substr(0,6); } else { sub3 = nstr3; // // Get a random number. // var digitlen = 6 - len3; // // Size of random seed number. // var sz; if ((digitlen < 3) || (digitlen >= 6)) { sz = 3; } else { sz = digitlen; } xdigits = fnNBRandomNumber_JS(sz); } ID = sub1 + sub2 + sub3 + xdigits; } return ID; } // Build an array initializer function isnArray() { for (var i=0;i12) ? hrs-12 : hrs) + ":"); document.write(""+((min<10) ? "0" : "")+min + ":"); document.write(""+((sec<10) ? "0" : "")+sec); (hrs>=12) ? document.write(" pm") : document.write(" am"); //isn1=setTimeout("isnclock()",1000); } // // This function gets n years back from // the current year in HTML option form for // a select, with the last one being selected. // function fnGetNYears(n) { var thisDay = new Date(); var thisYear; var year; thisDay = new Date(); thisYear = getFullYear(thisDay); for (year = (thisYear - n); year <= thisYear; year++) { // // The first one make it selectable // if (year == (thisYear -n)) { document.write(""); } else { document.write(""); } } } //------------------------------------------------------------------------------------ // // NAME : fnIsValidFloat_JS() // DESC : Given an string representation of a number this function check to see if the // number contains strictly numeric values that represent a float value. // AUTHOR: Bilal A. Chouman // DATE : November 5, 2001 // //------------------------------------------------------------------------------------ function fnIsValidFloat_JS(aFloat) { var valid = false; var abort = false // // Make sure that the given float is not "0", "0.", "0.0", "0.00", ".0". ,".00" // or even "0.000". // Assuming // var amount = parseFloat(aFloat); if ((aFloat != "") && (aFloat != ".") && (amount > 0)) { var i = 0; var pointFound = false; var afterPoint = 0; while ((i < aFloat.length) && (!abort)) { var ch = aFloat.charAt(i); if (ch==" ") { abort = true; } // // Let's ensure that there is only one decimal points // if ((ch == ".") && (!pointFound)) { pointFound = true; i++; } else { if (ch=="0" || ch=="1" || ch=="2" || ch=="3" || ch=="4" || ch=="5" || ch=="6" || ch=="7" || ch=="8" || ch=="9") { // // Now let's ensure that there are only two digit // after the decimal. // if (pointFound) { if (afterPoint < 2) { afterPoint++; } else { abort = true; } } if (!abort) { // // Looks okay, check the next character. // i++; } } else { abort = true; } } } // while // // It's only valid if abort is false and i = the length // of the account number string. // if ((!abort) && (i == aFloat.length)) { valid = true; } } // aFloat != "" return (valid); } //------------------------------------------------------------------------------------ // // NAME : fnIsValidAlphanumeric_JS() // DESC : Given string ensure it's alphanumeric // AUTHOR: Bilal A. Chouman // DATE : May 21, 2001 // //------------------------------------------------------------------------------------ function fnIsValidAlphanumeric_JS(some_text) { var valid = false; var abort = false if (some_text != "") { var i = 0; while ((i < some_text.length) && (!abort)) { var ch = some_text.charAt(i); if (ch==" ") { abort = true; } if (ch=="0" || ch=="1" || ch=="2" || ch=="3" || ch=="4" || ch=="5" || ch=="6" || ch=="7" || ch=="8" || ch=="9" || ch=="a" || ch=="b" || ch=="c" || ch=="d" || ch=="e" || ch=="f" || ch=="g" || ch=="h" || ch=="i" || ch=="j" || ch=="k" || ch=="l" || ch=="m" || ch=="n" || ch=="o" || ch=="p" || ch=="q" || ch=="r" || ch=="s" || ch=="t" || ch=="u" || ch=="v" || ch=="w" || ch=="x" || ch=="y" || ch=="z" || ch=="A" || ch=="B" || ch=="C" || ch=="D" || ch=="E" || ch=="F" || ch=="G" || ch=="H" || ch=="I" || ch=="J" || ch=="K" || ch=="L" || ch=="M" || ch=="N" || ch=="O" || ch=="P" || ch=="Q" || ch=="R" || ch=="S" || ch=="T" || ch=="U" || ch=="V" || ch=="W" || ch=="X" || ch=="Y" || ch=="Z") { // // Looks okay, check the next character. // i++; } else { abort = true; } } // while // // It's only valid if abort is false and i = the length // of the given text string. // if ((!abort) && (i == some_text.length)) { valid = true; } } return (valid); } //------------------------------------------------------------------------------------ // // NAME : fnContains_JS(str,srch) // DESC : Given string (str), this function checks to see if (str) contains // the character (ch). The function returns true if (ch) found, false // otherwise. // AUTHOR: Bilal A. Chouman // DATE : November 7, 2002 // //------------------------------------------------------------------------------------ function fnContains_JS(str, ch) { var found = false; if ((str != null) && (str != "") && (ch != null) && (ch != "")) { var abort = false; var len = str.length; var i = 0; var ch2; while ((!abort) && (i < len)) { ch2 = str.substr(i,1); if (ch2 == ch) { abort = true; found = true; } else { i = i + 1; } } // while } // if return (found); } // // Local Data members // var isn1=null; var isn2=false; today=new Date(); // And months and day arrays var isnMonths=new isnArray("January","February","March","April","May","June","July","August","September","October","November","December"); var isnDays= new isnArray("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"); isnDays[0]="Sunday";