// FUNCTION getFront - extract front part of mainStr prior to searchStr function getFront(mainStr, searchStr) { foundOffset = mainStr.indexOf(searchStr) if (foundOffset == -1) { return null } return mainStr.substring(0, foundOffset) } // FUNCTION getEnd - extract back end of mainStr after searchStr function getEnd(mainStr, searchStr) { foundOffset = mainStr.indexOf(searchStr) if (foundOffset == -1) { return null } return mainStr.substring(foundOffset+searchStr.length, mainStr.length) } // FUNCTION replaceString - replace all occurrences of searchStr in mainStr with replaceStr function replaceString(mainStr, searchStr, replaceStr) { var front = getFront(mainStr, searchStr) var end = getEnd(mainStr, searchStr) while (front != null && end != null) { mainStr = front + replaceStr + end front = getFront(mainStr, searchStr) end = getEnd(mainStr, searchStr) } return mainStr } // FUNCTION init - page initialization function init() { // Check if errors have occured when opening the form if ( ErrorMsg != "" ) { alert( "The following errors have occured:\n" + replaceString( ErrorMsg, "|", "\n" ) ) } else if ( UserPWOK == "false" ) { // the user's password has expired, force the user to change it var newURL = "/" + PublicSiteDbPath + "/JSRun?openagent&VAL=javascript:chgPW()"; alert( "Your current password has expired, please change it now." ); top.location.href = newURL } }