//var today = new Date();
//var todays_date = new Date(today.getYear(), today.getMonth(), today.getDate(), 0, 0, 0);
//var expires_date = new Date(todays_date.getTime() + (8 * 7 * 86400000));

function IsoDateString(date)
	{
	if ((year = date.getFullYear()) < 1900)
		year += 1900;
	month = date.getMonth() + 1;
	dayOfMonth = date.getDate();
	return year + "-" +  ((month < 10) ? "0" : "") + month + "-" + ((dayOfMonth < 10) ? "0" : "") + dayOfMonth;
	}

function DateString(date)
	{
	var monthName = new Array
		(
		"January",
		"February",
		"March",
		"April",
		"May",
		"June",
		"July",
		"August",
		"September",
		"October",
		"November",
		"December"
		);
	if ((year = date.getFullYear()) < 1900)
		year += 1900;
	month = monthName[date.getMonth()];
	dayOfMonth = date.getDate();
	return month + " " + dayOfMonth + ", " + year;
	}

function Updated()
	{
	document.write("Updated: " + IsoDateString(new Date(document.lastModified)));
	}

function HighlightTable(table)
//******************************************************************************
// Written by Jeffrey P. Smith, September 28, 2005
//
// Highlights rows of a table based on a color sequence specified in the
// HIGHLIGHT tag as follows:
//    <TABLE class="highlight:ColorSequence">
// Where ColorSequence is a semicolon delimited string of colors such as:
//    #FFFFC0;White
// Which will alternately set the background color of the rows to "Pale Yellow"
// and "White".
//
// If no color sequence is specified, then #FFFFC0;Transparent is assumed.
//
// If one color is specified, then the alternate color is "White".
//
// Rows with a predefined background color (e.g., <TR BGCOLOR=Color>) are
// skipped.
//
// If a row contains cells that span multiple rows, then the background color of
// all rows spanned by the cell are set to the same color.
//
// Cells with a predefined background color (e.g., <TD BGCOLOR=Color>) are not
// altered.
//******************************************************************************
	{
	if (table.className)
		{
		var className = table.className.split(":");
		if (className.length && className[0] == "highlight")
			{
			if (className.length == 1)
				var colors = new Array ("#FFFFC0","Transparent");
			else
				{
				colors = className[1].split(";");
				if (colors.length == 1)
					colors[1] = "White";
				}
		   	var color = 0;
			for	(var row = 0; row < table.rows.length;)
				{
				var rowSpan = 1;
				var highlighted = false;
				var visible = false;

				for (var cell = 0; cell < table.rows[row].cells.length; cell++)
					rowSpan = Math.max(rowSpan, table.rows[row].cells[cell].rowSpan);

				while (rowSpan)
					{
					if (highlighted = !table.rows[row].bgColor)
						table.rows[row].bgColor = colors[color];
					visible = visible || table.rows[row].style.display != 'none';
					--rowSpan;
					++row;
					}
	  			if (highlighted && visible)
				    color = ++color % colors.length;
				}
			}
		}
	}

function HighlightTables()
	{
	var object = document.getElementsByTagName("TABLE");

	if (object != null)
		if (object.length)
			for (var i = 0; i < object.length; i++)
				HighlightTable(object[i]);
		else
			HighlightTable(object);
	}

function Redirect(url)
//******************************************************************************
// 2007-11-04 Jeffrey P. Smith
//    a. Original.
// 2007-03-08 Jeffrey P. Smith
//    a. Passes along document hash, if any.
//******************************************************************************
	{
	if (self.name == "Search")
		top.location.replace(url);
	else if (window.parent.location.href == window.self.location.href)
		{
		if (url.indexOf("#") == -1)
			window.location.replace(url + document.location.hash);
		else
			window.location.replace(url);
		}
	}

function SetTitle()
	{
	top.document.title = document.title;
	}

function GetCookie(NameOfCookie)
	{
	if (document.cookie.length > 0)
		{              
		begin = document.cookie.indexOf(NameOfCookie + "=");       
		if (begin != -1)
			{           
			begin += NameOfCookie.length+1;       
			end = document.cookie.indexOf(";", begin);
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
			} 
		}
	return null;
	}

function SetCookie(NameOfCookie, value, expiredays)
	{
	var ExpireDate = new Date();

	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
	}

function DeleteCookie(NameOfCookie)
	{
	if (GetCookie(NameOfCookie))
		{
		document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}

function Check(name)
	{
	SetCookie(name,'ON', 7);
	}

function Checked(name)
	{
	return GetCookie(name) == 'ON';
	}

function Uncheck(name)
	{
	SetCookie(name,'OFF', 7);
	}

function Toggle(name)
	{
	if (GetCookie(name) == 'ON')
		SetCookie(name, 'OFF', 7);
	else
		SetCookie(name, 'ON', 7);
	}

function CheckCitation(object, display)
	{
	if (object != null)
		{
		if (object.length != null)
			for (var i = 0; i < object.length; i++)
				object[i].style.display = display;
		else
			object.style.display = display;
		}
	}

function CheckCitations()
//******************************************************************************
// Written by Jeffrey P. Smith
//
// If the "Citations" cookie is ON then the "inner text" is displayed per the
// style definition. Otherwise, it is hidden.
//******************************************************************************
	{
	var display = Checked("Citations") ? "inline" : "none";

	var object = document.getElementsByTagName("CITE");
	CheckCitation(object, display);
	}

function CheckInserts()
//******************************************************************************
// Written by Jeffrey P. Smith
//
// If the Inserts cookie is OFF then the font style and color of the "inner text"
// are changed to "italics" and "red", respectively. Other there are set to
// "normal" and "black".
//******************************************************************************
	{
	var fontStyle	= Checked("Inserts") ? "normal" : "italic";
	var color	= Checked("Inserts") ? "black" : "red";
	var object = document.getElementsByTagName("INS");

	if (object != null)
		{
		if (object.length != null)
			for (var i = 0; i < object.length; i++)
				{
				object[i].style.fontStyle = fontStyle;
				object[i].style.color = color;
				}
		else
			{
			object.style.fontStyle = fontStyle;
			object.style.color = color;
			}
		}
	}

function CheckStrikeout(object, display)
	{
	if (object != null)
		{
		if (object.length != null)
			for (var i = 0; i < object.length; i++)
				object[i].style.display = display;
		else
			object.style.display = display;
		}
	}

function CheckStrikeouts()
//******************************************************************************
// Written by Jeffrey P. Smith
//
// If the "Strikeouts" cookie is OFF then the "inner text" is displayed per the
// style definition. Otherwise, it is hidden.
//******************************************************************************
	{
	var display = Checked("Strikeouts") ? "none" : "inline";

	var object = document.getElementsByTagName("S");
	CheckStrikeout(object, display);
	var object = document.getElementsByTagName("STRIKE");
	CheckStrikeout(object, display);
	var object = document.getElementsByTagName("DEL");
	CheckStrikeout(object, display);
	}

function CheckOptions()
	{
//	CheckCitations();
	CheckInserts();
	CheckStrikeouts();
	}

function OnLoad(text)
	{
	CheckOptions();
	HighlightTables();
	SetTitle();
	if (text != null)
		alert(text);
	}

function MailTo(name, domain)
	{
	document.write("<a href=\"mailto:" + name + "@" + domain + "\">" + name + "@" + domain + "</a>");
	}

function include(filename)
	{
	var head = document.getElementsByTagName('head')[0];
	
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	head.appendChild(script)
	}