var errors, hddnAddressTypeId, edtAddressTypeName;
var module = baseRootURL + "address_type/";

function registerAddress_type(action)
{
	errors = false;
	validate_hddnAddressTypeId();
	validate_edtAddressTypeName();
	validate_selAddressTypeId();
    
	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("hddnAddressTypeId") != null) data.hddnAddressTypeId = hddnAddressTypeId;
		data.edtAddressTypeName = edtAddressTypeName;
		callModule("address_type/address_type_val.php", data);
	}
}
function insertAddress_type(){registerAddress_type(0)}
function modifyAddress_type(){registerAddress_type(1)}

function validate_hddnAddressTypeId(){
	if (document.getElementById("hddnAddressTypeId") != null) hddnAddressTypeId=document.getElementById("hddnAddressTypeId").value;}
function validate_edtAddressTypeName(){edtAddressTypeName=validateRequiredText("edtAddressTypeName", "Address Type Name is required.");}
function validate_selAddressTypeId(){selAreaId=validateRequiredSelection("selAddressTypeId", "Please make a valid selection.");}


function viewAddress_type(id)
{
	var data = {}
	data.dummy = "";
	data.hddnAddressTypeId = id;
	data.action = 2;
	callModule("address_type/address_type_val.php", data);
}

function editAddress_type(id)
{
	var data = {}
	data.dummy = "";
	data.hddnAddressTypeId = id;
	data.action = 3;
	callModule("address_type/address_type_val.php", data);
}

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

function setAddressTypeName()
{
	"use strict"; 
	var sel = document.getElementById('selAddressTypeId');
	document.getElementById('edtAddressTypeName').value = sel.options[sel.selectedIndex].innerHTML;
}