var CookieJar=Class.create();CookieJar.prototype={appendString:"__CJ_",initialize:function(b){this.options={expires:3600,path:"",domain:"",secure:""};Object.extend(this.options,b||{});if(this.options.expires!=""){var a=new Date();a=new Date(a.getTime()+(this.options.expires*1000));this.options.expires="; expires="+a.toGMTString()}if(this.options.path!=""){this.options.path="; path="+escape(this.options.path)}if(this.options.domain!=""){this.options.domain="; domain="+escape(this.options.domain)}if(this.options.secure=="secure"){this.options.secure="; secure"}else{this.options.secure=""}},put:function(a,c){a=this.appendString+a;cookie=this.options;var b=typeof c;switch(b){case"undefined":case"function":case"unknown":return false;case"boolean":case"string":case"number":c=String(c.toString())}var f=a+"="+escape(Object.toJSON(c));try{document.cookie=f+cookie.expires+cookie.path+cookie.domain+cookie.secure}catch(d){return false}return true},remove:function(c){c=this.appendString+c;cookie=this.options;try{var b=new Date();b.setTime(b.getTime()-(3600*1000));var a="; expires="+b.toGMTString();document.cookie=c+"="+a+cookie.path+cookie.domain+cookie.secure}catch(d){return false}return true},get:function(a){a=this.appendString+a;var b=document.cookie.match(a+"=(.*?)(;|$)");if(b){return(unescape(b[1])).evalJSON()}else{return null}},empty:function(){keys=this.getKeys();size=keys.size();for(i=0;i<size;i++){this.remove(keys[i])}},getPack:function(){pack={};keys=this.getKeys();size=keys.size();for(i=0;i<size;i++){pack[keys[i]]=this.get(keys[i])}return pack},getKeys:function(){keys=$A();keyRe=/[^=; ]+(?=\=)/g;str=document.cookie;CJRe=new RegExp("^"+this.appendString);while((match=keyRe.exec(str))!=undefined){if(CJRe.test(match[0].strip())){keys.push(match[0].strip().gsub("^"+this.appendString,""))}}return keys}};
