// JavaScript Document
// The oldest Acid code is always used.  New paramters do NOT override old parameters

param_name = "acid";
cookie_name = "acidCode";
expire_days = 90;
var acid = ReadCookie(cookie_name);
var param_value;



function SetCookie(cookieName,cookieValue,nDays) 
{
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";path=/ ;expires="+expire.toGMTString();
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


param_value = gup(param_name);



if (param_value == "")
{  //no URL string set, get ACID from cookie
   // we have cookie already leave it at whatever it is
}
else //Newest ACID Code always overwrites!  if (acid == "")
{   //set acid to our new value and save cookie
	acid = param_value;

	SetCookie(cookie_name, acid, expire_days);

}
