﻿function Cookie(){var name,value,expires,path="/",domain,secure=false;this.setName=function(sName){name=sName;}
this.getName=function(){return name;}
this.getValue=function(){return unescape((value instanceof Array)?value.join("&"):value);}
this.setValue=function(sValue){value=escape(sValue);}
this.add=function(key,val){if(!(value instanceof Array)){var temp=value;value=[];if(temp){value[value.length]=temp;}}
value[value.length]=key+"="+escape(val);}
this.setExpires=function(date){expires=date;}
this.getExpires=function(){return expires;}
this.setDomain=function(sD){domain=sD;}
this.getDomain=function(){return domain;}
this.setSecure=function(scr){secure=!!scr;}
this.getSecure=function(){return secure;}
this.save=function(){if(name&&value){if(value instanceof Array){value=value.join("&");}
document.cookie=name+'='+escape(value)+
((expires)?';expires='+expires.toGMTString():'')+
((path)?';path='+path:'')+
((domain)?';domain='+domain:'')+
((secure)?';secure':'');}}
this.remove=function(){expires=new Date(new Date().getTime()-1000*60*60*24);this.save();}};Cookie.get=function(name){var start=document.cookie.indexOf(name+"=");var len=start+name.length+1;var cookie=new Cookie();if(!(((!start)&&(name!=document.cookie.substring(0,name.length)))||(start==-1))){var end=document.cookie.indexOf(';',len);if(end==-1)end=document.cookie.length;cookie.setValue(unescape(document.cookie.substring(len,end)));cookie.setName(name);return cookie;}
return null;}
