



var urlCalendarReservationDateNH_iFrame = "/nh/Layer.Controller?event=2&formName=solicitud&calendarDivName=calendarReservationDateNH&fIniVisualInputName=reservationDateNH&fIniInputName=fReservationDateNH&twoMonth=0&twoDates=0";
var urlCalendarCheckInNH_iFrame = "/nh/Layer.Controller?event=2&formName=solicitud&calendarDivName=calendarCheckInNH&fIniVisualInputName=checkInDateNH&fIniInputName=fCheckInNH&twoMonth=0&twoDates=0";
var urlCalendarCheckOutNH_iFrame = "/nh/Layer.Controller?event=2&formName=solicitud&calendarDivName=calendarCheckOutNH&fIniVisualInputName=checkOutDateNH&fIniInputName=fCheckOutNH&twoMonth=0&twoDates=0";
var urlCalendarReservationDateOther_iFrame = "/nh/Layer.Controller?event=2&formName=solicitud&calendarDivName=calendarReservationDateOther&fIniVisualInputName=reservationDateOther&fIniInputName=fReservationDateOther&twoMonth=0&twoDates=0";
var urlCalendarCheckInOther_iFrame = "/nh/Layer.Controller?event=2&formName=solicitud&calendarDivName=calendarCheckInOther&fIniVisualInputName=checkInDateOther&fIniInputName=fCheckInOther&twoMonth=0&twoDates=0";
var urlCalendarCheckOutOther_iFrame = "/nh/Layer.Controller?event=2&formName=solicitud&calendarDivName=calendarCheckOutOther&fIniVisualInputName=checkOutDateOther&fIniInputName=fCheckOutOther&twoMonth=0&twoDates=0";

/**
 * Comprobación de los campos obligatorios del formulario del cuestionario.
 */
function submitSolicitud() {

	if (document.solicitud.reservationDateNH.value == 'dd-mm-yyyy') {
		document.solicitud.reservationDateNH.value = null;
	}
	if (document.solicitud.checkInDateNH.value == 'dd-mm-yyyy') {
		document.solicitud.checkInDateNH.value = null;
	}
	if (document.solicitud.checkOutDateNH.value == 'dd-mm-yyyy') {
		document.solicitud.checkOutDateNH.value = null;
	}
	if (document.solicitud.reservationDateOther.value == 'dd-mm-yyyy') {
		document.solicitud.reservationDateOther.value = null;
	}
	if (document.solicitud.checkInDateOther.value == 'dd-mm-yyyy') {
		document.solicitud.checkInDateOther.value = null;
	}
	if (document.solicitud.checkOutDateOther.value == 'dd-mm-yyyy') {
		document.solicitud.checkOutDateOther.value = null;
	}
	
	var clubChecked = false;
	for (i = 0; i < document.solicitud.clubNHWorld.length; i++) {
		if (document.solicitud.clubNHWorld[i].checked) {
			clubChecked = true;
			break;
		}
	}
	
	if (document.solicitud.firstName.value == '') {
		alert('You must introduce your name');
	} else if (document.solicitud.lastName1.value == '') {
		alert('You must introduce your surname');
	
	} else if (!clubChecked) {
		alert('You must indicate if you are you a member of NH Club?');
	} else if (document.solicitud.country.value == '') {
		alert('You must indicate your country');
	} else if (document.solicitud.phoneCode1.value == '') {
		alert('You must indicate country phone code 1');
	} else if (document.solicitud.phoneNumber1.value == '') {
		alert('You must indicate your phone number 1 ');
	} else if (document.solicitud.email.value == '') {
		alert('You must indicate your e-mail adress');
	} else if (document.solicitud.emailConfirmation.value == '') {
		alert('You must confirm confirmation of your e-mail adress');
	} else if (document.solicitud.email.value != document.solicitud.emailConfirmation.value) {
		alert('The e-mail adresses are different');
	} else if (!isValidEmail(document.solicitud.email)) {
		alert('The e-mail adresses have not a valid format');
	} else if (document.solicitud.reservationNumberNH.value == '') {
		alert('You must indicate your reservation number');
	} else if (document.solicitud.fReservationDateNH.value == 'dd-mm-yyyy' || document.solicitud.fReservationDateNH.value == '') {
		alert('You must indicate your reservation date');
	} else if (document.solicitud.hotelNH.value == '') {
		alert('You must indicate hotel name');
	} else if (document.solicitud.checkInDateNH.value == 'dd-mm-yyyy' || document.solicitud.checkInDateNH.value == '') {
		alert('You must indicate check in date');
	} else if (document.solicitud.checkOutDateNH.value == 'dd-mm-yyyy' || document.solicitud.checkOutDateNH.value == '') {
		alert('You must indicate check out date');
	} else if (document.solicitud.currencyNH.value == '') {
		alert('You must indicate currency');
	} else if (document.solicitud.priceNH.value == '') {
		alert('You must indicate price');
	} else if (document.solicitud.webNH.value == '') {
		alert('You must indicate web ');
	} else if (document.solicitud.fReservationDateOther.value == 'dd-mm-yyyy' || document.solicitud.fReservationDateOther.value == '') {
		alert('You must indicate reservation date');
	} else if (document.solicitud.hotelOther.value == '') {
		alert('You must indicate hotel name');
	} else if (document.solicitud.checkInDateOther.value == 'dd-mm-yyyy' || document.solicitud.checkInDateOther.value == '') {
		alert('You must indicate check in date');
	} else if (document.solicitud.checkOutDateOther.value == 'dd-mm-yyyy' || document.solicitud.checkOutDateOther.value == '') {
		alert('You must indicate check out date');
	} else if (document.solicitud.currencyOther.value == '') {
		alert('You must indicate currency');
	} else if (document.solicitud.priceOther.value == '') {
		alert('You must indicate price');
	} else if (document.solicitud.webOther.value == '') {
		alert('You must indicate web ');
	} else if (!document.solicitud.agedConfirmation.checked) {
		alert('You must be over 18 years old');
	} else if (!document.solicitud.termsConfirmation.checked) {
		alert('You must accept the service´s use conditions');
	} else {
		document.solicitud.submit();
	}
}

/**
 * Reset del formulario.
 */
function resetSolicitud() {
	document.solicitud.reset();
}

/**
 * Maxlength imposed to the text of a textarea element.
 */
function imposeMaxLength(Object, maxLength)
{
  if(Object.value.length > maxLength){
   Object.value = Object.value.substring(0, maxLength - 1);
  }
}
