function popUp(_url, _name)
{
	_args = "width=760,height=300, menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes";

	if (typeof(popupWin) != "object")
	{
		popupWin = window.open(_url, _name, _args);
	}
	else
	{
		if (!popupWin.closed)
		{
			popupWin.location.href = _url;
		}
		else
		{
			popupWin = window.open(_url, _name, _args);
		}
	}
	popupWin.focus();
}

function popUpStats(_url)
{
	popUp(_url, 'popup');
}

function adjustSize(_name)
{
	elem = document.getElementById(_name);

	window.innerWidth = elem.offsetWidth;
	window.innerHeight = elem.offsetHeight;

	if (window.screenX == 0 && window.screenY == 0)
	{
		centerWindow();
	}
}

function centerWindow()
{
	window.screenY = (window.screen.height - window.outerHeight) / 2;
	window.screenX = (window.screen.width - window.outerWidth) / 2;
}

function adjustPopupSize()
{
	adjustSize('popup');
}

function selectMatch(_radio)
{
	_match = _radio.parentNode.parentNode;
	document.getElementsByName("m")[0].value = _match.id;

	_cells = _match.cells;

	document.getElementsByName("date")[0].value = _cells[1].innerHTML;
	document.getElementsByName("group")[0].value = _cells[2].innerHTML;

	_hometeam = document.getElementsByName("hometeam")[0];
	for (i = 0; i < _hometeam.options.length; ++i)
	{
		_option = _hometeam.options[i];
		_option.selected = (_option.text == _cells[3].innerHTML);
	}

	_awayteam = document.getElementsByName("awayteam")[0];
	for (i = 0; i < _awayteam.options.length; ++i)
	{
		_option = _awayteam.options[i];
		_option.selected = (_option.text == _cells[5].innerHTML);
	}
}

function confirmDelete()
{
	return confirm('Czy na pewno chcesz usunąć wybrany wiersz?');
}
