var totalTips;
var naviWindow;

function setViewed()
{
	var lastReadTip = readLastCookie();
	var i = 0;
	var tip;
	while(tip = document.getElementById("tip_" + ++i))
	{
		if(i > lastReadTip)
		{
			tip.style.backgroundColor = "#afa";
		}
	}
	totalTips = --i;
	
	writeCookie(totalTips);
}

function readLastCookie()
{
	var lastRead
	var data = unescape(document.cookie);
	if(data)
	{
		// search through raw data to find string matching this page
		var pageName = document.title;
		var pageNameLength = pageName.length;
		var sectionStart = data.indexOf(pageName);
		if(sectionStart > -1)	// found an entry for this page
			lastRead = parseInt(data.substr(sectionStart + pageNameLength + 1));	// get part of string that matches
		else
			lastRead = 0;
	}
	else
		lastRead = 0;

	return lastRead;
}
	
function writeCookie(last)
{
	var currentDate = new Date();
	var expiryDate = new Date(currentDate.getTime() + (365 * 86400 * 1000)); // add on 1 year
	var pageName = window.name;
	document.cookie = escape(document.title) + "=" + last + "; expires=" + expiryDate.toGMTString();
}

function openGlossary(term, width, height)
{
	var aURL = "glossary/" + term.charAt(0) + "/" + term + ".html";
	window.open(aURL,"definition","width="+ width + ",height=" + height);
}

function openGlossary(term, width, height)
{
	var URL = "glossary/popupGlossary.html#" + term;
	window.open(URL,"definition","width="+ width + ",height=" + height + ",resizable");
}
/*
function preloadNavigator()
{
	// load navigator images for quick opening
	var navImage = new Image();
	navImage.src = "images/Navigation-panel.gif";
}

function openNavigator1()
{
	if(!naviWindow || naviWindow.closed)
		naviWindow = window.open("../navigator.html","NaviWindow","height=600,width=160");
	else
		naviWindow.focus();
}

function openNavigator2()
{
	if(!naviWindow || naviWindow.closed)
		naviWindow = window.open("navigator.html","NaviWindow","height=600,width=160");
	else
		naviWindow.focus();
}
*/
