var ACCookie = {};
ACCookie.Local = new Class({
	   options: {
		maxCookiesElement: 5
	},
	initialize: function(maxCookies,options) {
		if(maxCookies)
			this.maxCookiesElement = maxCookies;
		this.setOptions(options);
		this.coockObj = null;
		this.arrayValue = $A($A());
		this.build();
	},
	build: function(){
	if(!this.options.cookieName)
		this.options.cookieName = 'toplist';
	this.coockObj = new Hash.Cookie(this.options.cookieName, this.options.cookieOptions);
	
	},
	save: function(key,value){
		if(key)
		this.set(key,value);
		this.coockObj.save();
	},
	load: function(){
		this.coockObj.load();
	},
	add: function(key,value){
		if(this.coockObj.length == this.maxCookiesElement)
		{
			firstkey = this.coockObj.keys()[0]
			this.coockObj.remove(firstkey);
		}
		this.save(key,value);
	},
	set: function(key,value){
		this.coockObj.set(key,value);
	},
	get: function(key){
		return this.coockObj.get(key);
	},
	erase: function(){
		this.coockObj.empty();
		this.coockObj.save();
	},
	toArray: function(){
		this.coockObj.each( 
						function(value, key){
							var x = [[key, value]];
							this.arrayValue.extend(x);
						},this
		);
		return this.arrayValue.reverse();
	},
	length: function(){return this.coockObj.length;},
	debug: function (){
		this.coockObj.each( 
		function(value, key){alert(key + " = " + value);}
		);
	}
}) // end base
ACCookie.Local.implement(new Options);