function setCookie(name, value)
{
	var date = new Date();
	date.setFullYear(2010);
	
	document.cookie = name + "=" + escape(value) +
			"; expires=" + date.toGMTString() + ";";
}

function getCookie(name)
{
	var search = name + "=";

	if (document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		} 
	}
	return "";
}

function cookiesEnabled()
{
	var name = "testing";
	var value = "1";
	setCookie(name, value);
	var x = getCookie(name);
	if ( x != value) {
		return false;
	} else {
		return true;
	}
}

function Exist(any)
{
	var str = "" + any + "";
	return (str != 'undefined') && (str != '') && (str != 'null');
}

function treeExpand(imageObject)
{
	var listObject = document.all(imageObject.id + "list");
	
	if (listObject.style.display == "block")
	{
		imageObject.src = "../images/treePlus.gif";
		listObject.style.display = "none";
	}
	else
	{
		imageObject.src = "../images/treeMinus.gif";
		listObject.style.display = "block";
	}	
}

function resetMainBanner()
{
	if (window.screen.height <= 600)
	{
		mainTable.width = 670;
		mainTable.style.width = 670;
		mainBanner.src = "images/bannerHPs.gif";
	}
	resetLangLink();
}
function resetLangLink()
{
	var rect = mainBanner.getBoundingClientRect();
	rect.right  += mainBanner.offsetLeft;
	rect.bottom += mainBanner.offsetTop;
	
	langRedirect.style.left = rect.right - langRedirect.offsetWidth - 50;
	langRedirect.style.top = rect.bottom - langRedirect.offsetHeight - 20;
	
	langRedirect.style.visibility = "visible";
}

function setLegend(figureObject, x, y, text)
{
/*
	window.alert("left=" + rect.left + " right=" + rect.right + 
				 " top=" + rect.top + " bottom=" + rect.bottom);
	window.alert("offsetLeft=" + imageObject.offsetLeft + 
				 " offsetTop=" + imageObject.offsetTop);
	window.alert("body.clientLeft=" + document.body.clientLeft + 
				 " body.clientTop=" + document.body.clientTop);
	window.alert("imageObject.clientLeft=" + imageObject.clientLeft + 
				 " imageObject.clientTop=" + imageObject.clientTop);
*/
	var legendObject = document.all(figureObject.id + "Legend");
	if (Exist(legendObject))
	{
		var rect = figureObject.getBoundingClientRect();

		var XXX  = new Number(rect.left);
		XXX += Number(x) + document.body.scrollLeft;
		var YYY  = new Number(rect.top);
		YYY += Number(y) - 13 + document.body.scrollTop;

		var inner = "<DIV style='text-align: left; font-size: 11px; font-style: italic; font-weight: bold; LEFT: " +
					XXX + "px; TOP: " + YYY + "px; POSITION: absolute'>" +
					text + "</DIV>";

		legendObject.innerHTML += inner;
	}
}

function setLegendNull(figureObject)
{
	var legendObject = document.all(figureObject.id + "Legend");
	if (Exist(legendObject))
		legendObject.innerHTML = "";
}

function onResize()
{
	var imgCollection = document.all.tags("IMG");
	if (imgCollection != null)
	{
		for (i = 0; i < imgCollection.length; i++)
		{
			var idString = new String;
			idString = imgCollection[i].id;
			if (idString.substr(0, 6) == "figure")
			{
				imgCollection[i].fireEvent('onload');
			}
		}
	}
}

function onLoad()
{
}

function SetFimg()
{
	var rect = funnyImg.getBoundingClientRect();
/*
	window.alert("left=" + rect.left + " right=" + rect.right + 
				 " top=" + rect.top + " bottom=" + rect.bottom);
	window.alert("offsetLeft=" + funnyImg.offsetLeft + 
				 " offsetTop=" + funnyImg.offsetTop);
	window.alert("body.clientLeft=" + document.body.clientLeft + 
				 " body.clientTop=" + document.body.clientTop);
	window.alert("body.scrollWidth=" + document.body.scrollWidth + 
				 " body.scrollHeight=" + document.body.scrollHeight);
*/
	if (rect.bottom < document.body.scrollHeight - 50)
	{
		funnyImg.style.position = "absolute";
		funnyImg.style.top = document.body.scrollHeight - 110;
		funnyImg.style.left = 60;
	}
	funnyImg.style.visibility = "visible";
}

function SetItem(itemHref)
{
    var frameObject = document.parentWindow.frameElement;

	if (Exist(frameObject))
		frameObject.src = "" + itemHref;
}