var errors, hddnAuditId, edtItemId, edtAuditDesc, edtAuditCode, selUserCode, edtAuditTime, edtIpAddress;
var module = baseRootURL + "audit/";

function registerAudit(action)
{
	errors = false;
	validate_hddnAuditId();
	validate_edtItemId();
	validate_edtAuditDesc();
	validate_edtAuditCode();
	validate_selUserCode();
	validate_edtAuditTime();
	validate_edtIpAddress();
	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("hddnAuditId") != null) data.hddnAuditId = hddnAuditId;
		data.edtItemId = edtItemId;
		data.edtAuditDesc = edtAuditDesc;
		data.edtAuditCode = edtAuditCode;
		data.selUserCode = selUserCode;
		data.edtAuditTime = edtAuditTime;
		data.edtIpAddress = edtIpAddress;
		callModule("audit/audit_val.php", data);
	}
}
function insertAudit(){registerAudit(0)}
function modifyAudit(){registerAudit(1)}

function validate_hddnAuditId(){
	if (document.getElementById("hddnAuditId") != null) hddnAuditId=document.getElementById("hddnAuditId").value;}
function validate_edtItemId(){edtItemId=validateRequiredNumber("edtItemId", "Please enter a valid numeric value.");}
function validate_edtAuditDesc(){edtAuditDesc=validateRequiredText("edtAuditDesc", "This field is required.");}
function validate_edtAuditCode(){edtAuditCode=validateRequiredText("edtAuditCode", "This field is required.");}
function validate_selUserCode(){selUserCode=validateRequiredSelection("selUserCode", "Please make a valid selection.");}
function validate_edtAuditTime(){edtAuditTime=validateRequiredText("edtAuditTime", "This field is required.");}
function validate_edtIpAddress(){edtIpAddress=validateRequiredText("edtIpAddress", "This field is required.");}

function viewAudit(id)
{
	var data = {}
	data.dummy = "";
	data.hddnAuditId = id;
	data.action = 2;
	callModule("audit/audit_val.php", data);
}
