var CookieManager = Class.create({

  initialize : function (cookie_scope) {
    if (!cookie_scope)
      cookie_scope = '';
  	this.cookie_scope = cookie_scope;
  },
  		
  set : function(name, value, days) {
  	var full_name = this.cookie_name(name);
	
  	// figure out how long we want to stor the cookie for
  	if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		} else {
			var expires = "";
		}

		document.cookie = full_name+"="+value+expires+"; path=/";
  },
  
  get : function(name) {
		var nameEQ = this.cookie_name(name) + "=";
		var ca = document.cookie.split(';');
		for(var i=0; i < ca.length; i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
		}
		return null;
  },
  
  cookie_name : function(name) {
  	return this.cookie_scope + '_' + name;
  }
	
});
