var errors, hddnAreaTypeId, edtAreaTypeName;
var module = baseRootURL + "area_type/";

function registerAreaType(action)
{
	errors = false;
	validate_hddnAreaTypeId();
	validate_edtAreaTypeName();
	validate_selAreaTypeId();
    
	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("hddnAreaTypeId") != null) data.hddnAreaTypeId = hddnAreaTypeId;
		data.edtAreaTypeName = edtAreaTypeName;
		callModule("area_type/area_type_val.php", data);
	}
}
function insertAreaType(){registerAreaType(0)}
function modifyAreaType(){registerAreaType(1)}

function validate_hddnAreaTypeId(){
	if (document.getElementById("hddnAreaTypeId") != null) hddnAreaTypeId=document.getElementById("hddnAreaTypeId").value;}
function validate_edtAreaTypeName(){edtAreaTypeName=validateRequiredText("edtAreaTypeName", "This field is required.");}
function validate_selAreaTypeId(){selAreaId=validateRequiredSelection("selAreaTypeId", "Please make a valid selection.");}

function viewAreaType(id)
{
	var data = {}
	data.dummy = "";
	data.hddnAreaTypeId = id;
	data.action = 2;
	callModule("area_type/area_type_val.php", data);
}

function editAreaType(id)
{
	var data = {}
	data.dummy = "";
	data.hddnAreaTypeId = id;
	data.action = 3;
	callModule("area_type/area_type_val.php", data);
}

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