var iAmFlexible = "I am flexible";
var onewaylabel = "One-Way";

function showAlertInDiv(error, direction) {
    var tipoCity, tipoDate, errorDiv, errorTextDiv,isItinerarySelection;
    tipoCity = (direction == "departure") ? "departure" : "destination";
    tipoDate = (direction == "departure") ? "departure" : "return";
    if (direction.indexOf('tabFare') != -1) {
        var ind = direction.substr(0, direction.indexOf("t"));
        errorDiv = "content-error-form-" + ind;
        errorTextDiv = "content-error-form-text-" + ind;
        isItinerarySelection = true;
    } else {
        errorDiv = 'content-error-form';
        errorTextDiv = 'content-error-form-text';
        isItinerarySelection = false;
    }

    var enterCity = "Enter the " + tipoCity + " city.";
    var cityNoNumbers = "The " + tipoCity + " city cannot contain numbers.";
    //
    var noDate = "Enter the " + tipoDate + " date.";
    var dateFormat = "The " + tipoDate + " date needs to be entered in the format dd/mm/aaaa. i.e. 24/11/2009";
    var dateAfterToday = "The " + tipoDate + " date needs to be after today's date";
    var dateReturnAfterDeparture = "The return date needs to be after the departure date";
        //dynpack
    var thirtyDaysStay = "The maximum stay is 30 days. Please adjust the departure date accordingly.";
    var dynpackFiveOrSevenPeople = "It is not possible to launch a search with the indicated passenger combination. Please modify it and try again.";
    //
    var maxNinePax = "The maximum number of passengers is 9.";
    var noPax = "You have not selected a passenger.";
    var twoChildrenPerPax = "Maximum of two children per adult.";
    var oneInfantPerPax = "Maximum of 1 infant per adult.";
    //
    //I am flexible calendar
    var flexibleAlert = "If you click on « search », the search engine will show you the available dates for the return flight.";
    //
    // choose Airport
    var chooseAirport = "Please choose a " + tipoCity + " airport.";
    var sameAirports = "Please choose two different airports.";
    //
    //multiple cities
    var noAeropuerto0 = "Please indicate a city of " + tipoCity + " for the first flight.";
    var cityNoNumbers0 = "The city of " + tipoCity + " for the first flight can not include digits.";
    var noAeropuerto1 = "Please indicate the city of " + tipoCity + " for the second flight.";
    var cityNoNumbers1 = "The city of " + tipoCity + " for the second flight can not include digits.";
    var noAeropuerto2 = "Please indicate a city of " + tipoCity + " for the third flight.";
    var cityNoNumbers2 = "The city of " + tipoCity + " for the third flight can not include digits.";
    //multiple dates
    var noDate0 = "Please indicate the departure date of the first flight.";
    var dateFormat0 = "The departure date for the first flight needs to be entered in the format dd/mm/aaaa. i.e. 24/11/2009";
    var dateAfterToday0 = "The departure date of the first flight needs to be after today's date";
    var noDate1 = "Please indicate the departure date of the second flight.";
    var dateFormat1 = "The departure date for the second flight needs to be entered in the format dd/mm/aaaa. i.e. 24/11/2009";
    var dateAfterToday1 = "The departure date of the second flight needs to be after today's date";
    var noDate2 = "Please indicate the departure date of the third flight.";
    var dateFormat2 = "The departure date for the third flight needs to be entered in the format dd/mm/aaaa. i.e. 24/11/2009";
    var dateAfterToday2 = "The departure date of the third flight needs to be after today's date";
    var secondAfterFirst = "The second flight date needs to be after the first flight date";
    var thirdAfterFirst = "The third flight date needs to be after the first flight date";
    var thirdAfterSecond = "The third flight date needs to be after the second flight date";
    //
    //search results
    var selectTwoResultsOptions = "You need to select a departing and return flight in the same option block.";
    var selectThreeResultsOptions = "You need choose three flights with the same option block.";
    var chooseOut = "You need to select a departing flight from this option block.";
    //
    //busca destinos
    var maxPriceIsNaN = "The maximum price must be numbers.";
    //
    //busqueda caducada
    var outDatedSearch = "This search has expired. Please be aware that you can only launch one search at a time.";
    //
    //login
    var validEmail = "You must enter a valid email address.";
    var noPass = "You must enter your password!";
    //register
    var noname = "The value for your first name is mandatory and must be assigned.";
    var noNumbersInname = "Please check the first name.";
    var nolastName = "The value for your surname is mandatory and must be assigned.";
    var noNumbersInlastName = "Please check the last name.";
    var noNumbersInlastNames = "Please check the last name.";
    var noidCardNumber = "The value for your id is mandatory and must be assigned.";
    var nomobileNumber = "The value for your mobile phone is mandatory and must be assigned.";
    var validMobile = "Your mobile phone number does not have a valid format.";
    var noaddress = "The value for your address is mandatory and must be assigned.";
    var nocity = "The value for your city is mandatory and must be assigned.";
    var nozipCode = "The value for your postal code is mandatory and must be assigned.";
    var noregion = "The value for your mobile phone is mandatory and must be assigned.";
    var notEqualEmails = "Both email addresses must be the same.";
    var notEqualPasswords = "Passwords are different.";
    var noConditions = "You need to accept the Data Protection Policy and General Conditions of eDreams.";
    var lengthHigherName = "Name of passenger must be at least 2 characters long.";
    var lengthHigherLastName = "Lastname of passenger must be at least 2 characters long";
    var lengthHigherLastNames = "Lastname of passenger must be at least 2 characters long";
    //
    //pax page
    var nolastNames = "Enter the buyer's surname";
    var noidentification = noidCardNumber;
    var nocityName = nocity;
    var nostateName = noregion;
    var nophoneNumber1 = nomobileNumber;
    var noValidNif = "Incorrect NIF : please check the NIF number you entered.<br/>&nbsp;- A Spanish NIF is from 1 to 9 numbers plus a letter. For example : 12345678A<br/>&nbsp;- If you do not have a Spanish NIF, select NIE or Passport";
    //
    //pay page
    var noELVFirstName = "Por favor, introduce el nombre ELV.";
    var noELVAccount = "Por favor, introduce el número de cuenta ELV.";
    var noELVSurname = "Por favor, introduce apellido ELV.";
    var noELVBank = "Por favor, introduce banco ELV.";
    var noELVCredit = "Por favor, introduce credit ELV.";
    var nocardOwner = "Enter the cardholder's name.";
    var nocardNumber = "Enter the bank card number.";
    var nocardExpirationMonth = "Please indicate the month of the expiration date of your bank card exactly as it appears on your card. For example : 01.";
    var nocardExpirationYear = "Please indicate the year of the expiration date of your bank card exactly as it appears on your card. For example : 01.";
    var nocardSecNum = "Enter the bank card security code.";
    var noNumbersIncardOwner = "Please check the bankcard holder's name.";
    //  invoice
    var noinvoiceName = "Enter the name of the person or company the invoice is to be sent to.";
    var noinvoiceId =  "Enter the SIRET number of the company the invoice is to be sent to.";
    var noinvoiceAddress = "Enter the address of the person or company the invoice is to be sent to.";
    var noinvoiceCity = "Enter the city of the person or company the invoice is to be sent to.";
    var noinvoiceZipcode = "Enter the zip code of the person or company the invoice is to be sent to.";
    //
    var toAlert = eval(error);
    var docScope;
    if (document.getElementById(errorTextDiv)) {
        docScope = document;
    } else {
        docScope = parent.document;
    }
    doShowAlert(toAlert, docScope, errorTextDiv, errorDiv);
    if (!isItinerarySelection) {
        window.location.href = "#errorAnchor";
    }
}
function doShowAlert(toAlert, docScope, errorTextDiv, errorDiv) {
    docScope.getElementById(errorTextDiv).innerHTML += toAlert + "<br/>";
    docScope.getElementById(errorDiv).style.display = "block";
    //    windowScope.location.href = "#errorAnchor";
}
function showPaxAlertInDiv(error, paxInd, limitDate) {
    var errorDiv = 'content-error-form';
    var errorTextDiv = 'content-error-form-text';
    var paxNum;
    paxNum = parseInt(paxInd) + 1;
    if(isNaN(paxNum)){
        paxNum = paxInd;
    }
    //    passengers and Buyer
    var noname = "Enter passenger " + paxNum + " first name";
    var noNumbersInname = "Please check passenger's " + paxNum + " first name.";
    var nofirstLastName = "Enter  passenger " + paxNum + " surname";
    var noNumbersInfirstLastName = "Please check passenger's " + paxNum + " surname.";
    var nosecondLastName;
    var noNumbersInsecondLastName;
    var noidentification = "Enter passenger " + paxNum + "passport or ID card number(without spaces or dashes)";
    var noValidNif = "Incorrect NIF : please check the NIF number you entered.<br/>&nbsp;- A Spanish NIF is from 1 to 9 numbers plus a letter. For example : 12345678A<br/>&nbsp;- If you do not have a Spanish NIF, select NIE or Passport";
    var noidentificationExpirationDay = "Please indicate the expiration date for the identity document of passenger " + paxNum;
    var noidentificationExpirationMonth = "Please indicate the expiration date for the identity document of passenger " + paxNum;
    var noidentificationExpirationYear = "Please indicate the expiration date for the identity document of passenger " + paxNum;
    var invalidIdentificationExpirationDate= "Please change the expiration date of the passenger's " + paxInd + " identification document.";
    var noyearOfBirth = "Please check passenger " + paxNum + "date of birth";
    var badDateOfBirth = "Please check passenger " + paxNum + "date of birth.<br/>&nbsp;- The date of birth must be after " + limitDate;
    var badDateOfBirthPrevious = "Please check passenger " + paxNum + "date of birth.<br/>&nbsp;- The date of birth must be before " + limitDate;
    var lengthHigherName = "Name of passenger " + paxNum + " must be at least 2 characters long.";
    var lengthHigherFirstLastName = "Lastname of passenger " + paxNum + " must be at least 2 characters long.";

    //
    //pay page
    var noPaymethod = "You must select a method of payment.";
    var noCC = "Select the type of bank card.";
    var badCCNum = "Incorrect card. Please check the type and number of your card.";
    var badCardExpirationDate = "Please check the expiration date. The entered date must be after or the same as today's date.";
    var cvvJustNumber = "The security code can only be a number.";
    var cvvAmericanExpress = "The security code for American Express has 4 numbers. Please enter the security code again.";
    var cvvVisaMastercard = "The security code for Visa, MasterCard and JCB has 3 numbers. Please enter the security code again.";
    var selectAnInsurance = "Please indicate if you would like to include travel insurance";
    var noConditionsPay = "In order to continue, please read and accept the conditions for issuing tickets.";
    //   sms
    var validMobile = paxNum +"'s mobile phone number does not have a valid format.";
    //
    var toAlert = eval(error);
    doShowAlert(toAlert, document, errorTextDiv, errorDiv);
    window.location.href = "#errorAnchor";
}
function alertSessionTimeoutWarning(timePassed, timeLeft) {
    alert(timePassed + " minutes have passed since your request for a reservation, we have blocked seats for you. In order not to penalise other users, eDreams will hold the seats for you at the requested price for another " + timeLeft + " minutes. When these " + timeLeft + " minutes have elapsed, your session will end and you will have to start the procedure again. We can only guarantee that the seats you have chosen will remain available until that time. Make your reservation now so that you don't lose your seats !");
}
function alertSessionTimeout(maxTime) {
    alert("More than " + maxTime + " minutes have passed since your request for a reservation. Your session has ended. You will have to make a new search in order to make a reservation.");
}