var errors, hddnAccessId, edtAccessName, edtAccessLevel;
var module = baseRootURL + "access/";


function registerAccess(action)
{
	errors = false;
	validate_hddnAccessId();
	validate_edtAccessName();
	validate_edtAccessLevel();
	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("hddnAccessId") != null) data.hddnAccessId = hddnAccessId;
		data.edtAccessName = edtAccessName;
		data.edtAccessLevel = edtAccessLevel;
		callModule("access/access_val.php", data);
	}
}

function insertAccess(){registerAccess(0)}

function modifyAccess(){registerAccess(1)}

function validate_hddnAccessId(){if (document.getElementById("hddnAccessId") != null) hddnAccessId=document.getElementById("hddnAccessId").value;}
function validate_edtAccessName(){edtAccessName=validateRequiredText("edtAccessName", "This field is required.");}
function validate_edtAccessLevel(){edtAccessLevel=validateRequiredText("edtAccessLevel", "This field is required.");}

function viewAccess(id)
{
	var data = {}
	data.dummy = "";
	data.hddnAccessId = id;
	data.action = 2;
	callModule("access/access_val.php", data);
}

function editAccess(id)
{
	var data = {}
	data.dummy = "";
	data.hddnAccessId = id;
	data.action = 3;
	callModule("access/access_val.php", data);
}

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

function copyAccess(id, desc)
{
	if (confirm("Are you sure you want to duplicate "+desc+"?"))
	{
	var data = {}
	data.dummy = "";
	data.hddnAccessId = id;
	data.action = 5;
	callModule("access/access_val.php", data);
	}
}
