function checkForm()
{
	f = document.form;
	if (f.model.selectedIndex == 0)
	{
		alert("Please select a model");
		f.model.focus();
		return false;
	}
	if (f.no_fleet.checked == false)
	{
		if (f.fleet_size.selectedIndex == 0)
		{
			alert("Please select a fleet size");
			f.fleet_size.focus();
			return false;
		}
		if (f.fleet_policy.selectedIndex == 0)
		{
			alert("Please select your current fleet policy");
			f.fleet_policy.focus();
			return false;
		}
		if (f.fleet_method.selectedIndex == 0)
		{
			alert("Please select your method of purchase");
			f.fleet_method.focus();
			return false;
		}
	}
	if ((f.title.selectedIndex==0)||(f.firstname.value=='')||(f.surname.value==''))
	{
		alert("Please enter your full name");
		f.title.focus();
		return false;
	}
	if (f.job_title.selectedIndex==0)
	{
		alert("Please select your job title");
		f.job_title.focus();
		return false;
	}
	if (f.company_name.value=='')
	{
		alert("Please enter your company name");
		f.company_name.focus();
		return false;
	}
	if ((f.address_1.value=='')||(f.postcode.value==''))
	{
		alert("Please enter your address and postcode");
		f.address_1.focus();
		return false;
	}
	if (f.contact_method.selectedIndex == 0)
	{
		alert("Please select a contact method");
		f.contact_method.focus();
		return false;
	}
	if (f.contact_method.selectedIndex == 1)
	{
		if (f.tel_home.value=='' && f.tel_work.value=='' && f.tel_mobile.value=='')
		{
			alert("Please enter an telephone number");
			f.tel_home.focus();
			return false;
		}
		if (f.contact_time.selectedIndex ==0)
		{
			alert("Please select a preferred contact time");
			f.contact_time.focus();
			return false;
		}
	}
	if (f.contact_method.selectedIndex == 2)
	{
		if (f.email_home.value=='' && f.email_work.value=='')
		{
			alert("Please enter an email address");
			f.email_home.focus();
			return false;
		}
		if (f.email_home.value != '')
		{
			emailcheck = emailCheck(f.email_home.value);
			if (emailcheck==1)
			{
				alert("Sorry, you must provide a real home email address!");
				return false;
			}
		}
		if (f.email_work.value != '')
		{
			emailcheck = emailCheck(f.email_work.value);
			if (emailcheck==1)
			{
				alert("Sorry, you must provide a real work email address!");
				return false;
			}
		}
	}
	if (f.contact_method.selectedIndex == 3)
	{
		if (f.tel_mobile.value=='')
		{
			alert("Please enter a mobile number");
			f.tel_home.focus();
			return false;
		}
	}
	if (f.no_information.checked == false && (f.by_email.checked == false && f.by_sms.checked == false))
	{
		alert("Please complete section 2 of the Data Protection section");
		return false;
	}
}

function emailCheck(email)
{
	var supported = 0;
	if (window.RegExp)
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr))
			supported = 1;
	}
	if (!supported) 
		return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	if ((!r1.test(email)==true)&&(r2.test(email)==false))
		return 1;
}

function disableContact()
{
	f = document.form;
	if (f.no_information.checked==true)
	{
		f.by_email.checked=false;
		f.by_email.disabled=true;
		f.by_sms.checked=false;
		f.by_sms.disabled=true;
	}
	else
	{
		f.by_email.disabled=false;
		f.by_sms.disabled=false;
	}
}