function GoTo(docNumber) { var eString = "&EXPAND="; var eLength = eString.length; var cString = "&COLLAPSE="; var cLength = cString.length var baseURL = document.location.href; var baseURLUpperCase = baseURL.toUpperCase(); var eBeg = baseURLUpperCase.indexOf(eString); if (eBeg > 0) { var otherStuff = baseURL.substring(eBeg + eLength, baseURL.length); var otherStuffBeg = otherStuff.indexOf("&"); if (otherStuffBeg >= 0) { eNumber = otherStuff.substring(0, otherStuffBeg); otherStuff = otherStuff.substring(otherStuffBeg, otherStuff.length); } else { eNumber = otherStuff.substring(0, otherStuff.length); otherStuff = ""; } if (eNumber == docNumber) { // need to collapse goWhere = baseURL.substr(0, eBeg) + cString + docNumber + otherStuff; } else { // do not need to colapse goWhere = baseURL.substr(0, eBeg) + eString + docNumber + otherStuff; } } else { // no EXPAND in the string var cBeg = baseURLUpperCase.indexOf(cString); if (cBeg > 0) { var otherStuff = baseURL.substring(cBeg + cLength, baseURL.length) var otherStuffBeg = otherStuff.indexOf("&"); if (otherStuffBeg >= 0) { // other stuff in the string goWhere = baseURL.substr(0, cBeg) + eString + docNumber + otherStuff.substring(otherStuffBeg, otherStuff.length) } else { // nothing else in the string so just expand goWhere = baseURL.substr(0, cBeg) + eString + docNumber; } } else { // no COLLAPSE in the string goWhere = baseURL + eString + docNumber; } } // alert (goWhere); if (document.location.href.indexOf("&REF") == "-1") { goWhere = goWhere + "&REF" } document.location = goWhere; };