function MM_validateForm() { //v4.0
  var i,p,q,nm,nmtext,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; 
	       chckd=val.checked;
		   id = val.id;
		   value = val.value;

		if (nm == "name"){
			nmtext = "Name";
		}
		else if (nm == "surname"){
			nmtext = "Surname";
		}
		else if (nm == "NIF"){
			nmtext = "Tax number";
		}		
		else if (nm == "country"){
			nmtext = "Country";
		}
		else if (nm == "phone"){
			nmtext = "Telephone";
		}
		else if (nm == "email"){
			nmtext = "E-mail";
		}
		else if (nm == "emailconf"){
			nmtext = "Verification of e-mail";
		}		
		else if (nm == "address"){
			nmtext = "Address";
		}			
		else if (nm == "city"){
			nmtext = "City";
		}		
		else if (nm == "zipcode"){
			nmtext = "Post code";
		}
		else if (nm == "region"){
			nmtext = "Region";
		}				
		else if ((nm == "password1F") || (nm == "fpassword")){
			nmtext = "Password";
		}				
		else if (nm == "password2F"){
			nmtext = "Verification of password";
		}	
		else if ((nm == "usernameF") || (nm == "fusername")){
			nmtext = "E-mail";
		}
		else if (nm == "idCity"){
			nmtext = "Destination";
		}
		else if ((nm == "numAdults") || (nm == "numAdultsNR")){
			nmtext = "Number of adults";
		}
		else if (nm == "numChildrenNR"){
			nmtext = "Children between 2 & 12 years old";
		}
		else if (nm == "nameHotel"){
			nmtext = "Hotel name";
		}
		else if (nm == "phoneHotel"){
			nmtext = "Hotel telephone";
		}
		else if (nm == "emailHotel"){
			nmtext = "Hotel e-mail";
		}
		else if (nm == "nombre"){
			nmtext =  "Your name";
		}
		else if (nm == "emailFrom"){
			nmtext =  "Your e-mail";
		}
		else if (nm == "emailTo"){
			nmtext =  "Your friend's e-mail";
		}
		else if (nm == "firstinput"){
			nmtext =  "Date";
		}
		else if (nm == "secondinput"){
			nmtext =  "Date";
		}		
		else if ((nm == "firstinputArrival") || (nm == "firstinputH")){
			nmtext =  "Arrival date";
		}				
		else if (nm == "secondinputExit"){
			nmtext =  "Check-out date";
		}		
		else if (nm == "numFlight"){
			nmtext =  "Flight number";
		}
		else if (nm == "timeArriveFlight"){
			nmtext =  "Forecast time of arrival";
		}
		else if (nm == "addressDevolutionCar"){
			nmtext =  "Address";
		}			
		else if (nm == "arrivalTimeHour"){
			nmtext =  "Arrival time: Hour";
		}
		else if (nm == "arrivalTimeMinute"){
			nmtext =  "Arrival time: Minutes";
		}
		else if (nm == "exitTimeHour"){
			nmtext =  "Departure time: Hour";
		}	
		else if (nm == "exitTimeMinute"){
			nmtext =  "Departure time: Minutes";
		}	
		else if ((nm == "originAirport") || (nm == "arriveAirport")){
			nmtext =  "Departure airport";
		}	
		else if ((nm == "originNumFlight") || (nm == "numFlightArrive") || (nm == "numFlightExit")){
			nmtext =  "Flight number";
		}	
		else if (nm == "exitAirport"){
			nmtext =  "Airport of arrival";
		}
		else if ((nm == "idRoomNR") || (nm == "idRoom1")){
			nmtext =  "Room type";
		}
		else if ((nm == "idRegimesNR") || (nm == "idRegimes1")){
			nmtext =  "Meals";
		}
		else if ((nm == "numNightsH") || (nm == "numNights")){
			nmtext =  "Number of nights";
		}																												
		else{
			nmtext = nm;
		}

	if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { 
	p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nmtext+' You must include a valid e-mail address.\n';
      } 
      else if (test.indexOf('checked')!=-1) { 

		if ((id == "RSV0") && (value == "TXTFLD") && (chckd == true)){

			if (document.form1.nameHotel.value == ""){ errors += '- Hotel name this is required.\n';}
			if (document.form1.addressHotel.value == ""){ errors += '- Address this is required.\n';}
		}
		else if (id != "RSV0"){
        if (chckd == false) errors+='- You must accept the conditions of the service.\n';
		}
      } 
      else if (test!='R') { 
	num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nmtext+' It must be a numeric figure.\n';
        if (test.indexOf('inRange') != -1) { 
		p=test.indexOf(':');
          	min=test.substring(8,p); max=test.substring(p+1);
          	if (num<min || max<num) errors+='- '+nmtext+' it must be a numeric figure between '+min+'  '+max+'.\n';
    	} 
      } 

    } 
    else if (test.indexOf('selected')!=-1) {
		if (id == "idDestinacio" && document.getElementById("idDestinacio").value == ""){
			errors+='- Wählen Sie bitte ein Reiseziel aus.\n';
		}
    }
	else if (test.charAt(0) == 'R') errors += '- '+nmtext+' this is required.\n'; }
  } if (errors) alert('Folgende Fehler wurden gefunden:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function checkNIF()
  {

    nifcif = document.form1.NIF.value.substring (0, 1);

    if (EsNumero(nifcif)) {


//    if (document.form1.NIF.value.length==0) 
//    {
//      document.form1.NIF.focus();  
//      alert ("Debe facilitarnos el número de identificación fiscal.");
//      return(false);
//    }
    var letras=0;
    for (var i=0; i<document.form1.NIF.value.length; i++) 
    {
      var ch = document.form1.NIF.value.substring (i, i+1);
      if ( (ch < "0" || ch > "9") && (ch < "a" || ch > "z") && (ch < "A" || ch > "Z") )
      {
        alert("The tax number is wrong");
        document.form1.NIF.value = "";
        document.form1.NIF.focus();

        return(false);
      }
      if ( (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") )
      {
        letras++;
      }  
    }
    if (letras>2)
    {
      alert("The tax number is wrong");
      document.form1.NIF.value = "";
      document.form1.NIF.focus();
      return(false);
    }

    var numNIF = document.form1.NIF.value.substring(0,8);
    var lletraNIF = document.form1.NIF.value.substring(8,9);

    var cadena = 'TRWAGMYFPDXBNJZSQVHLCKET';
    var posicion = numNIF % 23;

    var lletraNIFOK = cadena.charAt(posicion);

    if (lletraNIF != lletraNIFOK){
      alert("The tax number is wrong");
      document.form1.NIF.value = "";
      document.form1.NIF.focus();
      return(false)
    }

    return true;
 
    }
    else{


	if (validarCIF(document.form1.NIF.value)){
		return(true)
	}
	else{
		alert("The tax number is wrong");
	        document.form1.NIF.value = "";
	        document.form1.NIF.focus();
		return(false)
	}

    }
}
