// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/

var caution = false
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 makeDatabase() {
	var i = 0
	outlinenml = new makeArray(9) 

    outlinenml[i] = new item(false, '<font face="Verdana" size="2" color="#000080"><A HREF="XXV-21.htm" target=\"blank\", class=bodylink>Normal breast, H+E stain</A>', 0); ++i
    outlinenml[i] = new item(false, '<A HREF="XXV-22.htm" target=\"blank\", class=bodylink>Normal breast, H+E stain</A>', 0); ++i
    outlinenml[i] = new item(false, '<A HREF="XXV-24.htm" target=\"blank\", class=bodylink>Normal breast, calponin stain</A>', 0); ++i
    outlinenml[i] = new item(false, '<A HREF="XXV-23.htm" target=\"blank\", class=bodylink>Normal breast, calponin stain</A>', 0); ++i
    outlinenml[i] = new item(false, '<A HREF="XXV-25.htm" target=\"blank\", class=bodylink>Normal breast, p63 stain</A>', 0); ++i
    outlinenml[i] = new item(false, '<A HREF="XXV-26.htm" target=\"blank\", class=bodylink>Normal breast, p63 stain</A>', 0); ++i
    outlinenml[i] = new item(false, '<A HREF="XXV-03.htm" target=\"blank\", class=bodylink>Normal breast, ER stain</A>', 0); ++i
    outlinenml[i] = new item(false, '<A HREF="XXVI-17.htm" target=\"blank\", class=bodylink>Normal breast. E-cadherin stain, low power</A>', 0); ++i
    outlinenml[i] = new item(false, '<A HREF="XXVI-16.htm" target=\"blank\", class=bodylink>Normal breast. E-cadherin stain, high power</A>', 0); ++i

	setStates()
	setImages()
}
function setStates() {
	var storedValue = getCookie("outlinenml")
	
	if (!storedValue) {
		for (var i = 0; i < outlinenml.length; ++i) {
			if (outlinenml[i].depth == 0)
				outlinenml[i].state = true
			else
				outlinenml[i].state = false
		}
	} else {
		for (var i = 0; i < outlinenml.length; ++i) {
			if (storedValue.charAt(i) == '1')
				outlinenml[i].state = true
			else
				outlinenml[i].state = false
		}
	}
}
function setImages() {
	for (var i = 0; i < outlinenml.length; ++i) {
		if (outlinenml[i].state)
			if (outlinenml[i].parent) 
				if (outlinenml[i + 1].state) 
					outlinenml[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="images/exploded.gif" BORDER=0></A>'
				else 
					outlinenml[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="images/collapsd.gif" BORDER=0></A>'
			else 
				outlinenml[i].pic = '<IMG SRC="images/child.gif" BORDER=0>'
	}
}
function toggle(num) {
	for (var i = num + 1; i < outlinenml.length && outlinenml[i].depth >= outlinenml[num].depth + 1; ++i) {
		if (outlinenml[i].depth == outlinenml[num].depth + 1)
			outlinenml[i].state = !outlinenml[i].state 
	}
	setStorage()
	history.go(0)
}
function setStorage() {
	var text = ""
	for (var i = 0; i < outlinenml.length; ++i) {
		text += (outlinenml[i].state) ? "1" : "0"
	}

	setCookie("outlinenml", text)
}
function openall() {
		for (var i = 0; i < outlinenml.length; ++i) {
			if (outlinenml[i].depth == 0)
				outlinenml[i].state = true
			else
				outlinenml[i].state = true
		}
	setStorage()
	history.go(0)
}
makeDatabase()

