//-------------------------------------------------------------
//Author : tonton
//Email : tonton@yeah.net
//Date : 2004-07-28
//Warning: free to use for everyone, don't stand on ceremony
//-------------------------------------------------------------
if (typeof __$__js__io__cookie__class__$__ == "undefined"){
var __$__js__io__cookie__class__$__="js.io.Cookie";
function Cookie(Name, Value){
_overload:
this.toString=function(){return this.value;}
this.valueOf=function(){return this.value;}
_pubic:
this.name=Name;
this.value=Value;
}
function Cookies(cookiePath, cookieDomain, cookieSecure){
_private:
var _path;
var _domain;
var _secure;
var _tail;
_overload:
this.toString =function(){return "CookiesClass";};
this.valueOf =function(){return document.cookie;};
_pubic:
this.getPath=function(){return this._path;}
this.getDomain=function(){return this._domain;}
this.getSecure=function(){return this._secure;}
this.items=null;
this.reset=function(Path, Domain, Secure){
if (Path!=null) this._path=Path;
else Path=this._path;
if (Domain!=null) this._domain=Domain;
else Domain=this._Domain;
if (Secure!=null) this._secure=Secure;
else Secure=this._secure;
var s="";
if (Path) s+="path=" + Path + ";";
if (Domain) s+="Domain=" + Domain + ";";
if (Secure) s+="secure;";
this._tail=s;
this.getAll()
}
this.get=function(cookieName){
if (cookieName){
if (this.items.length==0) this.getAll();
for (var i=0; i<this.items.length; i++)
if (this.items[i].name==cookieName)
return this.items[i];
}
}
this.getAll=function(){
var c=document.cookie;
this.items=new Array();
if (c==null) return null;
c=c.split(";");
var j=-1;
for (var i=0; i<c.length; i++){
var t=c[i].indexOf("=");
if (t>-1){
var n=unescape(c[i].substring(0,t));
this.items[++j]=new Cookie(n, unescape(c[i].substring(t+1)));
}
}
return this.items;
};
this.set=function(Name, Value, Expire){
if (!(Name && Value)) return false;
if (!(Expire instanceof Date)){
if (typeof Expire == "number"){
var d=new Date();
d.setTime(d.getTime() + parseInt(Expire) * 1000);
Expire=d;
}else{
Expire=null;
}
}
var s=unescape(Name) + "=" + unescape(Value) + ";";
if (Expire) s+="expires=" + Expire.toGMTString() + ";";
document.cookie=s+this._tail;
return true;
}
this.remove=function(Name){
var d=new Date();
d.setTime(d.getTime() - 1000);
document.cookie=unescape(Name) + "=''; expires=" + d.toGMTString() + ";";
}
_initial:
this.reset(cookiePath, cookieDomain, cookieSecure);
}
} //End of __$__js__io__cookie__class__$__
//Author : tonton
//Email : tonton@yeah.net
//Date : 2004-07-28
//Warning: free to use for everyone, don't stand on ceremony
//-------------------------------------------------------------
if (typeof __$__js__io__cookie__class__$__ == "undefined"){
var __$__js__io__cookie__class__$__="js.io.Cookie";
function Cookie(Name, Value){
_overload:
this.toString=function(){return this.value;}
this.valueOf=function(){return this.value;}
_pubic:
this.name=Name;
this.value=Value;
}
function Cookies(cookiePath, cookieDomain, cookieSecure){
_private:
var _path;
var _domain;
var _secure;
var _tail;
_overload:
this.toString =function(){return "CookiesClass";};
this.valueOf =function(){return document.cookie;};
_pubic:
this.getPath=function(){return this._path;}
this.getDomain=function(){return this._domain;}
this.getSecure=function(){return this._secure;}
this.items=null;
this.reset=function(Path, Domain, Secure){
if (Path!=null) this._path=Path;
else Path=this._path;
if (Domain!=null) this._domain=Domain;
else Domain=this._Domain;
if (Secure!=null) this._secure=Secure;
else Secure=this._secure;
var s="";
if (Path) s+="path=" + Path + ";";
if (Domain) s+="Domain=" + Domain + ";";
if (Secure) s+="secure;";
this._tail=s;
this.getAll()
}
this.get=function(cookieName){
if (cookieName){
if (this.items.length==0) this.getAll();
for (var i=0; i<this.items.length; i++)
if (this.items[i].name==cookieName)
return this.items[i];
}
}
this.getAll=function(){
var c=document.cookie;
this.items=new Array();
if (c==null) return null;
c=c.split(";");
var j=-1;
for (var i=0; i<c.length; i++){
var t=c[i].indexOf("=");
if (t>-1){
var n=unescape(c[i].substring(0,t));
this.items[++j]=new Cookie(n, unescape(c[i].substring(t+1)));
}
}
return this.items;
};
this.set=function(Name, Value, Expire){
if (!(Name && Value)) return false;
if (!(Expire instanceof Date)){
if (typeof Expire == "number"){
var d=new Date();
d.setTime(d.getTime() + parseInt(Expire) * 1000);
Expire=d;
}else{
Expire=null;
}
}
var s=unescape(Name) + "=" + unescape(Value) + ";";
if (Expire) s+="expires=" + Expire.toGMTString() + ";";
document.cookie=s+this._tail;
return true;
}
this.remove=function(Name){
var d=new Date();
d.setTime(d.getTime() - 1000);
document.cookie=unescape(Name) + "=''; expires=" + d.toGMTString() + ";";
}
_initial:
this.reset(cookiePath, cookieDomain, cookieSecure);
}
} //End of __$__js__io__cookie__class__$__