// Original script: Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/
// Improvements: Copyright (c) 2008 Ralph Sickinger, WILLCOR, Inc.

var caution = false
var nodecnt = 0
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "")
  if (!caution || (name + "=" + escape(value)).length <= 4000)
    document.cookie = curCookie
  else
    if (confirm("Cookie exceeds 4KB and will be cut!"))
      document.cookie = curCookie
}
function getCookie(name) {
  var prefix = name + "="
  var cookieStartIndex = document.cookie.indexOf(prefix)
  if (cookieStartIndex == -1)
    return null
  var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
  if (cookieEndIndex == -1)
    cookieEndIndex = document.cookie.length
  return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT"
  }
}
function fixDate(date) {
  var base = new Date(0)
  var skew = base.getTime()
  if (skew > 0)
    date.setTime(date.getTime() - skew)
}
function item(parent, caption, file, id, depth) {
  if (parent) { nodecnt++ }

  this.parent = parent
  this.text = caption
  this.id = id
  this.file = file
  this.depth = depth
}
function makeArray(length) {
  this.length = length
}
function makeDatabase() {
  var ix = 0
  outline = new makeArray(55)

//        outline[0] = new item(false, "<i>Summary</i>","summary","",0)

        outline[ix] = new item(false, "DoDI 5200.40","index","",0)
        ix++
        outline[ix] = new item(false, "1. Purpose","2","",0)
        ix++
        outline[ix] = new item(false, "2. Applicability and Scope","3","",0)
        ix++
        outline[ix] = new item(false, "3. Definitions","4","",0)
        ix++
        outline[ix] = new item(false, "4. Policy","5","",0)
        ix++
        outline[ix] = new item(false, "5. Responsibilities","6","",0)
        ix++
        outline[ix] = new item(false, "6. Procedures","7","",0)
        ix++
        outline[ix] = new item(false, "7. Information Requirements","8","",0)
        ix++
        outline[ix] = new item(false, "8. Effective Date","9","",0)
        ix++
        outline[ix] = new item(false, "Enclosure 1 - References, Continued","a","",0)
        ix++
        outline[ix] = new item(false, "Enclosure 2 - Definitions","b","",0)
        ix++
        outline[ix] = new item(true, "Enlcosure 3 - DITSCAP Description","c","1",0)
        ix++
        outline[ix] = new item(false, "E3.1. DITSCAP Overview","c1","",1)
        ix++
        outline[ix] = new item(false, "E3.2. DITSCAP Phases","c2","",1)
        ix++
        outline[ix] = new item(true, "E3.3. Phase 1, Definition","c3","2",1)
        ix++
        outline[ix] = new item(false, "E3.3.1","c31","",2)
        ix++
        outline[ix] = new item(false, "E3.3.2","c32","",2)
        ix++
        outline[ix] = new item(false, "E3.3.3","c33","",2)
        ix++
        outline[ix] = new item(false, "E3.3.4","c34","",2)
        ix++
        outline[ix] = new item(false, "E3.3.5","c35","",2)
        ix++
        outline[ix] = new item(true, "E3.4. Phase 2, Verification","c4","3",1)
        ix++
        outline[ix] = new item(false, "E3.4.1. Refine the SSAA","c41","",2)
        ix++
        outline[ix] = new item(false, "E3.4.2. System Developement Activity","c42","",2)
        ix++
        outline[ix] = new item(false, "E3.4.3. Certification Analysis","c43","",2)
        ix++
        outline[ix] = new item(false, "E3.4.4. Assess Analysis Results","c44","",2)
        ix++
        outline[ix] = new item(true, "E3.5. Phase 3, Validation","c5","4",1)
        ix++
        outline[ix] = new item(false, "E3.5.1. Refine the SSAA","c51","",2)
        ix++
        outline[ix] = new item(false, "E3.5.2. Certification Evaluation of the Integrated System","c52","",2)
        ix++
        outline[ix] = new item(false, "E3.5.3. Develop Recommendation to the DAA","c53","",2)
        ix++
        outline[ix] = new item(false, "E3.5.4. DAA Accreditation Decision","c54","",2)
        ix++
        outline[ix] = new item(false, "E3.6. Phase 4, Post Accreditation","c6","",1)
        ix++
        outline[ix] = new item(true, "Enclosure 4 - Management Approach","d","5",0)
        ix++
        outline[ix] = new item(false, "E4.1. Management Overview","d1","",1)
        ix++
        outline[ix] = new item(true, "E4.2. DITCSAP Management Roles and Functions","d2","6",1)
        ix++
        outline[ix] = new item(false, "E4.2.1","d21","",2)
        ix++
        outline[ix] = new item(false, "E4.2.2. Program Management Roles","d22","",2)
        ix++
        outline[ix] = new item(false, "E4.2.3. Security Roles and Responsibilities","d23","",2)
        ix++
        outline[ix] = new item(false, "E4.2.4. User Roles and Responsibilities","d24","",2)
        ix++
        outline[ix] = new item(false, "Enclosure 5 - Acronyms and Abbreviations","e","",0)
        ix++
        outline[ix] = new item(false, "Enclosure 6 - SSAA Outline","f","",0)
        ix++
        outline[ix] = new item(true, "Enclosure 7 - ITSEC System Class Description","g","7",0)
        ix++
        outline[ix] = new item(false, "E7.1. Introduction","g1","",1)
        ix++
        outline[ix] = new item(true, "E7.2 ITSEC Classes","g2","8",1)
        ix++
        outline[ix] = new item(false, "E7.2.1","g21","",2)
        ix++
        outline[ix] = new item(false, "E7.2.2","g22","",2)
        ix++
        outline[ix] = new item(false, "E7.2.3","g23","",2)
        ix++
        outline[ix] = new item(false, "E7.2.4","g24","",2)
        ix++
        outline[ix] = new item(false, "E7.2.5","g25","",2)
        ix++
        outline[ix] = new item(false, "E7.2.6","g26","",2)
        ix++
        outline[ix] = new item(false, "E7.2.7","g27","",2)
        ix++
        outline[ix] = new item(false, "E7.2.8","g28","",2)
        ix++
        outline[ix] = new item(false, "E7.2.9","g29","",2)
        ix++
        outline[ix] = new item(false, "E7.3 Security Requirements","g3","",1)
        ix++
        outline[ix] = new item(false, "E7.4 Determination of System Class","g4","",1)
        ix++
        outline[ix] = new item(false, "Enclosure 8 - DITSCAP Components Overview","h","",0)
        ix++

  setStates()
  setImages()
}

function resetStates() {
  setCookie("dodi 5200.40_outline", "-")
}

function setStates() {
  var storedValue = getCookie("dodi 5200.40_outline")
  var parentExpanded = true
  var lastExp = 0
  var text = ""
  var k = 0

  storedValue += "-"
  for (var i = 0; i < outline.length; ++i) {
    if (outline[i].parent) {
      text = "-" + outline[i].id + "-"
      if (storedValue.indexOf(text) != -1)
        outline[i].state = true
      else
        outline[i].state = false
    }
  }

  for (var i = 0; i < outline.length; ++i) {
    if (outline[i].parent) {
      if ((outline[i].depth == 0) || (outline[i].depth <= lastExp) || (parentExpanded)) {
        outline[i].visible = true
        if (outline[i].state)
          lastExp = outline[i].depth + 1
        else
          if (outline[i].depth < lastExp)
            lastExp = outline[i].depth
      } else
        outline[i].visible = false
      parentExpanded = (outline[i].state && outline[i].visible)
    } else {
      if (parentExpanded)
        outline[i].visible = true
      else
        outline[i].visible = false
    }
  }
}
function setImages() {
  for (var i = 0; i < outline.length; ++i) {
    if (outline[i].visible)
      if (outline[i].parent)
        if (((outline[i+1].parent) && (outline[i+1].depth <= outline[i].depth)))
          outline[i].pic = '<IMG SRC="../../minus.gif" BORDER=0>'
        else
          if (outline[i].state)
            outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="../../minus.gif" BORDER=0></A>'
          else
            outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="../../plus.gif" BORDER=0></A>'
      else
        outline[i].pic = '<IMG SRC="../../leaf.gif" BORDER=0>'
  }
}
function toggle(num) {
  outline[num].state = !outline[num].state

  setStorage()
  history.go(0)
}
function setStorage() {
  var text = "-"
  for (var i = 0; i < outline.length; ++i) {
    if ((outline[i].parent) && (outline[i].state)) {
      text += (outline[i].id)
      text += '-'
    }
  }

  setCookie("dodi 5200.40_outline", text)
}
function drawTree(myname) {
  document.write('<table>');
  for (var i = 0; i < outline.length; ++i) {
    if (outline[i].visible) {
      document.write('<tr><td align=right valign=top colspan=',(outline[i].depth + 1),'>')
      document.write(outline[i].pic, ' ')
      document.write('</td><td colspan=',(3-outline[i].depth))
      if (myname == outline[i].file)
        document.write(' class="boldredtxt"><b>', outline[i].text, '</b>')
      else
        document.write('><a href="',outline[i].file,'.html">', outline[i].text, '</a>')
      document.write('</td></tr>')
    } else {
      var previous = i
      for (var k = i + 1; k < outline.length && outline[k].depth >= outline[previous].depth; ++k) {
        ++i
      }
    }
  }
  document.write('<tr>');
  for (var j = 0; j < 12; ++j) { document.write('<td width=12>&nbsp;</td>') }
  document.write('</tr></table>');
}
makeDatabase()


