//
// A cookie has the following format:
//
//       name=value[;expires="expiration date"][;path="cgi-bin path"][;domain="server name"][;"secure"l]#00
//
// If expiration date is in the future, the cookie will be deleted on that date. If path and domain are given,
// the cookie is also removed from the server as well as the client machine. A null expiration date means this
// cookie expires as soon as the browser closes. A date in the past causes the cookie to be deleted prior to use.
// The path value specifies where the cgi-bin can be found on the server. Multiple cgi-bins may exist on a servers
// if the server supports multiple domains. A null path is equivalent to saying cgi-bin is on the root directory.
// The sever's name is www.something.xxx. For example "www.frostydrew.org".
// IF the final value is "secure" the server must access the cookie via a secure access method like https
// #00 all zero byte noting the end of the string.
//
// For example:
//   "FrostyDrewDivision=observatory/index.htm;expires=Fri, 19-Sep-2008 00:00:01 GMT" where path, domain and secure are null.
//
// Common variables (effectively constants)
//
var FD_div = 'FrostyDrewDivision';
var FD_www = 'www.frostydrew.org/';
var FD_FDO = 'C:/FDO Website/';

// This function extracts the value portion of a cookie. If the cookie does not exist
// or the named value does not exist return a null. The value will be delimited by either
// a semicolon (additional fields exist) or the end of the cookie.
//
function getCookie(name) {
    var cookie, value0, valueN
    cookie = document.cookie.substring(0,511);
    if (cookie == null) return null;
    value0 = cookie.indexOf(name+"=");
    if (value0 == -1) return null;
    value0 = value0 + name.length + 1;
    valueN = cookie.indexOf(";",value0);
    if (valueN == -1) valueN = cookie.length;
    return unescape(cookie.substring(value0,valueN));
}

// This function sets a value into a cookie by name. A cookie with a positive days value will expire
// that many days in the future. A null days value will expire in 24 hours. A negative days value will
// expire as soon as the browser is closed. Path, domain and secure are optional and unused.
//
function setCookie(name,value,days,path,domain,secure) {
    var expires, exp_date
    if (days == null) days = 1 ;
    exp_date = new Date();
    exp_date.setTime(exp_date.getTime()+(days*24*60*60*1000));
    expires = ";expires="+exp_date.toGMTString();
    document.cookie = name+"=" + escape(value) + expires +
        ( (path)   ? ";path="+path     : "") +
        ( (domain) ? ";domain="+domain : "") +
        ( (secure) ? ";secure"         : "") ;
}

// Get the place to go to after we reach root index.htm
function GO_TO_Division(web_fdo) {
  var division
  division=getCookie(FD_div)
  if (division == null) division='hub.htm';
  return web_fdo+division ;
}


