home *** CD-ROM | disk | FTP | other *** search
/ JavaScript Source Code 2002 / JavaScript Source Code 2002.iso / calendars / cookie-calendar / cengine.js < prev    next >
Encoding:
JavaScript  |  2001-03-13  |  1.1 KB  |  50 lines

  1. //Get Cookie Function
  2. function getCookie(name) {
  3.     var cname = name + "=";
  4.     var dc = document.cookie;
  5.     
  6.     if (dc.length > 0) {
  7.         begin = dc.indexOf(cname);
  8.         if (begin != -1) {
  9.             begin += cname.length;
  10.             end = dc.indexOf(";", begin);
  11.             if (end == -1) end = dc.length;
  12.                 return unescape(dc.substring(begin, end));
  13.         }
  14.     }
  15.     return null;
  16. }
  17.  
  18. //Set Cookie Function
  19. function setCookie(name, value, expires, path, domain, secure) {
  20.     document.cookie = name + "=" + escape(value) + 
  21.     ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  22.     ((path == null) ? "" : "; path=" + path) +
  23.     ((domain == null) ? "" : "; domain=" + domain) +
  24.     ((secure == null) ? "" : "; secure");
  25. }
  26.  
  27. //Delete Cookie Function
  28. function delCookie (name,path,domain) {
  29.     if (getCookie(name)) {
  30.         document.cookie = name + "=" +
  31.         ((path == null) ? "" : "; path=" + path) +
  32.         ((domain == null) ? "" : "; domain=" + domain) +
  33.         "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  34.     }
  35. }
  36.  
  37. //Get Advertisement from Array Function
  38. function getAdv(name) {
  39.     var adv = "";
  40.     
  41.     for(var i = 0;i < seglist.length ;i+=3) {
  42.         if(name == seglist[i]) {
  43.             adv = seglist[i + 2];
  44.             
  45.             return adv;
  46.         }
  47.     }
  48.     
  49.     return null;
  50. }