/*--------------------------------------------------------------------------------------------
YACS (Yet Another Cookie Script) version 1.0  -  by MD April 2001 
Use, distribution and modification allowed under the terms of the GNU General Public Licence
Most recent version: http://www.welkweb.com/scripts/js/yacs
--------------------------------------------------------------------------------------------*/
obj='';
adder=0;
defaults="";
dateObj=new Date();
milsec=dateObj.getTime();
expiringDate=dateObj.toUTCString();
days=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
months=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
function Cookie(name)
{
	this.name=name;
	this.value="";
	this.domain="";
	this.path="/";
	this.expire="";
	this.exst=0;
	this.values=new Array();
	this.defaults="";
	this.cookieDate="";
	this.script="";
	this.countHours="";
	this.set=set;
	this.get=get;
	this.del=del;
	this.parseValue=parseValue;
	this.exist=exist;
	this.get()
}
function set()
{
	LABEL_1:
	for(_t_=0; _t_<arguments.length; _t_++)
	{
		splitArgs=arguments[_t_].split('=');
		argu=splitArgs[1];
		if(splitArgs[0]=='value')
		{
			this.parseValue(argu,1)
		}
		if(splitArgs[0]=='expire')
		{
			argu=castType(argu);
			adder=0;
			parts=argu.split('+');
			for (var tt in parts)
			{
				adder+=(parts[tt].indexOf('Y')!=-1 ? (parts[tt].substr(0,parts[tt].length-1)*3600*24*365*1000) : 0);
				adder+=(parts[tt].indexOf('D')!=-1 ? (parts[tt].substr(0,parts[tt].length-1)*3600*24*1000) : 0);
				adder+=(parts[tt].indexOf('H')!=-1 ? (parts[tt].substr(0,parts[tt].length-1)*3600*1000) : 0);
				adder+=(parts[tt].indexOf('M')!=-1 ? (parts[tt].substr(0,parts[tt].length-1)*60*1000) : 0);
				adder+=(parts[tt].indexOf('S')!=-1 ? (parts[tt].substr(0,parts[tt].length-1)*1000) : 0);
			}
			thisDateObj=new Date(milsec+adder);
			this.expire=thisDateObj.toUTCString();
		}
		if(splitArgs[0]=='path')
		{
			argu=castType(argu);
			this.path=argu;
		}
		if(splitArgs[0]=='domain')
		{
			argu=castType(argu);
			this.domain=argu;
		}
		if(splitArgs[0]=='defaults')
		{
			argu=castType(argu);
		}
	}
	testOn=location.href;
	scrName=testOn.split('/');
	scrName=scrName[scrName.length-1];
	this.defaults=scrName+"#"+milsec;
	this.value+="***";
	this.value+=""+this.expire;
	this.value+="$"+this.domain;

	this.value+="$"+this.path;
	this.value+="$"+this.defaults;
	uit=this.name+"="+escape(this.value)+";";
	uit+=(this.expire ? "expires="+this.expire+";" : "");
	uit+=(this.path ? "path="+this.path+";" : "/");
	uit+=(this.domain ? "domain="+this.domain+";" : "");
	document.cookie=uit;
}
function get()
{
	naam=this.name;
	allCo=document.cookie;
	arrAllCo=allCo.split(";");
	for(var t in arrAllCo)
	{
		naVa=arrAllCo[t].split('=');
		if(naVa[0]==naam)
		{
			naVa[1]=unescape(naVa[1]);
			this.value=unescape(naVa[1]);
			this.exst=1;
			hulp=this.value.split("***");
			naVa[1]=hulp[0];
			YACSwaarden=hulp[1];
			yw=YACSwaarden.split("$");
			if(yw[0])
			{
				thisDateObj=new Date(yw[0]);
				this.expire=thisDateObj.toUTCString()
			};
			if(yw[1])
			{
				this.domain=yw[1]
			};
			if(yw[2])
			{
				this.path=yw[2]
			};
			if(yw[3])
			{
				defaults=yw[3]
			};
			defaults=defaults.split('#');
			this.cookieDate=new Date(parseFloat(defaults[1]));
			this.scriptName=defaults[0];
			this.sinceLast=parseFloat(milsec-defaults[1]);
			currentDate=days[dateObj.getDay()]+" "+months[dateObj.getMonth()]+" "+dateObj.getDate()+" "+(document.layers?dateObj.getYear()+1900:dateObj.getYear());
			currentTime=expiringDate.split(' ');
			currentTime=currentTime[4];
			this.parseValue(naVa[1]);
			return 1;
		}
	}
	return 0;
};
function castType(z)
{
	z=z;
	if((z.substr(0,1)=="'" || z.substr(0,1)=='"')&& (z.substr(z.length-1)=='"' || z.substr(z.length-1)=="'"))
	{
		returner = z.substr(1,z.length-2);
		return returner;
	}
	else
	{
		if(z.substr(0,1)=="/")
		{
			returner = z.substr(1,z.length-1);
			return returner;
		}
		else
		{
			return (eval(z));
		}
	}
};
function parseValue(theValue,ob)
{
	multiVal=theValue.split(',');
	for(var t in multiVal)
	{
		splitMulti=multiVal[t].split('->');
		if(splitMulti.length>1)
		{
			if(ob==1)
			{
				splitMulti[1]=castType(splitMulti[1]);
			};
			if(parseInt(splitMulti[1])==splitMulti[1])
			{
				splitMulti[1]=parseInt(splitMulti[1])
			}
			this.values[splitMulti[0]]=splitMulti[1];
		}
		else
		{
			if(ob==1)
			{
				theValue=castType(theValue)
			};
			this.values=new Array();
			this.value=theValue;
			return;
		}
	}
	this.value="";
	obj=this.values;
	for (var i in obj)
	{
		if(this.values[i]!="undef" && this.values[i]!="UNDEF")
		{
			this.value+=i+"->"+this.values[i]+",";
		}
	}
	this.value=this.value.substr(0,this.value.length-1);
};
function del()
{
	this.set('expire=/undef');
}
function accept()
{
	_acc=new Cookie("_accept_");
	_acc.set("value=/scay");
	_acc.get();
	if(_acc.value=="scay")
	{
		return 1
	}
	else
	{
		return 0
	}
}
function exist()
{
	return this.exst
}

