function formLocations(opt)
{
	switch(opt)
	{
		case 1: //Airport to town
			document.getElementById('ariport_from').style.display='block';
			document.getElementById('ariport_to').style.display='none';
			document.getElementById('postcode_from').style.display='none';
			document.getElementById('postcode_to').style.display='block';
		break;

		case 2: //Town to airport
			document.getElementById('ariport_from').style.display='none';
			document.getElementById('ariport_to').style.display='block';
			document.getElementById('postcode_from').style.display='block';
			document.getElementById('postcode_to').style.display='none';
		break;

		case 3: //Airport to airport
			document.getElementById('ariport_from').style.display='block';
			document.getElementById('ariport_to').style.display='block';
			document.getElementById('postcode_from').style.display='none';
			document.getElementById('postcode_to').style.display='none';
		break;

		case 4: //Town to town
			document.getElementById('ariport_from').style.display='none';
			document.getElementById('ariport_to').style.display='none';
			document.getElementById('postcode_from').style.display='block';
			document.getElementById('postcode_to').style.display='block';
		break;
	}
}

function validate()
{
	var errors = '';
	
	if(!document.f.name.value){errors+= "= Enter your name\n";}
	if(!document.f.surname.value){errors+= "= Enter your surname\n";}
	if(!document.f.phone.value){errors+= "= Enter your phone\n";}
	if(!document.f.email.value){errors+= "= Enter your email\n";}
	
	//------------
	if(errors) errors = errors + "\n";
	
	var from = document.getElementById('from_town_select').checked ? 'town' : 'airport';
	
	if(from == 'airport')
	{
		if(!document.getElementById('from_airport_name').value) {errors+= "= Select an airport (From)\n";}
		if(!document.f.from_airport_flight.value){errors+= "= Enter the full flight number\n";}
		if(!document.f.from_airport_depature_city.value){errors+= "= Enter the depature city\n";}
		if(
			!document.getElementById('from_airport_time_day').value || 
			!document.getElementById('from_airport_time_month').value || 
			!document.getElementById('from_airport_time_year').value
		) {errors+= "= Enter the date of arrival\n";}
		if(
			!document.getElementById('from_airport_time_hour').value || 
			!document.getElementById('from_airport_time_min').value
		) {errors+= "= Enter the time of arrival\n";}		
	}
	else
	{
		if(!document.f.from_town_name.value){errors+= "= Enter the London suburb (From)\n";}
		if(!document.f.from_town_address.value){errors+= "= Enter the full address (From)\n";}
		if(!document.f.from_town_postcode.value){errors+= "= Enter the postcode (From)\n";}
		if(
			!document.getElementById('from_town_time_day').value || 
			!document.getElementById('from_town_time_month').value || 
			!document.getElementById('from_town_time_year').value
		) {errors+= "= Enter the pickup date\n";}
		if(
			!document.getElementById('from_town_time_hour').value || 
			!document.getElementById('from_town_time_min').value
		) {errors+= "= Enter the pick up time\n";}			
	}
	
	
	//------------
	if(errors) errors = errors + "\n";
	
	var to = document.getElementById('to_airport_select').checked ? 'airport' : 'town';
	if(to == 'airport')
	{
		if(!document.getElementById('to_airport_name').value) {errors+= "= Select an airport (To)\n";}
		if(!document.f.to_airport_details.value){errors+= "= Enter the Drop Off details - hotel name, flight number, etc...\n";}
	}
	else
	{
		if(!document.f.to_town_name.value){errors+= "= Enter the London suburb (To)\n";}
		if(!document.f.to_town_address.value){errors+= "= Enter the full address (To)\n";}
		if(!document.f.to_town_postcode.value){errors+= "= Enter the postcode (To)\n";}		
	}
	
	//------------
	if(errors) errors = errors + "\n";
	
	if(
		!document.getElementById('vehicle_saloon').checked && 
		!document.getElementById('vehicle_estate').checked && 
		!document.getElementById('vehicle_mpv').checked && 
		!document.getElementById('vehicle_seater').checked
	)
	{
		{errors+= "= Choose a vehicle type\n";}
	}
	
	if(!document.f.num_passengers.value){errors+= "= Enter the number of passengers\n";}
	if(!document.f.num_luggage.value){errors+= "= Enter the number of luggage\n";}
	
	
	
	if(errors)
	{
		alert(errors);
		return false;
	}
	return true;
}

function generateCode(){
	var code = '';
	var f_name = document.getElementById('name').value;
	var l_name = document.getElementById('surname').value;
	var tel = document.getElementById('phone').value;
	var email = document.getElementById('email').value;
	code = f_name.substr(0, 2)+l_name.substr(0, 2)+tel.substr(0, 2)+email.substr(0, 2);
	document.getElementById('generatedCode').value = code;
}