function trim(inputstringTrim) { fixedTrim = ""; lastCh = " "; for (x = 0; x < inputstringTrim.length; x++) { ch = inputstringTrim.charAt(x); if ((ch != " ") || (lastCh != " ")) { fixedTrim += ch; } lastCh = ch; } if (fixedTrim.charAt(fixedTrim.length - 1) == " ") { fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1); } return fixedTrim; } function replaceSubstring (inputString, badString, goodString, caseSensitive) { fixedReplace = ""; UI = inputString; UB = badString; if ((caseSensitive != 1) && (caseSensitive != true)) { UI = inputString.toUpperCase(); UB = badString.toUpperCase(); } badEnd = -1; badLoc = UI.indexOf(UB); if (badLoc != -1) { for (x=1; (badLoc != -1); x++) { fixedReplace = fixedReplace + inputString.substring((badEnd + 1), badLoc) + goodString badEnd = badLoc + UB.length - 1; badLoc = UI.indexOf(UB, (badLoc + 1)); } fixedReplace = fixedReplace + inputString.substring((badEnd + 1), inputString.length); } else { fixedReplace = inputString; } return fixedReplace; } // instead of inStr, you could always just use the appropriate method in the String class, but this is provided anyway function inStr(beginning, word1, word2) { check1 = new String(word2); returnInStr = word1.indexOf(word2, (beginning - 1)) + 1; return returnInStr; } function mid(inputMid, pos, l) { pos = pos - 1; if ((pos < inputMid.length) && ((pos + l) <= inputMid.length)) { returnMid = inputMid.substring(pos, pos + l); } else { returnMid = ""; } return returnMid; } function checkListFields(frmCurrent, astrKeyword_Fields, astrKeyword_Fields_Desc) { // checks to make sure that any list fields (comboboxes, dialog lists, etc.) don't have the default list value chosen as it's value var strCheckChar = frmCurrent.txtDefaultListValue.value.charAt(0); for (var intIndex = 0; intIndex < astrKeyword_Fields.length; intIndex++) { if (frmCurrent.elements[astrKeyword_Fields[intIndex]].options[frmCurrent.elements[astrKeyword_Fields[intIndex]].selectedIndex].text.charAt(0) == strCheckChar) { frmCurrent.elements[astrKeyword_Fields[intIndex]].focus(); alert("Please choose a valid value for " + astrKeyword_Fields_Desc[intIndex]); return false; } } return true; } function properCase(inputstring) { u = inputstring.toUpperCase(); specialChars = " ~`@#$%^&*()_-+={}[]|\\:;\"'<>,.?/1234567890"; fixedProperCase = ""; twoPast = " "; lastChar = " "; for (place=0; place < inputstring.length; place++) { currchar = u.charAt(place); if (specialChars.indexOf(lastChar) != -1) { if ((lastChar == "\'") && (twoPast != "D")) { currchar = currchar.toLowerCase(); } } else { currchar = currchar.toLowerCase(); } fixedProperCase += currchar; twoPast = lastChar; lastChar = currchar; } fixedProperCase = trim(fixedProperCase); return fixedProperCase; }