function checkInicioSearch()
{
	errortext = "Por favor complete lo siguiente antes de continuar...\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 && f.city2.selectedIndex==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 + "- Fecha de llegada valida\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = checkArrivalDate();
	if (checkdate<0)
	{
		errortext = errortext + "- Fecha de salida valida\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = compareDates();
	if (checkdate==1)
	{
		errortext = errortext + "- Fecha de llegada anterior a la fecha de salida\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 + "- Fecha de llegada valida\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 + "- Un periodo mas corto o llame al +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 + "- Seleccione un tipo de habitacion " + 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 + "- Entre las edades de los niño(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;

		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 + "- Solamente numeros, separados por comas (sin espacios)\n";
		   errorcheck = 1;
                }
		else if (childrenfound>totalchildren)
		{
  		   if (totalchildren==1) errortext = errortext + "- Solamente la edad de 1 niño\n";
		   else errortext = errortext + "- Las edades de "+totalchildren+" ninños, separados por comas (sin espacios)\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);
	populateHabs();
	setGuests(2);
	setCookieDates();
}

function populateHabs()
{
	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 checkCitySearch()
{
	errortext = "Por favor, complete antes de continuar...\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 + "- Fecha de lleaga valida\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = checkArrivalDate();
	if (checkdate<0)
	{
		errortext = errortext + "- Fecha de salida valida\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = compareDates();
	if (checkdate==1)
	{
		errortext = errortext + "- Fecha de llegada anterior a la fecha de salida\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 + "- Fecha de lleaga valida\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 + "- Un perido mas corto o llame al +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 + "- Seleccione un tipo de habitacion " + 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 + "- Las edades de los niño(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 + "- Solamente numeros, separados por comas (sin espacios)\n";
		   errorcheck = 1;
                }
		else if (childrenfound>totalchildren)
		{
  		   if (totalchildren==1) errortext = errortext + "- Solamente la edad de 1 niños\n";
		   else errortext = errortext + "- Solamente las edades de "+totalchildren+" niños, separados por comas (sin espacios)\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);
	populateHabs();
	setGuests(2);
	setCookieDates();
}

function checkReservation()
{
	blackText();
	color_error = "#CC0000";
	errortext = "Por favor complete los siguientes campos and the continuar...\n";
	errorcheck = 0;
	f = document.form;

	if (f.title.selectedIndex==0)
	{
		errortext = errortext + "\t- Titulo\n";
		errorcheck = 1;
		document.getElementById('titleText').style.color = color_error;
	}
	if (f.surname.value=='')
	{
		errortext = errortext + "\t- Nombre y Apellidos\n";
		errorcheck = 1;
		document.getElementById('surnameText').style.color = color_error;
		document.getElementById('firstnameText').style.color = color_error;
	}
	if (f.address.value=='')
	{
		errortext = errortext + "\t- Dirección\n";
		errorcheck = 1;
		document.getElementById('addressText').style.color = color_error;
	}
	if (f.postcode.value=='' && (f.country.value=='UK|United Kingdom' || f.country.value=='US|USA'))
	{
		errortext = errortext + "\t- Codigo Postal\n";
		errorcheck = 1;
		document.getElementById('postcodeText').style.color = color_error;
	}
	if (f.country.selectedIndex==0)
	{
		errortext = errortext + "\t- País\n";
		errorcheck = 1;
		document.getElementById('countryText').style.color = color_error;
	}
	if ((f.telephoneam.value=='')&&(f.telephonepm.value==''))
	{
		errortext = errortext + "\t- Teléfono number\n";
		errorcheck = 1;
		document.getElementById('teldayText').style.color = color_error;
		document.getElementById('televeText').style.color = color_error;
	}
	if (f.email.value=='')
	{
		errortext = errortext + "\t- Correo electrónico\n";
		errorcheck = 1;
		document.getElementById('emailText').style.color = color_error;
	}
	if (f.email.value!=f.email2.value)
	{
		errortext = errortext + "\t- Correo electrónico correcto\n";
		errorcheck = 1;
		document.getElementById('emailText').style.color = color_error;
		document.getElementById('emailText2').style.color = color_error;
	}
	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- Correo electrónico correcto\n";
			errorcheck = 1;
			document.getElementById('emailText').style.color = color_error;
		}
	}
	if (f.cctype.selectedIndex==0)
	{
		errortext = errortext + "\t- Tipo de tarjeta\n";
		errorcheck = 1;
		document.getElementById('cardTypeText').style.color = color_error;
	}
	if (f.ccaddress.value=='')
	{
		errortext = errortext + "\t- Datos de pago\n";
		errorcheck = 1;
		document.getElementById('cardDirecciónText').style.color = color_error;
	}
	if (f.ccpostcode.value=='' && (f.cccountry.value=='UK|United Kingdom' || f.cccountry.value=='US|USA'))
	{
		errortext = errortext + "\t- Codigo postal de pago\n";
		errorcheck = 1;
		document.getElementById('cardPostcodeText').style.color = color_error;
	}
	if (f.cccountry.selectedIndex==0)
	{
		errortext = errortext + "\t- Pais de pago\n";
		errorcheck = 1;
		document.getElementById('cardPaísText').style.color = color_error;
	}
	/*if (f.heardabout.selectedIndex==0)
	{
		errortext = errortext + "\t- Where you heard about Hotel Direct\n";
		errorcheck = 1;
		document.getElementById('heardText').style.color = color_error;
	}*/
	if (f.terms.checked==false)
	{
		errortext = errortext + "\t- Acepte las condicions de uso de Hotel Direct\n";
		errorcheck = 1;
		document.getElementById('termText').style.color = color_error;
	}

	if (errorcheck==1)
	{
		alert(errortext);
		return false;
	}
}

function blackText()
{
	color = "";
	document.getElementById('titleText').style.color = color;
	document.getElementById('surnameText').style.color = color;
	document.getElementById('firstnameText').style.color = color;
	document.getElementById('addressText').style.color = color;
	document.getElementById('postcodeText').style.color = color;
	document.getElementById('countryText').style.color = color;
	document.getElementById('teldayText').style.color = color;
	document.getElementById('televeText').style.color = color;
	document.getElementById('emailText').style.color = color;
	document.getElementById('emailText2').style.color = color;
	document.getElementById('cardTypeText').style.color = color;
	document.getElementById('cardDirecciónText').style.color = color;
	document.getElementById('cardPostcodeText').style.color = color;
	document.getElementById('cardPaísText').style.color = color;
	//document.getElementById('heardText').style.color = color;
	document.getElementById('termText').style.color = color;
}

function blackText2()
{
	color = "";
	document.getElementById('titleText').style.color = color;
	document.getElementById('surnameText').style.color = color;
	document.getElementById('firstnameText').style.color = color;
	document.getElementById('addressText').style.color = color;
	document.getElementById('postcodeText').style.color = color;
	document.getElementById('countryText').style.color = color;
	document.getElementById('teldayText').style.color = color;
	document.getElementById('televeText').style.color = color;
	document.getElementById('emailText').style.color = color;
	document.getElementById('emailText2').style.color = color;
	document.getElementById('cardTypeText').style.color = color;
	document.getElementById('cardDirecciónText').style.color = color;
	document.getElementById('cardPostcodeText').style.color = color;
	document.getElementById('cardPaísText').style.color = color;
	//document.getElementById('heardText').style.color = color;
	document.getElementById('termText').style.color = color;

	//document.getElementById('cardTitle').style.color = color;
	//document.getElementById('cardInitial').style.color = color;
	//document.getElementById('cardApellido').style.color = color;
	//document.getElementById('valid').style.color = color;
	//document.getElementById('issue').style.color = color;
	//document.getElementById('cardNumber').style.color = color;
	//document.getElementById('cardExpiry').style.color = color;
	//document.getElementById('cardCode').style.color = color;
}

function checkFreeSearch()
{
	errortext = "Por favor complete lo siguiente...\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 + "- Fecha de llegada valida\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = checkArrivalDate();
	if (checkdate<0)
	{
		errortext = errortext + "- Fecha de salida valida\n";
		errorcheck = 1;
		setSunday();
	}
	checkdate = 0;
	checkdate = compareDates();
	if (checkdate==1)
	{
		errortext = errortext + "- Fecha de llegada anterior a la fecha de salida\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 + "- Fecha de llegada valida\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 + "- Periodo mas corto o llame al +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 + "- Seleccione un tipo de habitacion\n";
		errorcheck = 1;
	}
	if ((f.children.value>0)&&(f.kidsage.value==''))
	{
		errortext = errortext + "- Las edades de los niños\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();
}