// JavaScript for Erw Gerrig holiday cottages

// requires 'met-util.js' to be loaded.

//---------------------------------------------------------------------------

(function (libname) { // name of utility library - see end
//---------------------------------------------------------------------------

// update links of certain classes to open in a new window.
function checkData() 
{
	var correct = true;
	var o_form = document.getElementById('paform');

	// if we can't get the form, don't prevent it being submitted:
	if (!o_form)
		return correct;

	if (o_form.name && o_form.name.value == "") 
	{
		correct = false; 
		alert("Please tell us your name");
	}
	if (o_form.email && o_form.email.value == "") 
	{
		correct = false; 
		alert("Please tell us your email address");
	}
	if (o_form.how && o_form.how.value == "") 
	{
		correct = false; 
		alert("Please tell us how you found us");
	}
	if (o_form.any_smokers_value && o_form.any_smokers.value == "Yes/No") 
	{
		correct = false; 
		alert("Please tell us if there are any smokers in your party");
	}

	return correct
}
//---------------------------------------------------------------------------

// add form checking
function addFormChecking(id_form)
{
	var o_form = document.getElementById(id_form);

	if (o_form)
		o_form.onsubmit = checkData;
}
//---------------------------------------------------------------------------

// Code to execute
	if (!window[libname])
		return alert('Warning: library \'' + libname + ' not loaded.');

	var lib = window[libname];

	if (!lib.isSupported())
		return false;

	lib.addLoadEvent(function () { addFormChecking('paform') });

//---------------------------------------------------------------------------
})('MET'); // library name - execute immediately
//---------------------------------------------------------------------------

// end of scripts