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();
		}
	}
	

