home *** CD-ROM | disk | FTP | other *** search
- /******************************************************
- ** ** These functions read, write and delete cookies
- ** Most functions were ported from http://builder.com
- ** But the dater routine is custom code that builds the
- ** date in a Y2K compliant format that allows you to
- ** do a general number comparison to see if a date is
- ** greater than another or not
- *******************************************************/
- /*
- ** Declare & initialize variables
- */
- //set to expire on December 31, 2001 at 11:59:59
- var _EXPIRATION_ = new Date();
- _EXPIRATION_.setTime(1009871999259);
-
- //get today's date
- var _TODAY_ = new Number(dater())
- //alert ("today:" + _TODAY_);
-
- /*
- ** Get today's date and format it nicely
- */
- function dater()
- {
- //declare variables
- var _TODAY_ = new Date()
- tempday = _TODAY_.getDate()
- tempday1 = new Number(tempday)
- tempmonth = _TODAY_.getMonth()
- tempyear = _TODAY_.getYear()
- tempmonth1 = new Number(tempmonth)
- tempmonth1++
-
- //format day: if less than 10, add a zero in front
- if (tempday1 < 10) day = new String('0' + tempday1)
- else day = new String(tempday1)
-
- //format month: if less than 10, add a zero in front
- if (tempmonth1 < 10) month = new String('0' + tempmonth1)
- else month = new String(tempmonth1)
-
- //format year: add 19 to front of '99
- if (tempyear < 2000) year = new String('19' + tempyear)
- else year = tempyear
-
- //format full date
- date = year + month + day
- //alert ('dater: ' + date)
- return date;
- }
-
- /*
- ** cookie functions
- */
- // Heinle's function for retrieving a cookie.
- function getCookie(name){
- var cname = name + "=";
- var dc = document.cookie;
- if (dc.length > 0) {
- begin = dc.indexOf(cname);
- if (begin != -1) {
- begin += cname.length;
- end = dc.indexOf(";", begin);
- if (end == -1) end = dc.length;
- return unescape(dc.substring(begin, end));
- }
- }
- return null;
- }
-
- // An adaptation of Dorcht's function for setting a cookie.
- function setCookie(name, value, expires, path, domain, secure) {
- document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : "; expires=" + expires.toGMTString()) + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + ((secure == null) ? "" : "; secure");
- }
-
- // An adaptation of Dorcht's function for deleting a cookie.
- function delCookie (name,path,domain) {
- if (getCookie(name)) {
- document.cookie = name + "=" + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
- }
- }
-