var caution = false
var whichmenu
var currentmenu

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, text, depth) {
	this.parent = parent 
	this.text = text 
	this.depth = depth 
}
function makeArray(length) {
	this.length = length 
}

function setStates() {
	var storedValue = getCookie("outline" + whichmenu)
	
	if (!storedValue) {
		for (var i = 0; i < outline.length; ++i) {
			if (outline[i].depth == 0)
				outline[i].state = true
			else
				outline[i].state = false
		}
	} else {
		for (var i = 0; i < outline.length; ++i) {
			if (storedValue.charAt(i) == '1')
				outline[i].state = true
			else
				outline[i].state = false
		}
	}
}
function setImages() {
	for (var i = 0; i < outline.length; ++i) {
		if (outline[i].state)
			if (outline[i].parent) 
				if (outline[i + 1].state) 
					outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="/js/images/exploded_c.gif" HSRC="/js/images/exploded_h.gif" BORDER=0 name="Btn' + i + '"></A>'
				else 
					outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="/js/images/collapsd_c.gif" HSRC="/js/images/Collapsd_h.gif" BORDER=0 name="Btn' + i + '"></A>'
			else 
				outline[i].pic = '<IMG SRC="/js/images/child.gif" BORDER=0>'
	}
}
function toggle(num) {
	for (var i = num + 1; i < outline.length && outline[i].depth >= outline[num].depth + 1; ++i) {
		if (outline[i].depth == outline[num].depth + 1)
			outline[i].state = !outline[i].state 
	}
	setStorage()
	history.go(0)
}
function setStorage() {
	var text = ""
	for (var i = 0; i < outline.length; ++i) {
		text += (outline[i].state) ? "1" : "0"
	}

	setCookie("outline" + whichmenu, text)
}

function CreateMenu() {
  document.write('<PRE class=menuitem>')
  for (var i = 0; i < outline.length; ++i) {
	if (outline[i].state) {
		for (var j = 0; j < outline[i].depth * 2; ++j) {
			document.write(' ')
		}
		document.write(outline[i].pic, ' ', outline[i].text, '<BR>')
	} else {
		var previous = i
		for (var k = i + 1; k < outline.length && outline[k].depth >= outline[previous].depth; ++k) {
			++i
		}
	}
}
document.write('</PRE>')
}
