
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation. Please see the index.html
// for more details.

function Utilities()
{
}

Utilities.getDocumentWidth = function()
{
	var width = window.innerWidth;
	if (!isNaN(width)) {
		return width;
	}

	width = document.documentElement.clientWidth;
	if (!isNaN(width) && width) {
		return width;
	}

	width = document.body.clientWidth;
	if (!isNaN(width)) {
		return width;
	}

	throw new Exception("Utilities.getDocumentWidth");
}

Utilities.getDocumentHeight = function()
{
	var height = window.innerHeight;
	if(!isNaN(height)) {
		return height;
	}

	height = document.documentElement.clientHeight;
	if(!isNaN(height) && height) {
		return height;
	}

	height = document.body.clientHeight;
	if(!isNaN(height)) {
		return height;
	}

	throw new Exception("Utilities.getDocumentHeight");
}

function Exception(message)
{
	this.toString = function()
	{
		return "Exception: " + message
	}
}

function Hover() {
}

Hover.mouseover = function(element, image)
{
	element.src = image;
}

Hover.mouseout = function(element, image)
{
	element.src = image;
}

function Info() {
}

Info.click = function(id)
{
	var info = document.getElementById(id);
	if (info == null)
	{
		return;
	}

	if (info.style.display == "" || info.style.display == "none")
	{
		info.style.display = "block";
	}
	else
	{
		info.style.display = "none";
	}
}

Info.mouseover = function(element)
{
	element.style.color = "black";
	element.style.borderColor = "black";

	Info.changeColorOfThisElements(element, "a", "black");
}

Info.mouseout = function(element)
{
	element.style.color = "#d6d6d6";
	element.style.borderColor = "#d6d6d6";

	Info.changeColorOfThisElements(element, "a", "#d6d6d6");
}

Info.changeColorOfThisElements = function(root, elementNames, color)
{
	var elements = root.getElementsByTagName(elementNames);
	for (var n = 0; n < elements.length; n++)
	{
		elements[n].style.color = color;
	}
}


