// 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(30)

//        outline[0] = new item(false, "<i>Summary</i>","summary","",0)

        outline[ix] = new item(false, "Preface","index","",0)
        ix++
        outline[ix] = new item(true, "1.0 Introduction","2","1",0)
        ix++
        outline[ix] = new item(false, "1.1 Purpose","21","",1)
        ix++
        outline[ix] = new item(false, "1.2 Background","22","",1)
        ix++
        outline[ix] = new item(false, "1.3 Problem","23","",1)
        ix++
        outline[ix] = new item(true, "2.0 Anti-Corrosion Design Guidance Sources","3","2",0)
        ix++
        outline[ix] = new item(false, "2.1 Scope","31","",1)
        ix++
        outline[ix] = new item(false, "2.2 Design and Test Specification Interpretations","32","",1)
        ix++
        outline[ix] = new item(false, "2 3 Quantitive Design Feedback Sources","33","",1)
        ix++
        outline[ix] = new item(false, "2.4 Qualitative Design Feedback Sources","34","",1)
        ix++
        outline[ix] = new item(true, "3.0 The Corrosive Environment","4","3",0)
        ix++
        outline[ix] = new item(false, "3.1 Shipboard Environment","41","",1)
        ix++
        outline[ix] = new item(false, "3.2 Operational Environment","42","",1)
        ix++
        outline[ix] = new item(false, "3.3 Maintenance Environment","43","",1)
        ix++
        outline[ix] = new item(true, "4.0 Design Considerations","5","4",0)
        ix++
        outline[ix] = new item(false, "4.1 Types of Interior Airframe Fluids","51","",1)
        ix++
        outline[ix] = new item(false, "4.2 Airframe Vulnerabilities","52","",1)
        ix++
        outline[ix] = new item(true, "4.3 Equipment Housing Vulnerabilities","53","5",1)
        ix++
        outline[ix] = new item(false, "Fastener Areas","531","",2)
        ix++
        outline[ix] = new item(false, "Gaskets","532","",2)
        ix++
        outline[ix] = new item(false, "\"O\" Rings","533","",2)
        ix++
        outline[ix] = new item(false, "Form-In-Place Seals","534","",2)
        ix++
        outline[ix] = new item(false, "Electrical Connectors","535","",2)
        ix++
        outline[ix] = new item(false, "4.4 Susceptibility of Subassemblies to Fluid Intrusion","54","",1)
        ix++
        outline[ix] = new item(false, "4.5 Corrosion and Deterioration of Subassemblies/Circuit Component","55","",1)
        ix++
        outline[ix] = new item(true, "5 0 Design Techniques to  Minimize Corrosion Susceptibility","6","6",0)
        ix++
        outline[ix] = new item(false, "5.1 Design Approach","61","",1)
        ix++
        outline[ix] = new item(false, "5.2 Material Selection and Use","62","",1)
        ix++
        outline[ix] = new item(false, "5.3 Design Configurations to Minimize Corrosion Film Moisture (C/F/M)","63","",1)
        ix++
        outline[ix] = new item(false, "6.0 References","7","",0)
        ix++

  setStates()
  setImages()
}

function resetStates() {
  setCookie("navmat p-4855-2_outline", "-")
}

function setStates() {
  var storedValue = getCookie("navmat p-4855-2_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("navmat p-4855-2_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()


