var errors, hddnPmId, edtPmName;
var module = baseRootURL + "payment_method/";

function registerPaymentMethod(action)
{
	errors = false;
	validate_hddnPmId();
	validate_edtPmName();
	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("hddnPmId") != null) data.hddnPmId = hddnPmId;
		data.edtPmName = edtPmName;
		callModule("payment_method/payment_method_val.php", data);
	}
}
function insertPaymentMethod(){registerPaymentMethod(0)}
function modifyPaymentMethod(){registerPaymentMethod(1)}

function validate_hddnPmId(){
	if (document.getElementById("hddnPmId") != null) hddnPmId=document.getElementById("hddnPmId").value;}
function validate_edtPmName(){edtPmName=validateRequiredText("edtPmName", "This field is required.");}

function viewPaymentMethod(id)
{
	var data = {}
	data.dummy = "";
	data.hddnPmId = id;
	data.action = 2;
	callModule("payment_method/payment_method_val.php", data);
}

function editPaymentMethod(id)
{
	var data = {}
	data.dummy = "";
	data.hddnPmId = id;
	data.action = 3;
	callModule("payment_method/payment_method_val.php", data);
}

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