/******************************************************** Set of Global JavaScript functions to be used throughout DpiweLib ********************************************************/ /************************************************* Cookie code from Paul Schofield, Cookie Central *************************************************/ // function to return the DECODED value of a cookie // offset - ??? // returns - the decoded value of the cookie ? function getCookieVal(offset) { var endstr = document.cookie.indexOf(";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } // function to return the value of the cookie specified by NAME // name - string object containing the cookie name // returns - string object containing the cookie value, or null if the cookie does not exist function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i=0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal(j); i = document.cookie.indexOf(" ",i) + 1; if (i == 0) break; } return null; } // function to create or update a cookie // name - Required string object containing the cookie name // value - Required string object containing the cookie value. // [expires] - Optional date object containing the expiration data of the cookie. // If omitted or null, expires the cookie at the end of the current session. // [path] - Optional string object indicating the path for which the cookie is valid. // If omitted or null, uses the path of the calling document. // [domain] - Optional string object indicating the domain for which the cookie is valid. // If omitted or null, uses the domain of the calling document. // [secure] - Boolean (true / false) value indicating whether the cookie transmission requires a secure channel (HTTPS) // The parameters must be passed in the order listed above. // To omit an unused optional field, use null as a place holder. // for example, to call setCookie using name, value and path: // setCookie("cookieName", "cookieValue", null, "/"); // trailing omitted parameters do not require a placeholder. // To set a secure cookie for path "/myPath" that expires after the current session, you might code: // setCookie(myCookieVar, cookieValueVar, null, "/myPath", null, true); function setCookie(name, value, expires, path, domain, secure) { // document.cookie = name + "=" + escape(value) + document.cookie = name + "=" + value + ( (expires) ? "; expires=" + expires.toGMTString() : "") + ( (path) ? "; path=" + path : "") + ( (domain) ? ";domain=" + domain : "") + ( (secure) ? "; secure" : ""); } // function to delete a cookie (sets expiration date to start of epoch) // name - string object containing the cookie name // path - string object containing the path of the cookie to delete. // this MUST be the same as the path used to create the cookie, // or null/omitted if no path was specified when creating the cookie // domain - string object containing the domain of the cookie to delete. // this MUST be the same as the domainused to create the cookie, // or null/omitted if no domain was specified when creating the cookie function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain: "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } function getDBPath() { var pathname = window.location.pathname; var iPos = window.location.pathname.toString().toLowerCase().lastIndexOf('.nsf/'); if(iPos>0) return pathname.substring(0, iPos+5); return pathname; } function login() { setCookie('browseLogin', window.location.href, null, "/"); parent.window.location.href = getDBPath() ; } function setElementClassName(elemID, newClass) { document.getElementById(elemID).className = newClass; } function quickSearch() { frm = document.forms[0]; // set cookies for the Refine Search option // if user clicks on the Refine Search button in the Search Results page // the Advanced search form is loaded, with the existing query keywords preloaded // in the corresponding fields setCookie('Query', document.forms[0].newquery.value, null, "/"); setCookie('lookfor', '0', null, "/"); setCookie('lookIn', '0', null, "/"); // cookie value is the selected index of the html select field setCookie('Query2', '', null, "/"); setCookie('lookfor2', '0', null, "/"); setCookie('lookIn2', '0', null, "/"); setCookie('Format', '0', null, "/"); setCookie('Location', '0', null, "/"); setCookie('when', '0', null, "/"); setCookie('PubDate', '', null, "/"); frm.submit(); } function setSearchCookies() { }