var defaultProtection = "private"
var defaultVebosity = "full"

function setCookie(name, value, expire) {
 document.cookie = name + "=" + escape(value)
      + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}


function getCookie(Name) {
  var search = Name + "="
  if (document.cookie.length > 0) { // if there are any cookies
    offset = document.cookie.indexOf(search) 
    if (offset != -1) { // if 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))
    } 
  }
}

function showProtected() {
  var v = getCookie("showProtected");
  if( v ) {
    return v == 1;
  }
  return defaultProtection != "public"
}

function showPrivate() {
  var v = getCookie("showPrivate");
  if( v ) {
    return v == 1;
  }
  return defaultProtection == "private"
}

function setShowProtected(what) {
  setCookie("showProtected", what);
}

 
function setShowPrivate(what) {
  setCookie("showPrivate", what);
}

function showFull() {
  var v = getCookie("showFull");
  if( v ) {
    return v == 1;
  }
  return defaultVebosity == "full";
}

function setShowFull(what) {
  setCookie("showFull", what);
}

function insureTOC(fname) {
 loc = location.href;
 i = loc.lastIndexOf("/");
 tochref = loc.substring(0, i) + "/" + fname;

 if( tochref != parent.toc.location ) {
   parent.toc.location.href = tochref;
 }
}


