
// Shared cookies must be in the same domain AND same directory. 
// This file used to permit home page login shortcut to tracking in a different directory
// Set and get cookie values. How to use setCookie: 
// 		leave expire blank to expire cookie at end of session.
// 		leave value blank to expire cookie now.
var expireLater = new Date("December 31, 2020");
function setCookie(name, value, expire) {
    var cookie = name + "=" + escape(value)  + "; path=/"  + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
    document.cookie = cookie;
    // expires is an optional attribute. If not specified, the cookie will 
    // expire when the user's session ends.
    // path set to / so that it works in all subdirectories.
}

function getCookie(Name) {
    var search = Name + "="
	if (document.cookie.length > 0) {				
	    // if there are any cookies
	offset = document.cookie.indexOf(search) 
	    if (offset != -1) { 							// and named cookie exists 
		offset += search.length					// set index of beginning of value
		end = document.cookie.indexOf(";", offset)	// set index of end of cookie value
		if (end == -1) 
		    end = document.cookie.length
		return unescape(document.cookie.substring(offset, end))
	    } else return null;
	}
}


function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

