function toggletree(obj, evt)
	{
	if (obj == evt.target)
		{
		obj.className = (obj.className == "treeopened") ? "treeclosed" : "treeopened";
		}
	return true;
	}

function select_plugin_type()
	{
	var ua = navigator.userAgent;
	var highlight = 'lightgreen';
	var row_name = 'unknown';
	if ( (ua.search('Firefox') != -1 && ua.search('Epiphany') == -1) || ua.search('SeaMonkey|Flock|BonEcho|Minefield') != -1)
		{ // (Firefox and not Epiphany), SeaMonkey, Flock, BonEcho, Minefield
		row_name = 'firefox';
		if (ua.search('Windows') != -1)
			{ // windows
			row_name += '_windows';
			if ( ua.search('Win64|x64') != -1 )
				{
				row_name += '64';
				}
			}
		else if (ua.search('Mac OS X') != -1)
			{ // mac
			row_name += '_mac';
			}
		else if (ua.search('Linux') != -1)
			{ // Linux
			if (ua.search('Linux x86_64') != -1)
				{ // Linux 64-bit
				row_name += '_linux64';
				}
			else
				{
				row_name += '_linux32';
				}
			}
		}
		
	else
		{
		if ( ua.search('MSIE') != -1 || ( ua.search('Windows') != -1 && (ua.search('Opera|K-Meleon') != -1) ) )
			{ // MSIE or ( Windows and ( Opera,K-Meleon ) )
			if ( ua.search('Win64|x64') != -1 )
				{
				row_name = 'windows64';
				}
			else
				{
				row_name = 'windows';
				}
			}
		else
			{
			if (ua.search('Macintosh') != -1)
				{
				row_name = 'mac';
				}
			else
				{
				if (ua.search('Linux') != -1)
					{
					if (ua.search('Linux x86_64') != -1)
						{
						row_name = 'linux64';
						}
					else
						{
						row_name = 'linux32';
						}
					}
				}
			}
		}
	if (row_name != 'unknown')
		{
		document.getElementById(row_name).style.backgroundColor=highlight;
		document.getElementById('download_link').href = document.getElementById(row_name+'_link').href;
		document.getElementById('install_notes').innerHTML = document.getElementById(row_name+'_notes').innerHTML;
		}
	else
		{
		document.getElementById('download_link').style.background = "url(../include/download-button-grey.png) 0 0 no-repeat";
		}
	}

function expandTree(treeId)
	{
	var tree = document.getElementById(treeId);
	if (tree != null)
		{
		expandCollapseList(tree, "treeopened");
		}
	}

function collapseTree(treeId)
	{
	var tree = document.getElementById(treeId);
	if (tree != null)
		{
		expandCollapseList(tree, "treeclosed");
		}
	}

function expandCollapseList(ul, cName, itemId)
	{
	if (!ul.childNodes || ul.childNodes.length == 0)
		{
		return false;
		}
	for (var itemi = 0; itemi < ul.childNodes.length; itemi++)
		{
		var item = ul.childNodes[itemi];

		if (itemId != null && item.id == itemId)
			{
			return true;
			}
		if (item.nodeName == "LI")
			{
			var subLists = false;

			for (var sitemi = 0; sitemi < item.childNodes.length; sitemi++)
				{
				var sitem = item.childNodes[sitemi];

				if (sitem.nodeName == "UL")
					{
					subLists = true;
					var ret = expandCollapseList(sitem, cName, itemId);

					if (itemId != null && ret)
						{
						item.className = cName;
						return true;
						}
					}
				}
			if (subLists && itemId == null)
				{
				item.className = cName;
				}
			}
		}
	}

function expandToItem(treeId, itemId)
	{
	var ul = document.getElementById(treeId);

	if (ul == null)
		{
		return false;
		}
	var ret = expandCollapseList(ul, "treeopened", itemId);

	if (ret)
		{
		var o = document.getElementById(itemId);

		if (o.scrollIntoView)
			{
			o.scrollIntoView(false);
			}
		}
	}

function is_print()
	{
	var isprint = 0;
	var stylevalue = document.getElementById('stylevalue');
	if (stylevalue != null)
		{
		var widthvalue = '0px';
		if (document.all)
			{
			widthvalue = document.all.stylevalue.width;
			}
		else
			{
			widthvalue = document.defaultView.getComputedStyle(stylevalue,null).getPropertyValue('width');
			}
		if (widthvalue == '1px')
			{
			isprint = 1;
			}
		}
	return isprint;
	}
	
function calculateSizes()
	{
	var newheight = 0;
	var newwidth = 0;
	if (navigator.appName != "Microsoft Internet Explorer")
		{
		newheight = window.innerHeight;
		newwidth = window.innerWidth;
		}
	else
		{
		newheight = document.body.clientHeight;
		newwidth = document.body.clientWidth;
		}

	
	var contentframe = document.getElementById('contentframe');
	if (contentframe != null)
		{
		var contentlist = document.getElementById('contentlist');
		var contentpane = document.getElementById('contentpane');
		if (newheight < 640)
			{
			contentframe.style.height = 'auto';
			if (contentlist)
				{
				contentlist.style.height = 'auto';
				}
			contentpane.style.height = 'auto';
			}
		else
			{
			var remainingheight = newheight - 220;
			contentframe.style.height = remainingheight+'px';
			remainingheight -= 25;
			if (contentlist)
				{
				contentlist.style.height = 200+'px';
				remainingheight -= 200;
				}
			contentpane.style.height = remainingheight+'px';
			}
		}
	
	var bookcontentframe = document.getElementById('bookcontentframe');
	if (bookcontentframe != null)
		{
		var bookcontentpane = document.getElementById('bookcontentpane');
		var bookcontentlist = document.getElementById('bookcontentlist');
		var framemarginwidth = 270;			
		var panemarginwidth = framemarginwidth + 40;			
		if (newheight < 640)
			{
			bookcontentframe.style.width = (newwidth - framemarginwidth)+'px';
			bookcontentframe.style.height = 'auto';
			bookcontentpane.style.width = (newwidth - panemarginwidth)+'px';
			bookcontentpane.style.height = 'auto';
			bookcontentlist.style.width = '220px';
			bookcontentlist.style.height = 'auto';
			}
		else
			{
			bookcontentframe.style.width = (newwidth - framemarginwidth)+'px';
			bookcontentframe.style.height = (newheight - 240)+'px';
			bookcontentpane.style.width = (newwidth - panemarginwidth)+'px';
			bookcontentpane.style.height = (newheight - 240)+'px';
			bookcontentlist.style.width = '220px';
			bookcontentlist.style.height = (newheight - 240)+'px';
			}
		}
	}

function windowresize()
	{
	if (!is_print())
		{
		calculateSizes();
		}
	}

function bodyload()
	{
	if (!is_print())
		{
		if (navigator.appName != "Microsoft Internet Explorer")
			{
			window.captureEvents(Event.RESIZE);
			window.onresize=windowresize;
			}
		calculateSizes();
		}
	}
function calculateTableSizes()
	{
	var scrollingtable = document.getElementById('scrollingtable');
	if (scrollingtable != null)
		{
		var scrollingtablebody = scrollingtable.tBodies[0]; // document.getElementById('scrollingtablebody');
		var scrollingtablehead = scrollingtable.tHead; // document.getElementById('scrollingtablehead');
		var newheight = window.innerHeight - (scrollingtablehead.clientHeight + 60);
		// var newwidth = window.innerWidth;
		scrollingtablebody.style.height = newheight+'px';
		// scrollingtablebody.style.width = newwidth+'px';
		}
	}

function windowtableresize()
	{
	if (!is_print())
		{
		calculateTableSizes();
		}
	}

var refreshID;
var refreshSecondsStored = 60;
function refresh_page() 
	{
	location.reload(true);
	}
function start_refresh(refreshSeconds)
	{
	refreshID = window.setInterval("refresh_page()",refreshSeconds * 1000);
	refreshSecondsStored = refreshSeconds;
	}
function stop_refresh()
	{
	window.clearInterval(refreshID);
	}
function toggle_refresh(check_box)
	{
	if (check_box.checked)
		{
		start_refresh(refreshSecondsStored);
		}
	else
		{
		stop_refresh();
		}
	}

function bodyloadtable()
	{
	// alert('bodyloadtable');
	if (!is_print())
		{
		window.onresize=windowtableresize;
		calculateTableSizes();
		}
	}
function bodyloadtablerefresh(refreshSeconds)
	{
	if (!is_print())
		{
		if (refreshSeconds > 0)
			{
			start_refresh(refreshSeconds);
			}
		window.onresize=windowtableresize;
		calculateTableSizes();
		}
	}

function menutree_start(menu_id, menu_name)
	{
	document.write('<table><tr><td><img alt="++" class="treebutton" height="11" onclick="expandTree('+"'"+menu_id+"'"+')" src="/include/plusplus.gif" title="Expand All" width="21" /><br /><img alt="--" class="treebutton" height="11" onclick="collapseTree('+"'"+menu_id+"'"+')" src="/include/minusminus.gif" title="Collapse All" width="21" /></td><td><span class="treeheader">'+menu_name+'</span></td></tr></table>');
	document.write('<ul class="menutree" id="'+menu_id+'">');
	}
function menutree_end()
	{
	document.write('</ul>');
	}
function menutree_sub_start(item_id, item_name, item_link, item_description, opened)
	{
	if (opened)
		{
		opened = 'opened';
		}
	else
		{
		opened = 'closed';
		}
	document.write('<li class="tree'+opened+'" id="'+item_id+'" onclick="toggletree(this,event)"><a href="'+item_link+'" title="'+item_description+'">'+item_name+'</a><ul>');
	}
function menutree_sub_end()
	{
	document.write('</ul></li>');
	}
function menutree_item(item_id, item_name, item_link, item_description, opened)
	{
	document.write('<li class="treebullet" id="'+item_id+'"><a href="'+item_link+'" title="'+item_description+'">'+item_name+'</a></li>');
	}



