/**
 * Cookie plugin to Prototype.  Simply a helper more than anything.
 */
var Cookie = {
  set: function(name, value, daysToExpire, serverPath) {
    var expire = '';
    var path = '';
    if (daysToExpire != undefined) {
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      expire = '; expires=' + d.toGMTString();
    }
    if(serverPath != undefined) {
    	path = '; path='+serverPath;
    }

    domain = '; domain=infoworld.com;';

    return (document.cookie = escape(name) + '=' + escape(value || '') + expire + path + domain);
  },
  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  erase: function(name,serverPath) {
    var cookie = Cookie.get(name) || true;
    Cookie.set(name, '', -1,serverPath);
    return cookie;
  },
  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookie.set('_test', '1');
    return (Cookie.erase('_test') === '1');
  }
};
