var errors, hddnPositionId, edtPositionTitle, edtPositionDesc, selAccessId;
var module = baseRootURL + "position/";

function registerPosition(action)
{
	errors = false;
	validate_hddnPositionId();
	validate_edtPositionTitle();
	validate_edtPositionDesc();
	validate_selAccessId();
	if (!errors)
	{
		var data = {};
		data.dummy = ""; //we seem to get errors from the first value, so always add a dummy value first.
		data.action = action;
		if (document.getElementById("hddnPositionId") != null) data.hddnPositionId = hddnPositionId;
		data.edtPositionTitle = edtPositionTitle;
		data.edtPositionDesc = edtPositionDesc;
		data.selAccessId = selAccessId;
		callModule("position/position_val.php", data);
	}
}
function insertPosition(){registerPosition(0)}
function modifyPosition(){registerPosition(1)}

function validate_hddnPositionId(){
	if (document.getElementById("hddnPositionId") != null) hddnPositionId=document.getElementById("hddnPositionId").value;}
function validate_edtPositionTitle(){edtPositionTitle=validateRequiredText("edtPositionTitle", "This field is required.");}
function validate_edtPositionDesc(){edtPositionDesc=validateRequiredText("edtPositionDesc", "This field is required.");}
function validate_selAccessId(){selAccessId=validateRequiredSelection("selAccessId", "Please make a valid selection.");}

function viewPosition(id)
{
	var data = {}
	data.dummy = "";
	data.hddnPositionId = id;
	data.action = 2;
	callModule("position/position_val.php", data);
}

function editPosition(id)
{
	var data = {}
	data.dummy = "";
	data.hddnPositionId = id;
	data.action = 3;
	callModule("position/position_val.php", data);
}

function deletePosition(id, desc)
{
	if (confirm("Are you sure you want to delete "+desc+" and all associated records?"))
	{
		var data = {}
		data.dummy = "";
		data.hddnPositionId = id;
		data.action = 4;
		callModule("position/position_val.php", data);
	}
}
