var mtDays;
var mtList;
var mtOffset = 0;

function gotoBad ()
{
	document.location = currentPageID + "_2.html";
}

function gotoGood ()
{
	if (currentPageID == "dpb")
		document.location = "index.html";
	else
		document.location = currentPageID + ".html";
}

function updateLists (pageID, language)
{
	currentPageID=pageID;

	switch (pageID)
	{
		case 'ae':
			var e = document.getElementById ('mainList');
			if (e)
			{
				window.onresize = function () { updateListSize (e) };
				
				updateListSize (e);
				eraseFilter();
			}

			break;

		case 'ds':
		case 'ds_2':
			updateFiltered ();
			eraseFilter();

			var e = document.getElementById ('comment');
			if (e)
			{
				window.onresize = function () { updateCommentSize (e) };
				
				updateCommentSize (e);
			}

			break;

		case 'ddr':
		{
			mtDays = mtwbDay;
			mtList = mtwbDayList;
			var e = document.getElementById ('mainList');
			if (e)
			{
				window.onresize = function () { updateListSize (e) };
				
				updateListSize (e);
				eraseFilter();
			}

			break;
		}

		case 'dmr':
		{
			mtDays = mtwbMonth;
			mtList = mtwbMonthList;
			var e = document.getElementById ('mainList');
			if (e)
			{
				window.onresize = function () { updateListSize (e) };
				
				updateListSize (e);
				eraseFilter();
			}

			break;
		}

		case 'dkr':
		{
			mtDays = mtwbBench;
			mtList = mtwbBenchList;
			var e = document.getElementById ('mainList');
			if (e)
			{
				window.onresize = function () { updateListSize (e) };
				
				updateListSize (e);
				eraseFilter();
			}

			break;
		}
	}
}

var lastF = "-";

function updateListSize (e)
{
	var windowHeight = getWindowHeight();

	if (windowHeight - 290 > 0)
		e.style.height = (windowHeight - 290) + 'px';
}

function updateCommentSize (e)
{
	var windowHeight = getWindowHeight();

	if (windowHeight - 460 > 0)
		e.style.height = (windowHeight - 460) + 'px';
}

var refreshTimeout = 0;

function prepareUpdateFiltered ()
{
	if (refreshTimeout)
		clearTimeout (refreshTimeout);

	refreshTimeout = setTimeout ('updateFiltered ()', 200);
}

function eraseFilter()
{
	var f;
	
	f = document.getElementById ("filter");
	f.value = "";
	f.focus ();

	updateFiltered ();
}

function navigationClick (pageID, language)
{
	return true;
}

function languageClick (pageID, language)
{
	return true;
}

function logoClick (pageID, language)
{
	return true;
}

function getWindowHeight()
{
	var windowHeight = 0;

	if (typeof (window.innerHeight) == 'number')
		windowHeight = window.innerHeight;
	else
	{
		if (document.documentElement && document.documentElement.clientHeight)
			windowHeight = document.documentElement.clientHeight;
		else
		{
			if (document.body && document.body.clientHeight)
				windowHeight = document.body.clientHeight;
		}
	}

	return windowHeight;
}
