var sans = "Tahoma, Verdana, Helvetica, Arial, Sans-Serif";

var serif = "Palatino Linotype, Georgia, Times New Roman, Utopia, Serif";

FONT_DEFAULT = 9; FONT_SMALLEST = 8; FONT_LARGEST = 12;

var fSize = FONT_DEFAULT;

var fFamily = sans;

var ri_select = "#e4e8e0";  // "#f3f2f0"

var ARTICLE_CELL;

if( document.cookie != "" )
{
	var cookie_array = document.cookie.split( ";" ); fSize = parseInt(cookie_array[0].split( "=" )[1] ); fFamily = cookie_array[1].split( "=" )[1];

	document.write( "<style type=\"text/css\">.article { font-family: " + fFamily + "; font-size: " + fSize + "pt; }</style>" );
}
if( !document.layers ) document.write( "<style type=\"text/css\">.toc { font-size: 7pt; }</style>" );

function printerFriendly()
{
	var W = 760, H = 640, X = ( screen.width - W )/2, Y = ( screen.height - H )/2;

	window.open( 'print.php' + location.search, 'x', 'menubar=0,scrollbars=1,location=0,statusbar=0,resizable=0,width='+W+',height='+H+',left='+X+',top='+Y );
}
/*function getPrinterFriendlyStatus()
{
	if( document.layers )
	{
		document.write( "<img border=\"0\" src=\"images/printerX.gif\" alt=\"Sorry, The Printer View Isn't Available In Netscape\" vspace=\"4\" width=\"26\" height=\"25\">" )
	}
	else { document.write( "<a href=\"#\" onclick=\"printerFriendly(); return false\" onmouseover=\"window.status=''; return true;\"><img border=\"0\" src=\"images/printer.gif\" alt=\"Print This Page\" vspace=\"4\" width=\"26\" height=\"25\"></a>" )
	}
}*/
function ri( o ) { o.style.backgroundColor = ri_select; } 

function ro( o ) { o.style.backgroundColor = "white"; } 

function nada() { return false; }

function init()
{
	if( document.getElementById )
	{
		// add context by highlighting the TOC cell corresponding to this page and disabling the cell's events and visual cues
		//
		if( the_cell = document.getElementById( location.search.substring(1).split("=")[1] ))
		{
			the_cell.style.backgroundColor = ri_select;

			the_cell.onmouseover = the_cell.onmouseout = the_cell.onclick = nada;

			the_cell.style.cursor = the_cell.getElementsByTagName( "A" )[0].style.cursor = 'default';
		} 
		// if this page has a caption (article title), make the window title more informative
		//
		if( the_cap = document.getElementById( "cap" )) document.title = the_cap.innerHTML;

		ARTICLE_CELL = document.getElementById( "articleCell" );  // save this element for later use

		// document.onselectstart = nada;    // some users wanted to be able to select and copy text
	}
}
function saveStyle()
{
	var expire = new Date(); expire.setTime( expire.getTime() + 31*24*3600*1000 ); 
	
	var expires = expire.toGMTString();

	document.cookie = "fontSize=" + fSize + "; path=/; expires=" + expires; 
	
	document.cookie = "fontFamily=" + fFamily + "; path=/; expires=" + expires;

	if( document.getElementsByTagName )
	{
		// iterate through collection of Paragraphs of class 'article' and set properties in-place
		//
		var i=0, p = ARTICLE_CELL.getElementsByTagName( "P" ); 
		
		while( o = p[i++] ) { if( o.className == "article" ) { o.style.fontSize = fSize+"pt"; o.style.fontFamily = fFamily; } }
	}
	else { window.location.reload();
	}
}
function setFaceLarger() { if( isNaN( fSize )) { fSize = FONT_DEFAULT }; fSize++; if( fSize > FONT_LARGEST ) { fSize = FONT_SMALLEST }; saveStyle(); }

function setFontFamily() { if( fFamily == sans ) { fFamily = serif } else { fFamily = sans }; saveStyle(); }

