function setActionAndSubmit(form, action)
{
	var actionField = form['action'];
	if (actionField != null)
	{
		actionField.value = action;
		form.submit();
	}	
	return true;
}

function submitOnEnter(form, keyCode, action)
{
	if (keyCode == 13)
	{
		return setActionAndSubmit(form, action);
	}
}

function checkEnterAndSubmit(form, event)
{
	if(event.keyCode == 13) {
		form.submit();
		return false;
	} else {
		return true 
	}
}

function doFoldDiv(divName)
{
	var div = document.getElementById(divName);
	if (div != null) {
		div.style.display = 'none';
	}
}
 
function doUnfoldDiv(divName)
{
	var div = document.getElementById(divName);
	if (div != null) {
		div.style.display = 'block';
	}
}

selectedRow = null;

function setTableSelection(id)
{
	if (selectedRow != null) {
		selectedRow.className = '';
	}

	var currentRow = document.getElementById('tb_row_' + id);
	var rowRadio = document.getElementById('tb_radio_' + id);
	
	if (currentRow != null && rowRadio != null) {
		currentRow.className = 'rowSelected';
		rowRadio.checked = true;
		selectedRow = currentRow;
	}
}

function setTablePage(form, pageNo, action)
{
	pageNoWg = document.getElementById("wgTbPageNo");
	if (pageNoWg != null) {
		pageNoWg.value = pageNo;
		setActionAndSubmit(form, action);
		return true;
	}
	return false;
}

function setTablePageOnEnter(form, keyCode, pageNo, action)
{
	if (keyCode == 13) {
		pageNoWg = document.getElementById("wgTbPageNo");
		if (pageNoWg != null) {
			pageNoWg.value = pageNo;
			setActionAndSubmit(form, action);
		}
	}
}

function showImage(imagePath)
{
	window.open(imagePath, '', 'width=300,height=300,scrollbars=yes,resizable=yes');
}

function showEditor(sessionParam)
{
	window.open('editor/iedit.php?sessionParam=' + sessionParam, 'Edytor', 'width=600,height=600,scrollbars=no,resizable=yes,status=yes');
}
