function checkHomeSearch()
{
	errortext = "Please do the following before continuing...\n";
	errorcheck = 0;
	f = document.form;
	c = f.city.length;

	checkcity = 0;
	for (i=0; i<c; i++)
	{
		if (f.city[i].checked==true)
			checkcity = 1;
	}
	if (checkcity==0)
	{
		errortext = errortext + "- Select a city\n";
		errorcheck = 1;
	}
	checkdate = 0;
	checkdate = validDate(f.arrivedate.options[f.arrivedate.selectedIndex].value, f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a valid arrival date\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = checkArrivalDate();
	if (checkdate<0)
	{
		errortext = errortext + "- Enter a valid arrival date\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = compareDates();
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a departure date that is after the arrival date\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	checkdate = 0;
	checkdate = validDate(f.departdate.options[f.departdate.selectedIndex].value, f.departdate2.options[f.departdate2.selectedIndex].value);
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a valid departure date\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	if (f.nights.options[f.nights.selectedIndex].value>20)
	{
		errortext = errortext + "- Please select a shorter period or tel. 08700 550 550 - or +44 1872 261 100\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	roomnum = f.rooms.options[f.rooms.selectedIndex].value;
	for (i=1; i<=roomnum; i++)
	{
		if (f['roomtype'+i].selectedIndex==0)
		{
			errortext = errortext + "- Select a room type for room " + i +"\n";
			errorcheck = 1;
		}
	}
	r1 = f.roomtype1.options[f.roomtype1.selectedIndex].value;
	r2 = f.roomtype2.options[f.roomtype2.selectedIndex].value;
	r3 = f.roomtype3.options[f.roomtype3.selectedIndex].value;
	r4 = f.roomtype4.options[f.roomtype4.selectedIndex].value;
	r5 = f.roomtype5.options[f.roomtype5.selectedIndex].value;
	kids = f.kidsage.value;
	if ((kids=='' || kids=='0') && ((r1.indexOf('family1')>-1) || (r2.indexOf('family1')>-1) || (r3.indexOf('family1')>-1) || (r4.indexOf('family1')>-1) || (r5.indexOf('family1')>-1) || (r1.indexOf('family2')>-1) || (r2.indexOf('family2')>-1) || (r3.indexOf('family2')>-1) || (r4.indexOf('family2')>-1) || (r5.indexOf('family2')>-1)))
	{
		errortext = errortext + "- Please enter the child age(s)\n";
		errorcheck = 1;
	}
	if ((kids!='' || kids!='0') && ((r1.indexOf('family1')==-1) && (r2.indexOf('family1')==-1) && (r3.indexOf('family1')==-1) && (r4.indexOf('family1')==-1) && (r5.indexOf('family1')==-1) && (r1.indexOf('family2')==-1) && (r2.indexOf('family2')==-1) && (r3.indexOf('family2')==-1) && (r4.indexOf('family2')==-1) && (r5.indexOf('family2')==-1)))
	{
		f.kidsage.value='';
	}
	if ((kids!='' && kids!='0') && ((r1.indexOf('family1')>-1) || (r2.indexOf('family1')>-1) || (r3.indexOf('family1')>-1) || (r4.indexOf('family1')>-1) || (r5.indexOf('family1')>-1) || (r1.indexOf('family2')>-1) || (r2.indexOf('family2')>-1) || (r3.indexOf('family2')>-1) || (r4.indexOf('family2')>-1) || (r5.indexOf('family2')>-1)))
	{
		var totalchildren=0,childrenfound=1;
		if (r1.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r2.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r3.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r4.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r5.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r1.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r2.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r3.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r4.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r5.indexOf('family2')>-1) totalchildren=totalchildren+2;
		//if (r1.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r2.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r3.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r4.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r5.indexOf('family3')>-1) totalchildren=totalchildren+3;

		var valid = "0123456789,";
		ok = 1;
		var temp;
		for (var i=0; i<kids.length; i++)
		{
			temp = "" + kids.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
				ok = 0;
			if (temp==',') childrenfound++;
		}
		if (ok==0)
		{
  		   errortext = errortext + "- Please enter only numbers, separated by commas if applicable (no spaces)\n";
		   errorcheck = 1;
                }
		else if (childrenfound>totalchildren)
		{
  		   if (totalchildren==1) errortext = errortext + "- Please enter ages only for 1 child\n";
		   else errortext = errortext + "- Please enter ages only for "+totalchildren+", separated by commas if applicable (no spaces)\n";
		   errorcheck = 1;
		}
	}
	if (errorcheck==1)
	{
		alert(errortext);
		return false;
	}
	f.arrivemonth.value = getMonthValue(f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	f.arriveyear.value = getYearValue(f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	f.departmonth.value = getMonthValue(f.departdate2.options[f.departdate2.selectedIndex].value);
	f.departyear.value = getYearValue(f.departdate2.options[f.departdate2.selectedIndex].value);
	populateRooms();
	setGuests(2);
	setCookieDates();
}

function checkSmallSearch()
{
	errortext = "Please do the following before continuing...\n";
	errorcheck = 0;
	f = document.form;
	c = f.city.length;

	checkcity = 0;
	for (i=0; i<c; i++)
	{
		if (f.city[i].checked==true)
			checkcity = 1;
	}
	if (checkcity==0)
	{
		errortext = errortext + "- Select a city\n";
		errorcheck = 1;
	}
	checkdate = 0;
	checkdate = validDate(f.arrivedate.options[f.arrivedate.selectedIndex].value, f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a valid arrival date\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = checkArrivalDate();
	if (checkdate<0)
	{
		errortext = errortext + "- Enter a valid arrival date\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = compareDates();
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a departure date that is after the arrival date\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	checkdate = 0;
	checkdate = validDate(f.departdate.options[f.departdate.selectedIndex].value, f.departdate2.options[f.departdate2.selectedIndex].value);
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a valid departure date\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	if (f.nights.options[f.nights.selectedIndex].value>20)
	{
		errortext = errortext + "- Please select a shorter period or tel. 08700 550 550 - or +44 1872 261 100\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	roomnum = f.rooms.options[f.rooms.selectedIndex].value;
	for (i=1; i<=roomnum; i++)
	{
		if (f['roomtype'+i].selectedIndex==0)
		{
			errortext = errortext + "- Select a room type for room " + i +"\n";
			errorcheck = 1;
		}
	}
	r1 = f.roomtype1.options[f.roomtype1.selectedIndex].value;
	r2 = f.roomtype2.options[f.roomtype2.selectedIndex].value;
	r3 = f.roomtype3.options[f.roomtype3.selectedIndex].value;
	r4 = f.roomtype4.options[f.roomtype4.selectedIndex].value;
	r5 = f.roomtype5.options[f.roomtype5.selectedIndex].value;
	kids = f.kidsage.value;
	if ((kids=='' || kids=='0') && ((r1.indexOf('family1')>-1) || (r2.indexOf('family1')>-1) || (r3.indexOf('family1')>-1) || (r4.indexOf('family1')>-1) || (r5.indexOf('family1')>-1) || (r1.indexOf('family2')>-1) || (r2.indexOf('family2')>-1) || (r3.indexOf('family2')>-1) || (r4.indexOf('family2')>-1) || (r5.indexOf('family2')>-1)))
	{
		errortext = errortext + "- Please enter the child age(s)\n";
		errorcheck = 1;
	}
	if ((kids!='' || kids!='0') && ((r1.indexOf('family1')==-1) && (r2.indexOf('family1')==-1) && (r3.indexOf('family1')==-1) && (r4.indexOf('family1')==-1) && (r5.indexOf('family1')==-1) && (r1.indexOf('family2')==-1) && (r2.indexOf('family2')==-1) && (r3.indexOf('family2')==-1) && (r4.indexOf('family2')==-1) && (r5.indexOf('family2')==-1)))
	{
		f.kidsage.value='';
	}
	if ((kids!='' && kids!='0') && ((r1.indexOf('family1')>-1) || (r2.indexOf('family1')>-1) || (r3.indexOf('family1')>-1) || (r4.indexOf('family1')>-1) || (r5.indexOf('family1')>-1) || (r1.indexOf('family2')>-1) || (r2.indexOf('family2')>-1) || (r3.indexOf('family2')>-1) || (r4.indexOf('family2')>-1) || (r5.indexOf('family2')>-1)))
	{
		var totalchildren=0,childrenfound=1;
		if (r1.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r2.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r3.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r4.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r5.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r1.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r2.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r3.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r4.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r5.indexOf('family2')>-1) totalchildren=totalchildren+2;
		//if (r1.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r2.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r3.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r4.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r5.indexOf('family3')>-1) totalchildren=totalchildren+3;

		var valid = "0123456789,";
		ok = 1;
		var temp;
		for (var i=0; i<kids.length; i++)
		{
			temp = "" + kids.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
				ok = 0;
			if (temp==',') childrenfound++;
		}
		if (ok==0)
		{
  		   errortext = errortext + "- Please enter only numbers, separated by commas if applicable (no spaces)\n";
		   errorcheck = 1;
                }
		else if (childrenfound>totalchildren)
		{
  		   if (totalchildren==1) errortext = errortext + "- Please enter ages only for 1 child\n";
		   else errortext = errortext + "- Please enter ages only for "+totalchildren+", separated by commas if applicable (no spaces)\n";
		   errorcheck = 1;
		}
	}
	if (errorcheck==1)
	{
		alert(errortext);
		return false;
	}
	f.arrivemonth.value = getMonthValue(f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	f.arriveyear.value = getYearValue(f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	f.departmonth.value = getMonthValue(f.departdate2.options[f.departdate2.selectedIndex].value);
	f.departyear.value = getYearValue(f.departdate2.options[f.departdate2.selectedIndex].value);
	populateRooms();
	setGuests(2);
	setCookieDates();
	window.close();
}

function checkCitySearch()
{
	errortext = "Please do the following before continuing...\n";
	errorcheck = 0;
	f = document.form;
	checkdate = 0;
	checkdate = validDate(f.arrivedate.options[f.arrivedate.selectedIndex].value, f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a valid arrival date\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = checkArrivalDate();
	if (checkdate<0)
	{
		errortext = errortext + "- Enter a valid arrival date\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = compareDates();
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a departure date that is after the arrival date\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	checkdate = 0;
	checkdate = validDate(f.departdate.options[f.departdate.selectedIndex].value, f.departdate2.options[f.departdate2.selectedIndex].value);
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a valid departure date\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	if (f.nights.options[f.nights.selectedIndex].value>20)
	{
		errortext = errortext + "- Please select a shorter period or tel. 08700 550 550 - or +44 1872 261 100\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	roomnum = f.rooms.options[f.rooms.selectedIndex].value;
	for (i=1; i<=roomnum; i++)
	{
		if (f['roomtype'+i].selectedIndex==0)
		{
			errortext = errortext + "- Select a room type for room " + i +"\n";
			errorcheck = 1;
		}
	}
	r1 = f.roomtype1.options[f.roomtype1.selectedIndex].value;
	r2 = f.roomtype2.options[f.roomtype2.selectedIndex].value;
	r3 = f.roomtype3.options[f.roomtype3.selectedIndex].value;
	r4 = f.roomtype4.options[f.roomtype4.selectedIndex].value;
	r5 = f.roomtype5.options[f.roomtype5.selectedIndex].value;
	kids = f.kidsage.value;
	if ((kids=='' || kids=='0') && ((r1.indexOf('family1')>-1) || (r2.indexOf('family1')>-1) || (r3.indexOf('family1')>-1) || (r4.indexOf('family1')>-1) || (r5.indexOf('family1')>-1) || (r1.indexOf('family2')>-1) || (r2.indexOf('family2')>-1) || (r3.indexOf('family2')>-1) || (r4.indexOf('family2')>-1) || (r5.indexOf('family2')>-1)))
	{
		errortext = errortext + "- Please enter the child age(s)\n";
		errorcheck = 1;
	}
	if ((kids!='' || kids!='0') && ((r1.indexOf('family1')==-1) && (r2.indexOf('family1')==-1) && (r3.indexOf('family1')==-1) && (r4.indexOf('family1')==-1) && (r5.indexOf('family1')==-1) && (r1.indexOf('family2')==-1) && (r2.indexOf('family2')==-1) && (r3.indexOf('family2')==-1) && (r4.indexOf('family2')==-1) && (r5.indexOf('family2')==-1)))

	{
		f.kidsage.value='';
	}
	if ((kids!='' && kids!='0') && ((r1.indexOf('family1')>-1) || (r2.indexOf('family1')>-1) || (r3.indexOf('family1')>-1) || (r4.indexOf('family1')>-1) || (r5.indexOf('family1')>-1) || (r1.indexOf('family2')>-1) || (r2.indexOf('family2')>-1) || (r3.indexOf('family2')>-1) || (r4.indexOf('family2')>-1) || (r5.indexOf('family2')>-1)))
	{
		var totalchildren=0,childrenfound=1;
		if (r1.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r2.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r3.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r4.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r5.indexOf('family1')>-1) totalchildren=totalchildren+1;
		if (r1.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r2.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r3.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r4.indexOf('family2')>-1) totalchildren=totalchildren+2;
		if (r5.indexOf('family2')>-1) totalchildren=totalchildren+2;
		//if (r1.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r2.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r3.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r4.indexOf('family3')>-1) totalchildren=totalchildren+3;
		//if (r5.indexOf('family3')>-1) totalchildren=totalchildren+3;

		var valid = "0123456789,";
		ok = 1;
		var temp;
		for (var i=0; i<kids.length; i++)
		{
			temp = "" + kids.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
				ok = 0;
			if (temp==',') childrenfound++;
		}
		if (ok==0)
		{
  		   errortext = errortext + "- Please enter only numbers, separated by commas if applicable (no spaces)\n";
		   errorcheck = 1;
                }
		else if (childrenfound>totalchildren)
		{
  		   if (totalchildren==1) errortext = errortext + "- Please enter the age of 1 child only\n";
		   else errortext = errortext + "- Please enter ages only for "+totalchildren+" children, separated by commas if applicable (no spaces)\n";
		   errorcheck = 1;
		}
	}
	if (errorcheck==1)
	{
		alert(errortext);
		return false;
	}
	f.arrivemonth.value = getMonthValue(f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	f.arriveyear.value = getYearValue(f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	f.departmonth.value = getMonthValue(f.departdate2.options[f.departdate2.selectedIndex].value);
	f.departyear.value = getYearValue(f.departdate2.options[f.departdate2.selectedIndex].value);
	populateRooms();
	setGuests(2);
	setCookieDates();
}

function checkFreeSearch()
{
	errortext = "Please do the following before continuing...\n";
	errorcheck = 0;
	f = document.form;
	checkdate = 0;
	checkdate = validDate(f.arrivedate.options[f.arrivedate.selectedIndex].value, f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a valid arrival date\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = checkArrivalDate();
	if (checkdate<0)
	{
		errortext = errortext + "- Enter a valid arrival date\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = compareDates();
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a departure date that is after the arrival date\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	checkdate = 0;
	checkdate = validDate(f.departdate.options[f.departdate.selectedIndex].value, f.departdate2.options[f.departdate2.selectedIndex].value);
	if (checkdate==1)
	{
		errortext = errortext + "- Enter a valid departure date\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	if (f.nights.options[f.nights.selectedIndex].value>20)
	{
		errortext = errortext + "- Please select a shorter period or tel. 08700 550 550 - or +44 1872 261 100\n";
		errorcheck = 1;
		f.nights.selectedIndex = 0;
		f.nights.length = 20;
		setEndDate(f.nights.options[f.nights.selectedIndex].value);
	}
	if ((f.family1.selectedIndex==0)&&(f.family2.selectedIndex==0))
	{
		errortext = errortext + "- Select a room type\n";
		errorcheck = 1;
	}
	if ((f.children.value>0)&&(f.kidsage.value==''))
	{
		errortext = errortext + "- Please enter the age(s) of the children\n";
		errorcheck = 1;
	}
	if (errorcheck==1)
	{
		alert(errortext);
		return false;
	}
	f.arrivemonth.value = getMonthValue(f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	f.arriveyear.value = getYearValue(f.arrivedate2.options[f.arrivedate2.selectedIndex].value);
	f.departmonth.value = getMonthValue(f.departdate2.options[f.departdate2.selectedIndex].value);
	f.departyear.value = getYearValue(f.departdate2.options[f.departdate2.selectedIndex].value);
	setCookieDatesFree();
}

function checkReservation()
{
	blackText();
	errortext = "Please complete the following fields before continuing...\n";
	errorcheck = 0;
	f = document.form;

	if (f.title.selectedIndex==0)
	{
		errortext = errortext + "\t- Title\n";
		errorcheck = 1;
		document.getElementById('titleText').style.color = '#FF0000';
	}
	if (f.surname.value=='')
	{
		errortext = errortext + "\t- Full name\n";
		errorcheck = 1;
		document.getElementById('surnameText').style.color = '#FF0000';
		document.getElementById('firstnameText').style.color = '#FF0000';
	}
	if (f.address.value=='')
	{
		errortext = errortext + "\t- Address\n";
		errorcheck = 1;
		document.getElementById('addressText').style.color = '#FF0000';
	}
	//if (f.postcode.value=='')
	//{
		//errortext = errortext + "\t- Postcode\n";
		//errorcheck = 1;
		//document.getElementById('postcodeText').style.color = '#FF0000';
	//}
	if (f.country.selectedIndex==0)
	{
		errortext = errortext + "\t- Country\n";
		errorcheck = 1;
		document.getElementById('countryText').style.color = '#FF0000';
	}
	if ((f.telephoneam.value=='')&&(f.telephonepm.value==''))
	{
		errortext = errortext + "\t- Telephone number\n";
		errorcheck = 1;
		document.getElementById('teldayText').style.color = '#FF0000';
		document.getElementById('televeText').style.color = '#FF0000';
	}
	if (f.email.value=='')
	{
		errortext = errortext + "\t- Email address\n";
		errorcheck = 1;
		document.getElementById('emailText').style.color = '#FF0000';
	}
	if (f.email.value!=f.email2.value)
	{
		errortext = errortext + "\t- Correct email address\n";
		errorcheck = 1;
		document.getElementById('emailText').style.color = '#FF0000';
		document.getElementById('emailText2').style.color = '#FF0000';
	}
	else
	{
		var str = f.email.value;
		var supported = 0;
		if (window.RegExp)
		{
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported) 
			return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$");
		if ((!r1.test(str)==true)&&(r2.test(str)==false))
		{
			errortext = errortext + "\t- A real email address\n";
			errorcheck = 1;
			document.getElementById('emailText').style.color = '#FF0000';
		}
	}
	if (f.cctype.selectedIndex==0)
	{
		errortext = errortext + "\t- Card type\n";
		errorcheck = 1;
		document.getElementById('cardTypeText').style.color = '#FF0000';
	}
	if (f.ccaddress.value=='')
	{
		errortext = errortext + "\t- Billing address\n";
		errorcheck = 1;
		document.getElementById('cardAddressText').style.color = '#FF0000';
	}
	//if (f.ccpostcode.value=='')
	//{
		//errortext = errortext + "\t- Billing postcode\n";
		//errorcheck = 1;
		//document.getElementById('cardPostcodeText').style.color = '#FF0000';
	//}
	if (f.cccountry.selectedIndex==0)
	{
		errortext = errortext + "\t- Billing country\n";
		errorcheck = 1;
		document.getElementById('cardCountryText').style.color = '#FF0000';
	}
	if (f.heardabout.selectedIndex==0)
	{
		errortext = errortext + "\t- Where you heard about Hotel Direct\n";
		errorcheck = 1;
		document.getElementById('heardText').style.color = '#FF0000';
	}
	if (f.terms.checked==false)
	{
		errortext = errortext + "\t- Agree to Hotel Direct`s terms & conditions\n";
		errorcheck = 1;
		document.getElementById('termText').style.color = '#FF0000';
	}

	if (errorcheck==1)
	{
		alert(errortext);
		return false;
	}
}

function checkRequest()
{
	blackText2();
	errortext = "Please complete the following fields before continuing...\n";
	errorcheck = 0;
	f = document.form;

	if (f.title.selectedIndex==0)
	{
		errortext = errortext + "\t- Title\n";
		errorcheck = 1;
		document.getElementById('titleText').style.color = '#FF0000';
	}
	if (f.surname.value=='')
	{
		errortext = errortext + "\t- Full name\n";
		errorcheck = 1;
		document.getElementById('surnameText').style.color = '#FF0000';
		document.getElementById('firstnameText').style.color = '#FF0000';
	}
	if (f.address.value=='')
	{
		errortext = errortext + "\t- Address\n";
		errorcheck = 1;
		document.getElementById('addressText').style.color = '#FF0000';
	}
	//if (f.postcode.value=='')
	//{
		//errortext = errortext + "\t- Postcode\n";
		//errorcheck = 1;
		//document.getElementById('postcodeText').style.color = '#FF0000';
	//}
	if (f.country.selectedIndex==0)
	{
		errortext = errortext + "\t- Country\n";
		errorcheck = 1;
		document.getElementById('countryText').style.color = '#FF0000';
	}
	if ((f.telephoneam.value=='')&&(f.telephonepm.value==''))
	{
		errortext = errortext + "\t- Telephone number\n";
		errorcheck = 1;
		document.getElementById('teldayText').style.color = '#FF0000';
		document.getElementById('televeText').style.color = '#FF0000';
	}
	if (f.email.value=='')
	{
		errortext = errortext + "\t- Email address\n";
		errorcheck = 1;
		document.getElementById('emailText').style.color = '#FF0000';
	}
	if (f.email.value!=f.email2.value)
	{
		errortext = errortext + "\t- Correct email address\n";
		errorcheck = 1;
		document.getElementById('emailText').style.color = '#FF0000';
		document.getElementById('emailText2').style.color = '#FF0000';
	}
	else
	{
		var str = f.email.value;
		var supported = 0;
		if (window.RegExp)
		{
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported) 
			return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$");
		if ((!r1.test(str)==true)&&(r2.test(str)==false))
		{
			errortext = errortext + "\t- A real email address\n";
			errorcheck = 1;
			document.getElementById('emailText').style.color = '#FF0000';
		}
	}
	if (f.cctype.selectedIndex==0)
	{
		errortext = errortext + "\t- Card type\n";
		errorcheck = 1;
		document.getElementById('cardTypeText').style.color = '#FF0000';
	}

/*
         if (f.cctype.options[f.cctype.selectedIndex].value=='Switch')
	 {
	  if (((f.ccvalidmonth.selectedIndex==0) || (f.ccvalidyear.selectedIndex==0)) && (f.issue.value==''))
	  {
	   errortext = errortext + '\t- If you have an issue number you must submit it. If you have no issue number please submit a valid from date\n';
	   errorcheck = 1;
	   document.getElementById('valid').style.color='#FF0000';
	   document.getElementById('issue').style.color='#FF0000';
	  }
	  if ((f.ccvalidmonth.selectedIndex>0) && (f.ccvalidyear.selectedIndex>0) && (f.issue.value==''))
	  {
	   alert('If you have an issue number you must submit it');
	  }
	 }

	 if ((f.cctitle.selectedIndex==0)||(f.ccsurname.value=='')||(f.ccname.value==''))
	 {
	  errortext = errortext + '\t- Card Name\n';
	  errorcheck = 1;
	  document.getElementById('cardTitle').style.color='#FF0000';
	  document.getElementById('cardInitial').style.color='#FF0000';
	  document.getElementById('cardSurname').style.color='#FF0000';
	 }
	 if (f.ccnum.value=='')
	 {
	  errortext = errortext + '\t- Credit card number\n';
	  errorcheck = 1;
	  document.getElementById('cardNumber').style.color='#FF0000';
	 }
	 if (f.ccnum.value.indexOf(" ")>-1)
	 {
	  errortext = errortext + '\t- No spaces in credit card number\n';
	  errorcheck = 1;
	  document.getElementById('cardNumber').style.color='#FF0000';
	 }
	 if ((f.ccmonth.selectedIndex==0) || (f.ccyear.selectedIndex==0))
	 {
	  errortext = errortext + '\t- Credit card expiry date\n';
	  errorcheck = 1;
	  document.getElementById('cardExpiry').style.color='#FF0000';
	 }
	 if (f.cv2.value.length<3)
	 {
	  errortext = errortext + '\t- Credit card security code\n';
	  errorcheck = 1;
	  document.getElementById('cardCode').style.color='#FF0000';
	 }
*/

	if (f.ccaddress.value=='')
	{
		errortext = errortext + "\t- Billing address\n";
		errorcheck = 1;
		document.getElementById('cardAddressText').style.color = '#FF0000';
	}
	//if (f.ccpostcode.value=='')
	//{
		//errortext = errortext + "\t- Billing postcode\n";
		//errorcheck = 1;
		//document.getElementById('cardPostcodeText').style.color = '#FF0000';
	//}
	if (f.cccountry.selectedIndex==0)
	{
		errortext = errortext + "\t- Billing country\n";
		errorcheck = 1;
		document.getElementById('cardCountryText').style.color = '#FF0000';
	}
	if (f.heardabout.selectedIndex==0)
	{
		errortext = errortext + "\t- Where you heard about Hotel Direct\n";
		errorcheck = 1;
		document.getElementById('heardText').style.color = '#FF0000';
	}
	if (f.terms.checked==false)
	{
		errortext = errortext + "\t- Agree to Hotel Direct`s terms & conditions\n";
		errorcheck = 1;
		document.getElementById('termText').style.color = '#FF0000';
	}

	if (errorcheck==1)
	{
		alert(errortext);
		return false;
	}
	//f.ccmonth.value=f.ccexpiry.value.substring(0,2);
	//f.ccyear.value=f.ccexpiry.value.substring(2);
	//f.ccvalidmonth.value=f.ccvaliddate.value.substring(0,2);
	//f.ccvalidyear.value=f.ccvaliddate.value.substring(2);
}

function blackText()
{
	document.getElementById('titleText').style.color = '#000000';
	document.getElementById('surnameText').style.color = '#000000';
	document.getElementById('firstnameText').style.color = '#000000';
	document.getElementById('addressText').style.color = '#000000';
	document.getElementById('postcodeText').style.color = '#000000';
	document.getElementById('countryText').style.color = '#000000';
	document.getElementById('teldayText').style.color = '#000000';
	document.getElementById('televeText').style.color = '#000000';
	document.getElementById('emailText').style.color = '#000000';
	document.getElementById('emailText2').style.color = '#000000';
	document.getElementById('cardTypeText').style.color = '#000000';
	document.getElementById('cardAddressText').style.color = '#000000';
	document.getElementById('cardPostcodeText').style.color = '#000000';
	document.getElementById('cardCountryText').style.color = '#000000';
	document.getElementById('heardText').style.color = '#000000';
	document.getElementById('termText').style.color = '#000000';
}

function blackText2()
{
	document.getElementById('titleText').style.color = '#000000';
	document.getElementById('surnameText').style.color = '#000000';
	document.getElementById('firstnameText').style.color = '#000000';
	document.getElementById('addressText').style.color = '#000000';
	document.getElementById('postcodeText').style.color = '#000000';
	document.getElementById('countryText').style.color = '#000000';
	document.getElementById('teldayText').style.color = '#000000';
	document.getElementById('televeText').style.color = '#000000';
	document.getElementById('emailText').style.color = '#000000';
	document.getElementById('emailText2').style.color = '#000000';
	document.getElementById('cardTypeText').style.color = '#000000';
	document.getElementById('cardAddressText').style.color = '#000000';
	document.getElementById('cardPostcodeText').style.color = '#000000';
	document.getElementById('cardCountryText').style.color = '#000000';
	document.getElementById('heardText').style.color = '#000000';
	document.getElementById('termText').style.color = '#000000';

	//document.getElementById('cardTitle').style.color = '#000000';
	//document.getElementById('cardInitial').style.color = '#000000';
	//document.getElementById('cardSurname').style.color = '#000000';
	//document.getElementById('valid').style.color = '#000000';
	//document.getElementById('issue').style.color = '#000000';
	//document.getElementById('cardNumber').style.color = '#000000';
	//document.getElementById('cardExpiry').style.color = '#000000';
	//document.getElementById('cardCode').style.color = '#000000';
}

function populateRooms()
{
	f=document.form;
	f.doubleroom.value=0;
	f.single.value=0;
	f.twin.value=0;
	f.triple.value=0;
	f.family1.value=0;
	f.family2.value=0;
	f.family3.value=0;

	for (i=1; i<=f.rooms.options[f.rooms.selectedIndex].value; i++)
	{
		room = f['roomtype'+i].options[f['roomtype'+i].selectedIndex].value;
		if (room=='doubleroom')
			f.doubleroom.value++;
		else if (room=='single')
			f.single.value++;
		else if (room=='twin')
			f.twin.value++;
		else if (room=='triple')
			f.triple.value++;
		else if (room=='family1')
			f.family1.value++;
		else if (room=='family2')
			f.family2.value++;
		else if (room=='family3')
			f.family3.value++;
	}
}

function displaySwitch()
{
 f=document.form;
 /*
 if (f.cctype.options[f.cctype.selectedIndex].value=='Switch')
 {
  document.getElementById('Switch').style.display='block';
  document.getElementById('Switch2').style.display='block';
  document.getElementById('Switch3').style.display='block';
  document.getElementById('Switch4').style.display='block';
  document.getElementById('Switch5').style.display='block';
 }
 else
 {
  document.getElementById('Switch').style.display='none';
  document.getElementById('Switch2').style.display='none';
  document.getElementById('Switch3').style.display='none';
  document.getElementById('Switch4').style.display='none';
  document.getElementById('Switch5').style.display='none';
 }
 */
}

function checkLastminute()
{
  f=document.last;
  if (f.city.selectedIndex==0) 
  {
     window.alert('Please select a city');
     return false;
  }
  else return true;
}

function checkTheatretickets()
{
  f=document.form;
  setGuests(2);

  now = new Date();
  showdate = f.showdate.options[f.showdate.selectedIndex].value;
  showmonth=showdate.substring(8);
  showmonth=showmonth-1;
  showday=showdate.substring(0,2);
  showmonth=showmonth-now.getMonth();
  if (showmonth<0) showmonth=showmonth+12;

  if ((f.arrivedate2.selectedIndex>showmonth) || (f.departdate2.selectedIndex<showmonth) || (f.arrivedate2.selectedIndex==showmonth && f.arrivedate.selectedIndex>showday) || (f.departdate2.selectedIndex==showmonth && f.departdate.selectedIndex<showday))
  {
	window.alert('You are trying to book a hotel stay that does not include your show night.');
        return(false);
  }
  else
  {
    total = parseInt(f.adults.value) + parseInt(f.children.value);
    tickets=f.ntickets.options[f.ntickets.selectedIndex].value;
    x=true;
    if (tickets!=total)
    {
	  x=window.confirm("Number of tickets does NOT match number of guests. Click 'Cancel' to amend.");
	  if (x) checkCitySearch();
	  else return false;
    }
    else checkCitySearch();
  }
}

function checkTheatretickets2()
{
  f=document.form;
  setGuests(2);
  total = parseInt(f.adults.value) + parseInt(f.children.value);
  tickets=f.ntickets.options[f.ntickets.selectedIndex].value;
  x=true;
  if (tickets!=total)
  {
	  x=window.confirm("Number of tickets does NOT match number of guests. Click 'Cancel' to amend.");
	  if (x) checkCitySearch();
	  else return false;
  }
  else if (f.employee.selectedIndex==0) 
  {
	window.alert("Please select the agent's name");
	return(false);
  }
  else checkCitySearch();
}

function checktelform()
{
  f=document.telform;
  if (f.telephonenum.length<5 || f.telephonenum.value=='Your telephone number')  
  {
	window.alert("Please enter your full telephone number");
	return(false);
  }
}

