// Lightbox Javascript functions// These routines make use of the jsCookies library, which must be included// Note that we will not specify the domain (the current domain, which is the default) is what we want,// and the path will default to "/" making the cookie available anywhere within this domain.// Change the days variable to alter the expiry of lightbox cookiesvar days = 60;var today = new Date();// Calculate new date using milliseconds...var dateExpire = new Date(today.getTime() + days*24*60*60*1000);// [lightboxname] - the lightbox to work with ("MyLightbox")// [value] - the item data to add to the lightboxfunction addToLightbox(lightboxname, value) {     sExisting = getCookie(lightboxname);	if (sExisting == null) {		// always append "&" to values as the delimiter		setCookie(lightboxname, value + "&", dateExpire, "/");		return true;	} else {		if (sExisting.indexOf(value + "&")==-1) {			// the value isn't already there, so add it to the existing			setCookie(lightboxname, sExisting + value + "&", dateExpire, "/");			return true;		} else {			return false;		}	}}function removeFromLightbox(lightboxname, value) {	if ((sExisting = getCookie(lightboxname)) == null) {		// Possibly report the error?	} else {		if ((iStart = sExisting.indexOf(value + "&"))==-1) {			// again, nothing to do?		} else {			sNewcookieVal = sExisting.substring(0, iStart) + sExisting.substring(iStart + value.length + 1, sExisting.length);			setCookie(lightboxname, sNewcookieVal, dateExpire, "/")		}	}}//count the number of values in the cookiefunction countValues(lightboxname) {	sExisting = getCookie(lightboxname);	if (sExisting  == null)	{		return 0;	}	var sValues = sExisting.split("&");	//we always append an "&" so the split will have one more item than we have in the list...	return sValues.length-1;}//return the first matching item in the cookie that starts with the specified string valuefunction getPartMatch(lightboxname, startsWith) {	sExisting = getCookie(lightboxname)	if (sExisting == null)	{		return "";	}	var sValues = sExisting.split("&");	for (i=0; i<sValues.length; i++)	{		if (sValues[i].indexOf(startsWith)==0)		{			return sValues[i];		}	}	return "";}function removeAllLightboxCookies() {	deleteCookie("MyLightbox");}
