var errors, hddnTxnTypeId, edtTxnTypeName, cbTxnDebit;
var module = baseRootURL + "transaction_type/";

function registerTransactionType(action)
{
	errors = false;
	validate_hddnTxnTypeId();
	validate_edtTxnTypeName();
	validate_cbTxnDebit();
	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;
		data.hddnTxnTypeId = hddnTxnTypeId;
		if (document.getElementById("edtTxnTypeName") != null) data.edtTxnTypeName = edtTxnTypeName;
		data.cbTxnDebit = cbTxnDebit;
		callModule("transaction_type/transaction_type_val.php", data);
	}
}
function insertTransactionType(){registerTransactionType(0)}
function modifyTransactionType(){registerTransactionType(1)}

function validate_hddnTxnTypeId(){
	if (document.getElementById("hddnTxnTypeId") != null) hddnTxnTypeId=document.getElementById("hddnTxnTypeId").value;}
function validate_edtTxnTypeName(){edtTxnTypeName=validateRequiredText("edtTxnTypeName", "This field is required.");}
function validate_cbTxnDebit(){cbTxnDebit = document.getElementById("cbTxnDebit").checked;}

function viewTransactionType(id)
{
	var data = {}
	data.dummy = "";
	data.edtTxnTypeName = id;
	data.action = 2;
	callModule("transaction_type/transaction_type_val.php", data);
}

function editTransactionType(id)
{
	var data = {}
	data.dummy = "";
	data.edtTxnTypeName = id;
	data.action = 3;
	callModule("transaction_type/transaction_type_val.php", data);
}

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