function setFocus(fieldIdfr) {
	userForm = document.getElementById('bookingForm');
	switch (fieldIdfr) {
		case 1:
			userForm.holiday.focus();
			break;
		case 2:
			userForm.cottage.focus();
			break;
		case 3:
			userForm.day.focus();
			break;
		case 4:
			userForm.nights.focus();
			break;
		case 5:
			userForm.title.focus();
			break;
		case 6:
			userForm.initial.focus();
			break;
		case 7:
			userForm.surname.focus();
			break;
		case 8:
			userForm.addr1.focus();
			break;
		case 9:
			userForm.addr2.focus();
			break;
		case 10:
			userForm.city.focus();
			break;
		case 11:
			userForm.county.focus();
			break;
		case 12:
			userForm.postcode.focus();
			break;
		case 13:
			userForm.country.focus();
			break;
		case 14:
			userForm.email.focus();
			break;
		case 15:
			userForm.teleD.focus();
			break;
		case 16:
			userForm.teleE.focus();
			break;
		case 17:
			userForm.teleM.focus();
			break;
		case 18:
			userForm.cot.focus();
			break;
		case 19:
			userForm.highchair.focus();
			break;
		case 20:
			userForm.dog.focus();
			break;
		case 21:
			userForm.heard.focus();
			break;
		case 22:
			userForm.terms.focus();
			break;
		default:
			userForm.holiday.focus();
			break;
	}
}

function restoreCottages(thisForm, cottage_id) {
	while (thisForm.cottage.options.length) // Remove all existing SELECT OPTIONS
		thisForm.cottage.options[0] = null;
	thisForm.cottage.options[0] = new Option("The Butler's Pantry", 1, (cottage_id == 1), (cottage_id == 1));
	thisForm.cottage.options[1] = new Option("The Old Pump House", 2, (cottage_id == 2), (cottage_id == 2));
	thisForm.cottage.options[2] = new Option("Sam's Stable", 3, (cottage_id == 3), (cottage_id == 3));
	thisForm.cottage.options[3] = new Option("The Old Coach House", 4, (cottage_id == 4), (cottage_id == 4));
}

function holidayChange(cottage_id) {
	cottage_id = parseInt(cottage_id, 10);
	var thisForm = document.getElementById('bookingForm');
	var holidaySelected = thisForm.holiday.value;
	//alert(holidaySelected);
	switch (holidaySelected) {
		case 'week':
			thisForm.nights.value = 7;
			restoreCottages(thisForm, cottage_id);
			break;
		case 'fortnight':
			thisForm.nights.value = 14;
			restoreCottages(thisForm, cottage_id);
			break;
		case 'other':
			restoreCottages(thisForm, cottage_id);
			break;
		default:
			var specDate = 's' + holidaySelected + 'd';
			var specNights = 's' + holidaySelected + 'n';
			var specCottages = 's' + holidaySelected + 'c';
			eval("var thisDate = thisForm." + specDate + ".value;");
			eval("var thisNights = thisForm." + specNights + ".value;");
			eval("var thisCottages = thisForm." + specCottages + ".value;");
			thisForm.day.value = parseInt(thisDate.substr(8, 2), 10);
			thisForm.month.value = parseInt(thisDate.substr(5, 2), 10);
			thisForm.year.value = parseInt(thisDate.substr(0, 4), 10);
			thisForm.nights.value = parseInt(thisNights, 10);
			while (thisForm.cottage.options.length) // Remove all existing SELECT OPTIONS
				thisForm.cottage.options[0] = null;
			var i = 0;
			if (thisCottages.substr(0, 1) == 'Y')
				thisForm.cottage.options[i++] = new Option("The Butler's Pantry", 1, (cottage_id == 1), (cottage_id == 1));
			if (thisCottages.substr(1, 1) == 'Y')
				thisForm.cottage.options[i++] = new Option("The Old Pump House", 2, (cottage_id == 2), (cottage_id == 2));
			if (thisCottages.substr(2, 1) == 'Y')
				thisForm.cottage.options[i++] = new Option("Sam's Stable", 3, (cottage_id == 3), (cottage_id == 3));
			if (thisCottages.substr(3, 1) == 'Y')
				thisForm.cottage.options[i++] = new Option("The Old Coach House", 4, (cottage_id == 4), (cottage_id == 4));	
			break;
	}
}