function CookieClass(prefix){
	this.prefix = prefix || 'sc_';
	this.ac = {};

	if( document.cookie == '' || document.cookie == null){
		return;
	}
	var rca = document.cookie.split(';');
	for(var i = 0; i < rca.length; i++){
		var regs = rca[i].match(/([^\s]+)=([^\s]+)/);
		this.ac[regs[1]] = regs[2];		
	}
	
	this.set = function(name, value, expire)
	{
		if(this.ac[name]){
			this.remove(name);
		}
		
		name = this.getRawName(name);
		var exp = new Date();
		exp.setTime(exp.getTime() + expire * 1000);
		document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
		this.ac[name] = value;
	};
	
	this.get = function(name)
	{
		name = this.getRawName(name);
		if(this.ac[name] != null && this.ac[name] != 'undefined'){
			var v = unescape(this.ac[name]); 
			v = decodeURIComponent(v);
			return v;
		}
		return null;
	};
	
	this.remove = function(name)
	{
		this.set(name, null, -1);
		this.ac[name] = null;
	};
	
	this.has = function(name)
	{
		name = this.getRawName(name);
		if(this.ac[name] == null || this.ac[name] == undefined){
			return false;
		}
		return true;
	};
	
	this.getRawName = function(name)
	{
		return this.prefix + name;
	};
};
var cookie = new CookieClass();
