function BrowserCookie(sName){
		
	this._$items = {};
	this.name = sName;
	this.domain = "" ;
	this.path = "";
	this.COOKIE_STATIC="; expires=Sunday, 21-Mar-2010 23:59:59 GMT";
	this.COOKIE_DELETE="; expires=Fri, 02-Jan-1970 00:00:00 GMT";	
}

BrowserCookie.prototype.setCookie = function(sVal, sType){
	
	var s = "";

	s += this.name + "=" + sVal + sType;
	if(this.path != "") s += "; path="+ this.path ;
	if(this.domain != "") s += "; domain=." + this.domain ;

	document.cookie = s;
}


BrowserCookie.prototype.load = function(){

	var c = document.cookie;

	if(c != ""){
		var s = c.indexOf(this.name + "=");
		
		if(s != -1){
			s += this.name.length + 1;
			e = c.indexOf(";", s);
			e = (e == -1)? c.length : e;
			val = c.substring(s, e);
			this.deserialize(val);
		}
	}
}


BrowserCookie.prototype.deserialize = function(sData){
		
	// SAMPLE SERIALIZED
	// --- "0:valueOne|1:valueTwo|"
	var a = sData.split("|");
	var i;
	var len = a.length;
	for(i=0;i<len;i++){
		a[i] = a[i].split(":");
	}
	for(i=0;i<len;i++){
		this._$items[a[i][0]] = unescape(a[i][1]);
	}
}
		
		
BrowserCookie.prototype.serialize = function(){
			
	var each;
	var s = "";
	for(each in this._$items){
		if(s != "") s+= "|";
		s += each + ":" + escape(this._$items[each]);
	}

	return s;
}

BrowserCookie.prototype.getItem = function(sID){
			
	return this._$items[sID];
}

		
BrowserCookie.prototype.setItem = function(sID, oItem){
		
	//alert("setItem " + sID + ":" + oItem);
	this._$items[sID] = oItem;
	this.flush();
}
		
		
BrowserCookie.prototype.removeItem = function(sID){
			
	delete(this._$items[sID]);
	this.flush();
}


BrowserCookie.prototype.clear = function(){
		
	this.setCookie("", this.COOKIE_DELETE);
}


BrowserCookie.prototype.flush = function(){

	this.setCookie(this.serialize(), this.COOKIE_STATIC);
}





