/////////////////////////////////// // Start of IsItEmpty() Function // /////////////////////////////////// function IsItEmpty(TestVar) { if(TestVar == "undefined" || TestVar == "null" || TestVar == null || TestVar == "NaN") TestVar = ""; return TestVar; } // End of IsItEmpty() //////////////////////////////////////// // Start of CommonFunction_TestText() // //////////////////////////////////////// function CommonFunction_TestText(strText, length, strType, SpaceOkay) { strText = IsItEmpty(""+strText); length = length - 1 + 1; strType = IsItEmpty(""+strType); SpaceOkay = IsItEmpty(""+SpaceOkay); if(SpaceOkay == "") SpaceOkay = 1; SpaceOkay = (SpaceOkay - 1 + 1); if(!SpaceOkay) strType = "Normal_NoSpace"; if(strType == "Normal_NoSpace") strText = strText.replace(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\[\]\{\}\^\$\.\?\*\+\(\)\-,;:!@#%&=°÷\/<>_'\"\n\r\u2018\u2019\u201C\u201D]/gi,''); else if(strType == "Number" || strType == "Number_Zero") strText = strText.replace(/[^1234567890]/gi,''); else if(strType == "FloatNumber") strText = strText.replace(/[^1234567890\.]/gi,''); else if(strType == "Time") strText = strText.replace(/[^1234567890apmAPM:.\\\/\-]/gi,''); else if(strType == "Number_Decimal") strText = strText.replace(/[^1234567890.]/gi,''); else if(strType == "NumberNegative" || strType == "NumberNegative_Zero") strText = strText.replace(/[^1234567890\-]/gi,''); else if(strType == "PhoneNumber" || strType == "UserName") strText = strText.replace(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890]/gi,''); else if(strType == "ABC123Underscore") strText = strText.replace(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_]/gi,''); else if(strType == "EmailAddress") strText = strText.replace(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\$\.\?\-!@#%&=°÷_]/gi,''); else if(strType == "Code") strText = strText.replace(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\[\]\{\}\^\$\.\?\*\+\(\)\-,;:!@#%&=°÷\/<>_'\"\|\\\n\r ]/gi,""); else if(strType == "NoQuotes") strText = strText.replace(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\[\]\{\}\^\$\.\?\*\+\(\)\-,;:!@#%&=°÷\/<>_\n\r\u2018\u2019\u201C\u201D ]/gi,''); else strText = strText.replace(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\[\]\{\}\^\$\.\?\*\+\(\)\-,;:!@#%&=°÷\/<>_'\"\n\r\u2018\u2019\u201C\u201D ]/gi,''); // strType == "" || strType == "Normal" if(strType == "Password") strText = strText.replace(/[\.\*\'\"]/gi, ''); strText = strText.replace(/^\s+/,''); // removes whitespace from beginning of line strText = strText.replace(/\s+$/,''); // removes whitespace from the end of line strText = strText.replace(/[\n\r]$/gi, ''); // removes extra carriage returns from the end of the line if(length > 0) strText = strText.substr(0,length); if((strType == "Number_Zero" || strType == "NumberNegative_Zero") && strText == "") strText = "0"; if(strType != "Code") { strText = strText.replace(/[\u2018|\u2019]/gi,"'"); // smart single-quotes to neutral single-quotes strText = strText.replace(/[\u201C|\u201D]/gi,"'"); // smart double-quotes to neutral double-quotes } if(strType == "NoDoubleQuotes") strText = strText.replace(/\"/gi, "'"); if(strType == "Time") { strText = strText.toLowerCase(); strText = strText.replace(/[.;\\\/\-]/gi, ':'); if(strText == "1") strText = "1:00am"; if(strText == "2") strText = "2:00am"; if(strText == "3") strText = "3:00am"; if(strText == "4") strText = "4:00am"; if(strText == "5") strText = "5:00am"; if(strText == "6") strText = "6:00am"; if(strText == "7") strText = "7:00am"; if(strText == "8") strText = "8:00am"; if(strText == "9") strText = "9:00am"; if(strText == "10") strText = "10:00am"; if(strText == "11") strText = "11:00am"; if(strText == "12") strText = "12:00pm"; if(strText == "13") strText = "1:00pm"; if(strText == "14") strText = "2:00pm"; if(strText == "15") strText = "3:00pm"; if(strText == "16") strText = "4:00pm"; if(strText == "17") strText = "5:00pm"; if(strText == "18") strText = "6:00pm"; if(strText == "19") strText = "7:00pm"; if(strText == "20") strText = "8:00pm"; if(strText == "21") strText = "9:00pm"; if(strText == "22") strText = "10:00pm"; if(strText == "23") strText = "11:00pm"; if(strText == "24") strText = "12:00pm"; var CommonFunction_TestText_AMPM = "am"; if(strText.indexOf("p") != -1) CommonFunction_TestText_AMPM = "pm"; strText = strText.replace(/[^0123456789:]/gi, ''); var CommonFunction_TestText_Hour = strText; if(CommonFunction_TestText_Hour.indexOf(":") != -1) CommonFunction_TestText_Hour = CommonFunction_TestText_Hour.substr(0, CommonFunction_TestText_Hour.indexOf(":")); var CommonFunction_TestText_Minutes = ""; if(strText.indexOf(":") != -1) CommonFunction_TestText_Minutes = strText.substr(strText.indexOf(":") + 1, strText.length); if(CommonFunction_TestText_Minutes.indexOf(":") != -1) CommonFunction_TestText_Minutes = CommonFunction_TestText_Minutes.substr(0, CommonFunction_TestText_Minutes.indexOf(":")); // This will help avoid a double ':' instance if(CommonFunction_TestText_Hour != "") { if((CommonFunction_TestText_Hour - 1 + 1) > 12) CommonFunction_TestText_Hour = ""; if(CommonFunction_TestText_Minutes != "") { if((CommonFunction_TestText_Minutes - 1 + 1) >= 60) CommonFunction_TestText_Minutes = ""; } if(CommonFunction_TestText_Minutes == "") CommonFunction_TestText_Minutes = "00"; if(""+CommonFunction_TestText_Minutes.length == 1) CommonFunction_TestText_Minutes = "0" + CommonFunction_TestText_Minutes; if(CommonFunction_TestText_Hour != "") strText = CommonFunction_TestText_Hour + ":" + CommonFunction_TestText_Minutes; else strText = ""; } if(strText != "") strText += CommonFunction_TestText_AMPM; } return strText; } // End of CommonFunction_TestText() /////////////////////////// // Start of TrimSpaces() // /////////////////////////// function TrimSpaces(strString, strBegEnd) { var returnString = strString; strBegEnd = IsItEmpty(strBegEnd); if(strBegEnd == "" || strBegEnd == "Beginning") returnString = returnString.replace(/^\s+/,''); // removes whitespace from beginning of line if(strBegEnd == "" || strBegEnd == "Ending") returnString = returnString.replace(/\s+$/,''); // removes whitespace from the end of line return returnString; } // End of TrimSpaces() ///////////////////////////// // Start of CheckForCAPS() // ///////////////////////////// function CheckForCAPS(strText, varType) { // varType 0 = Names // varType 1 = Sentence - currently not used // varType 2 = Important Words Only (example: United States of America) var buildReturn = ""; strText = ""+strText; strText = strText.toLowerCase(); var NextLetterCAP = 1; var CheckForCAPS_LetterCounter = 0; for(iCheckForCAPS=0;iCheckForCAPS<=strText.length;iCheckForCAPS++) { CheckForCAPS_LetterCounter++; if(NextLetterCAP == 1) { if(strText.charAt(iCheckForCAPS) != " ") { buildReturn += (""+strText.charAt(iCheckForCAPS)).toUpperCase(); NextLetterCAP = 0; } else buildReturn += " "; } else if(strText.charAt(iCheckForCAPS) == " " || strText.charAt(iCheckForCAPS) == "-" || strText.charAt(iCheckForCAPS) == ".") { CheckForCAPS_LetterCounter = 0; buildReturn += strText.charAt(iCheckForCAPS); NextLetterCAP = 1; } else buildReturn += strText.charAt(iCheckForCAPS); if(CheckForCAPS_LetterCounter == 2 && buildReturn.charAt(iCheckForCAPS-1) == "M" && buildReturn.charAt(iCheckForCAPS) == "c") NextLetterCAP = 1; if(CheckForCAPS_LetterCounter == 2 && buildReturn.charAt(iCheckForCAPS-1) == "O" && buildReturn.charAt(iCheckForCAPS) == "'") NextLetterCAP = 1; if(CheckForCAPS_LetterCounter == 3 && buildReturn.charAt(iCheckForCAPS-2) == "M" && buildReturn.charAt(iCheckForCAPS-1) == "a" && buildReturn.charAt(iCheckForCAPS) == "c") NextLetterCAP = 1; } if((varType - 1 + 1) == 2) { buildReturn = buildReturn.replace(/ A /gi, " a "); buildReturn = buildReturn.replace(/ An /gi, " an "); buildReturn = buildReturn.replace(/ The /gi, " the "); buildReturn = buildReturn.replace(/ Of /gi, " of "); } return buildReturn; } // End of CheckForCAPS() //////////////////////////////// // Start of CheckMoneyInput() // //////////////////////////////// function CheckMoneyInput(tmpValue) { tmpValue = tmpValue.replace(/[^0-9,.\-]/gi, ''); tmpValue = ""+tmpValue; tmpValue = tmpValue.replace(/,/gi, ''); tmpValue = tmpValue - 1 + 1; tmpValue = tmpValue * 100; if(tmpValue != (tmpValue - 1 + 1)) return "0.00"; tmpValue = tmpValue/100; tmpValue = tmpValue - 1 + 1; tmpValue = Math.abs(Math.round(tmpValue * 100))/100; if(Math.round(tmpValue) == tmpValue) return tmpValue + ".00"; if(Math.round(tmpValue*10) == tmpValue*10) return tmpValue + "0"; return tmpValue; } // End of CheckMoneyInput() /////////////////////////////////////// // Start of HideDisplayPageElement() // /////////////////////////////////////// function HideDisplayPageElement(strElementName, strHideDisplayFunction) { if(strHideDisplayFunction == "") strHideDisplayFunction = "Toggle"; if(strHideDisplayFunction == "Hide") { styleObj = document.getElementById(strElementName).style; styleObj.display='none'; } if(strHideDisplayFunction == "Display") { styleObj = document.getElementById(strElementName).style; styleObj.display=''; } if(strHideDisplayFunction == "Toggle") { styleObj = document.getElementById(strElementName).style; if(styleObj.display == "none") { styleObj = document.getElementById(strElementName).style; styleObj.display=''; } else { styleObj = document.getElementById(strElementName).style; styleObj.display='none'; } } } // End of HideDisplayPageElement() ////////////////////////////// // Start of ReverseString() // ////////////////////////////// function ReverseString(strString) { var returnString = ""; for(ReverseString_i = strString.length; ReverseString_i >= 0; ReverseString_i--) { returnString += strString.charAt(ReverseString_i); } return returnString; } // End of ReverseString() /////////////////////////// // Start of ColorToHex() // /////////////////////////// function ColorToHex(color) { if(color.substr(0,1) == "#") return color; color = color.replace(/[^1234567890\,]/gi, ""); color = ""+color; var ColorToHex_Red = color.substring(0, color.indexOf(",")); color = color.substr(color.indexOf(",") + 1, color.length); var ColorToHex_Green = color.substr(0, color.indexOf(",")); color = color.substr(color.indexOf(",") + 1, color.length); var ColorToHex_Blue = color; var returnColor = (ColorToHex_Red - 1 + 1) + 256 * (ColorToHex_Green - 1 + 1) + 65536 * (ColorToHex_Blue - 1 + 1); var returnColor = (ColorToHex_Red - 1 + 1) * 65536 + (ColorToHex_Green - 1 + 1) * 256 + (ColorToHex_Blue - 1 + 1); returnColor = returnColor.toString(16); returnColor = "#" + returnColor.toUpperCase(); return returnColor; } // End of ColorToHex() /* ////////////////////////////// // Start of Highlight_Row() // ////////////////////////////// function Highlight_Row(strRowName, strHighlightColor, varOverrideChange) { // #F3D9FF = light purple (selected - highlighted) // #E7B1FE = darker purple (selected) // #FDFECB = highlight yellow // #FEB1CC = gray varOverrideChange = varOverrideChange - 1 + 1; styleObj = document.getElementById(strRowName).style; var string_styleObj_backgroundColor = styleObj.backgroundColor.toString(); string_styleObj_backgroundColor = string_styleObj_backgroundColor.toUpperCase(); string_styleObj_backgroundColor = ColorToHex(string_styleObj_backgroundColor); if(varOverrideChange) styleObj.backgroundColor=strHighlightColor; else { if(string_styleObj_backgroundColor == "#AFEFE2" || string_styleObj_backgroundColor == "#8CE8D6" || string_styleObj_backgroundColor == "#FDFECB" || string_styleObj_backgroundColor == "#FFFFFF" || string_styleObj_backgroundColor == "#E1E1E1" || string_styleObj_backgroundColor == "#D7F5FF" || string_styleObj_backgroundColor == "#B7EDFF" || string_styleObj_backgroundColor == "") styleObj.backgroundColor=strHighlightColor; if(string_styleObj_backgroundColor == "#F3D9FF") styleObj.backgroundColor="#E7B1FE"; else if(string_styleObj_backgroundColor == "#E7B1FE") styleObj.backgroundColor="#F3D9FF"; } } // End of Highlight_Row() */