// CookieJar Version 1.0 - January 22nd 2001 - Mango Wodzak.
// CookieJar Version 1.1 - January 10th 2002 - Added "show" and "rename".
// Action can be "get", "set", "anex", "count", "delete", "show" or "rename".
// need to add, "show all", "delete all".
// - flexibility with expires date, domain name, pathname.
var Action,CookieName,Ingredients,UseBy=new Date();
UseBy.setTime(UseBy.getTime()+(10*365*24*60*60*1000)); // 10 years from now.
function CookieJar(Action,CookieName,Ingredients) {
  if (navigator.cookieEnabled==false) return("locked");
  if (Action!="set") {
    if (Action=="anex"||Action=="rename") var init=Ingredients;
    StartPos=document.cookie.indexOf(CookieName+"=");
	if (StartPos==-1)Ingredients="";
	if (StartPos!=-1) {
	  WorkIt=document.cookie.substring(StartPos,document.cookie.length);
	  StartPos=WorkIt.indexOf("=")+1;
	  EndPos=WorkIt.indexOf(";");
	  if (EndPos==-1) EndPos=WorkIt.length;
	  Ingredients=WorkIt.substring(StartPos,EndPos);
	}
  } 
  if (Action!="get") {
	if (Action=="show") {alert(CookieName+"="+Ingredients); return(Ingredients);}
	if (Action=="rename")CookieName=init;
	if (Action=="anex") Ingredients=Ingredients+"-"+init; // Tag the Ingredients to the end of the cookie.
	if (Action=="count"){Ingredients=escape(Ingredients);Ingredients++;}
	if (Action=="delete")document.cookie=CookieName+"=;path=/;expires=Thu, 01-Jan-70 00:00:01 GMT";
    else document.cookie=CookieName+"="+Ingredients+";expires="+UseBy.toGMTString()+";path=/";
  }
  return(Ingredients);
}