// 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(48)

//        outline[0] = new item(false, "<i>Summary</i>","summary","",0)

        outline[ix] = new item(false, "Cover page","index","",0)
        ix++
        outline[ix] = new item(false, "Acknowledgements","2","",0)
        ix++
        outline[ix] = new item(false, "Abstract","3","",0)
        ix++
        outline[ix] = new item(false, "Chapter 1: Introduction","4","",0)
        ix++
        outline[ix] = new item(false, "Chapter 2: Review of Related Literature","5","",0)
        ix++
        outline[ix] = new item(false, "Chapter 3: Methodology","6","",0)
        ix++
        outline[ix] = new item(false, "Chapter 4: Limitations of Study and Assumptions","7","",0)
        ix++
        outline[ix] = new item(true, "Chapter 5: Findings","8","1",0)
        ix++
        outline[ix] = new item(false, "Primary Findings","81","",1)
        ix++
        outline[ix] = new item(true, "General Management Metrics","82","2",1)
        ix++
        outline[ix] = new item(false, "Cost and Schedule Overruns","821","",2)
        ix++
        outline[ix] = new item(false, "EMD Duration","822","",2)
        ix++
        outline[ix] = new item(false, "Success Ratings","823","",2)
        ix++
        outline[ix] = new item(false, "Baselining Acquisition Reform","824","",2)
        ix++
        outline[ix] = new item(false, "Average Tenure of the Program Manager","825","",2)
        ix++
        outline[ix] = new item(false, "Type of Contract","826","",2)
        ix++
        outline[ix] = new item(false, "Competition","827","",2)
        ix++
        outline[ix] = new item(false, "Number of Associate Contractors","828","",2)
        ix++
        outline[ix] = new item(false, "Number of Production Quantity Changes","829","",2)
        ix++
        outline[ix] = new item(false, "SAR percent of Exception/Annual","82a","",2)
        ix++
        outline[ix] = new item(true, "Operational Test Metrics","83","3",1)
        ix++
        outline[ix] = new item(false, "Figure 12","831","",2)
        ix++
        outline[ix] = new item(false, "Figure 13","832","",2)
        ix++
        outline[ix] = new item(false, "Figure 14","833","",2)
        ix++
        outline[ix] = new item(false, "Figure 15","834","",2)
        ix++
        outline[ix] = new item(false, "Figure 16","835","",2)
        ix++
        outline[ix] = new item(false, "Figure 17","836","",2)
        ix++
        outline[ix] = new item(false, "Figure 18","837","",2)
        ix++
        outline[ix] = new item(false, "Chapter 6: Conclusions and Recommendations","9","",0)
        ix++
        outline[ix] = new item(false, "End Notes","a","",0)
        ix++
        outline[ix] = new item(false, "Bibliography","b","",0)
        ix++
        outline[ix] = new item(false, "Authors Notes","c","",0)
        ix++
        outline[ix] = new item(false, "Appendix A: Definitions","d","",0)
        ix++
        outline[ix] = new item(false, "Appendix B: Correlation of Cost Data Sources","e","",0)
        ix++
        outline[ix] = new item(true, "Appendix C","f","4",0)
        ix++
        outline[ix] = new item(false, "Spreadsheet Column Descriptions","f1","",1)
        ix++
        outline[ix] = new item(false, "Notes","f2","",1)
        ix++
        outline[ix] = new item(true, "Spreadsheets","f3","5",1)
        ix++
        outline[ix] = new item(false, "Spreadsheet 1","f31","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 2","f32","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 3","f33","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 4","f34","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 5","f35","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 6","f36","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 7","f37","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 8","f38","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 9","f39","",2)
        ix++
        outline[ix] = new item(false, "Spreadsheet 10","f3a","",2)
        ix++

  setStates()
  setImages()
}

function resetStates() {
  setCookie("tr_1-99_outline", "-")
}

function setStates() {
  var storedValue = getCookie("tr_1-99_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("tr_1-99_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()


