/* Version 1.
This file contains a standard set of javascript validation functions. */

/* This function validates the site search facility. */
function validate_site_search(search)
{
	if(search.value==''||search.value==' '||search.value=='Keyword')
	{
		alert('Please enter a search Keyword before clicking on the Search button.');
		search.focus();
		return(false);
	}
	else
	{
		return(true);
	}
}

/* This function validates the contact us facility. It uses the following logic. If the user has chosen, join the database over the phone, 
their name and phone number is also required. If the user has chosen, be sent a form in the post, their name and address is also required. 
If the user has chosen niether, join the database over the phone, or be sent a form in the post, then no validation is required. */
function validate_contact_us(body_subject,name,address,telephone_number)
{
	var name_alert,address_alert,telephone_number_alert;

	name_alert='';
	address_alert='';
	telephone_number_alert='';

	if(name.value==''||name.value==' ')
	{
		name_alert='\n*Your name';
	}
	if(address.value==''||address.value==' ')
	{
		address_alert='\n*Your address';
	}
	if(telephone_number.value==''||telephone_number.value==' ')
	{
		telephone_number_alert='\n*Your telephone number';
	}
	if(body_subject.value=='Join the database over the phone'&&(name_alert!=''||telephone_number_alert!=''))
	{
		alert('Please enter:\n'+name_alert+telephone_number_alert+'\n\nbefore clicking on the Send button.');
		if (name_alert!='')
		{
			name.focus();
		}
		else
		{
			telephone_number.focus();
		}
			return(false);
		}
	else if(body_subject.value=='Be sent a data collection form in the post'&&(name_alert!=''||address_alert!=''))
	{
		alert('Please enter:\n'+name_alert+address_alert+'\n\nbefore clicking on the Send button.');
		if (name_alert!='')
		{
			name.focus();
		}
			else
		{
			address.focus();
		}
			return(false);
		}
	return(true);
}