// JavaScript Document

// http://wiki.script.aculo.us/scriptaculous/show/Cookie
// by Carlos Reche

var Cookie = {
  set: function(name, value, params) {
    var ext = '';

	if (typeof(params) == 'object') {
		// expire
		if (typeof(params['daysToExpire']) != 'undefined') {
		  var d = new Date();
		  d.setTime(d.getTime() + (86400000 * parseFloat(params['daysToExpire'])));
		  ext += '; expires=' + d.toGMTString();
		}
	
		// path
		if (typeof(params['path']) != 'undefined') {
			ext += '; path=' + escape(params['path']);
		}
	}
	return (document.cookie = escape(name) + '=' + escape(value || '') + ext);
  },
  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  erase: function(name, params) {
    var cookie = Cookie.get(name) || true;
	if (typeof(params) != 'object') params = new Object();
	params['daysToExpire'] = -1;
    Cookie.set(name, '', params);
    return cookie;
  },
  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookie.set('_test', '1');
    return (Cookie.erase('_test') === '1');
  }
};


