function _dateAdapter(sDate1) { var SelLocal; var jour1; var mois1; var annee1; // Récupération du contexte linguistique //SelLocal = jsGetLocale; //alert(jsGetLocale); //SelLocal=1033; tableauDate = sDate1.split("/"); //if (SelLocal=="1033") if (true) {// Dates Anglaises mm/jj/aaaa this.jour = tableauDate[1]; this.mois = tableauDate[0]; this.annee = tableauDate[2]; } else {// Dates francaises & Autres jj/mm/aaaa this.jour = tableauDate[0]; this.mois = tableauDate[1]; this.annee = tableauDate[2]; } } function trim(string) { return string.replace(/(^\s*)|(\s*$)/g,''); } function setIfrmSrc(isAller, idLangue) { var ifrm; var tb; var idDep; var idArr; var DateDepart; var nbPassager = 0; var elmnt; elmnt = document.frmbook.elements; for (i = 0; i < elmnt.length; i++) { if (elmnt[i].name.substring(0, 12) == 'TypePassager') { nbPassager += parseInt(elmnt[i].options[elmnt[i].options.selectedIndex].value); } } var cmbDep = document.getElementById('id_depart'); var cmbArr = document.getElementById('id_arrivee'); var txtDateDepartAller; txtDateDepartAller = document.getElementById('txtDateAller'); var txtDateDepartRetour; txtDateDepartRetour = document.getElementById('txtDateRetour'); if (isAller == 1) { tb = "txtDateAller"; ifrm = document.getElementById('ifrmCalAller'); idDep = cmbDep.options[cmbDep.options.selectedIndex].value; idArr = cmbArr.options[cmbArr.options.selectedIndex].value; if (txtDateDepartAller.value != '' && isDateFutur(txtDateDepartAller.value)) { dateDepart = txtDateDepartAller.value; } else { dateDepart = dateNowInFrenchFormat(); } } else { tb = "txtDateRetour"; ifrm = document.getElementById('ifrmCalRetour'); idDep = cmbDep.options[cmbDep.options.selectedIndex].value; idArr = cmbArr.options[cmbArr.options.selectedIndex].value; if (txtDateDepartAller.value != '' && isDateFutur(txtDateDepartAller.value)) { dateDepart = txtDateDepartAller.value; } else if (txtDateDepartRetour.value != '' && isDateFutur(txtDateDepartRetour.value)) { dateDepart = txtDateDepartRetour.value; } else { dateDepart = dateNowInFrenchFormat(); } } ifrm.src = "/ttidotnet/transport/transportnetfo/JetLinkExpress/PopupFlightDispo.aspx?tb=" + tb + "&id_langue="+idLangue+"&dateFormat=dd/MM/yyyy&Id_Depart=" + idDep + "&Id_Arrivee=" + idArr + "&dateDepart=" + dateDepart + "&ph=&nbpassager=" + nbPassager + "&typestck=&isAller=" + isAller; } function isDateFutur(dte) { now = new Date() return _getDateFromString(dte).getTime() > now.getTime() } function _getDateFromString(sDate1) { var date1 = new Date(); dateAdaptee = new _dateAdapter(sDate1); date1.setDate(dateAdaptee.jour); date1.setMonth((dateAdaptee.mois -1)); date1.setYear(dateAdaptee.annee); return date1; } function fnConvertStringToDateInFrenchFormat(str) { dte = _getDateFromString(str); day = new String(dte.getDate()); if (day.length<2) day = "0"+day; month = new String(dte.getMonth()+1); if (month.length<2) month = "0"+month; year = dte.getFullYear(); return day+"/"+month+"/"+year; } function dateNowInFrenchFormat() { return fnConvertStringToDateInFrenchFormat(dateNow()); } function dateNow() { d = new Date(); return return_formatdate(d.getDate(), d.getMonth()+1, d.getFullYear()); } function showHideRetour(show) { var myStyle = show == 1 ? '' : 'none'; var txtDateDepartRetour; txtDateDepartRetour = document.getElementById('txtDateRetour'); txtDateDepartRetour.style.display = myStyle; var trRetour; trRetour = document.getElementById('trRetour'); trRetour.style.display = myStyle; var btVoirCalRetour; btVoirCalRetour = document.getElementById('btVoirCalRetour'); btVoirCalRetour.style.display = myStyle; var ComboPlageHoraire; ComboPlageHoraire = document.getElementById('ComboPlageHoraire'); if (ComboPlageHoraire) { ComboPlageHoraire.style.display = myStyle; } } function showHideElseCal(show) { var myStyle = show == 1 ? '' : 'none'; var ElseCal; ElseCal = document.getElementById('ElseCal'); if (ElseCal==null) { return; } ElseCal.style.display = myStyle; } function displayCalendar(isAller, idLangue) { var divCal; if (isAller == 1) { divCal = document.getElementById('divCalAller'); } else { divCal = document.getElementById('divCalRetour'); } if (verifIdDepartAndIdRetour()) { divCal.style.display = 'block'; setIfrmSrc(isAller, idLangue); } } function verifIdDepartAndIdRetour() { var cmbDep = document.getElementById('id_depart'); var cmbArr = document.getElementById('id_arrivee'); var idDep = cmbArr.options[cmbArr.options.selectedIndex].value; var idArr = cmbDep.options[cmbDep.options.selectedIndex].value; var txtDateDepartAller = document.getElementById('txtDateAller').value; var txtDateDepartRetour = document.getElementById('txtDateRetour').value; if (idDep == '' || idArr == '') { alert('You must select your trip.'); return false; } return true; } function verifDateAller() { var txtDate = document.getElementById('txtDateAller'); if ( (isValidDate(txtDate.value) || txtDate.value == '') && isDateValidFormatSmallDateTime(txtDate.value) ) { document.getElementById('txtDateRetour').value = txtDate.value; } else { txtDate.value = ""; alert('Invalid date.'); txtDate.focus(); return false; } } function verifDateRetour() { var txtDate = document.getElementById('txtDateRetour'); if ( !isValidDate(txtDate.value) || !isDateValidFormatSmallDateTime(txtDate.value) ) { txtDate.value = ""; alert('Invalid date.'); txtDate.focus(); return false; } } function isDateValidFormatSmallDateTime(dateAVerif) { var strLowDate = new String("01/01/1900"); var strHighDate = new String("05/06/2079"); var strdte = new String(dateAVerif); if (isDate1LowerOrEqualThanDate2(strdte,strHighDate) && isDate1LowerOrEqualThanDate2(strLowDate,strdte)) { return true; } else { return false; } } function getJour(dte) { var strDte = new String(dte); if(strDte.length > 10 || strDte.length < 8) return false; // Création d'un objet qui adapte la date selon la langue dateAdaptee = new _dateAdapter(strDte); return dateAdaptee.jour; } function getMois(dte) { var strDte = new String(dte); if(strDte.length > 10 || strDte.length < 8) return false; dateAdaptee = new _dateAdapter(strDte); return dateAdaptee.mois; } function getAnnee(dte) { var strDte = new String(dte); if(strDte.length > 10 || strDte.length < 8) return false; dateAdaptee = new _dateAdapter(strDte); return dateAdaptee.annee; } function getDates() { var txtDateDepartAller = document.getElementById('txtDateAller'); var txtDateDepartRetour = document.getElementById('txtDateRetour'); document.getElementById('Annee_Aller').value = getAnnee(txtDateDepartAller.value); document.getElementById('Mois_Aller').value = getMois(txtDateDepartAller.value); document.getElementById('Jour_Aller').value = getJour(txtDateDepartAller.value); document.getElementById('Annee_Retour').value = getAnnee(txtDateDepartRetour.value); document.getElementById('Mois_Retour').value = getMois(txtDateDepartRetour.value); document.getElementById('Jour_Retour').value = getJour(txtDateDepartRetour.value); } function checkForm() { var cmbDep = document.getElementById('id_depart'); var cmbArr = document.getElementById('id_arrivee'); var idDep = cmbArr.options[cmbArr.options.selectedIndex].value; var idArr = cmbDep.options[cmbDep.options.selectedIndex].value; var txtDateDepartAller; txtDateDepartAller = document.getElementById('txtDateAller'); var txtDateDepartRetour; txtDateDepartRetour = document.getElementById('txtDateRetour'); var rdTypeTrajetAllerSimple; rdTypeTrajetAllerSimple = document.getElementById('TypeTrajetAllerSimple'); if (txtDateDepartAller.value == '' || (txtDateDepartRetour.value == '' && !rdTypeTrajetAllerSimple.checked) || idDep == '' || idArr == '') { alert('Please, enter every mandatory field.'); return; } else if ( rdTypeTrajetAllerSimple.checked && ( txtDateDepartAller.value == '' || !isValidDate(txtDateDepartAller.value))) { alert('Invalid date.'); txtDateDepartRetour.focus(); txtDateDepartRetour.value = ''; return; } else if ( !rdTypeTrajetAllerSimple.checked && (( txtDateDepartAller.value == '' || !isValidDate(txtDateDepartAller.value)) || (txtDateDepartAller.value == '' || !isValidDate(txtDateDepartAller.value)))) { alert('Invalid date.'); txtDateDepartRetour.focus(); txtDateDepartRetour.value = ''; return; } else if ( !rdTypeTrajetAllerSimple.checked && !isDate1LowerOrEqualThanDate2(txtDateDepartAller.value, txtDateDepartRetour.value) ) { alert('Returning date is lower than departing date.'); txtDateDepartRetour.focus(); txtDateDepartRetour.value = ''; return; } else { getDates(); checkopen(); showWaitingMess(); document.frmbook.submit(); } } // Duplication de la fonction checkForm() // mise en place sur JetForYou (/Wondair) // suppression de l'alerte sur les dates car la compagnie fait des vols dans la journée function checkFormAR() { var cmbDep = document.getElementById('id_depart'); var cmbArr = document.getElementById('id_arrivee'); var idDep = cmbArr.options[cmbArr.options.selectedIndex].value; var idArr = cmbDep.options[cmbDep.options.selectedIndex].value; var txtDateDepartAller; txtDateDepartAller = document.getElementById('txtDateAller'); var txtDateDepartRetour; txtDateDepartRetour = document.getElementById('txtDateRetour'); var rdTypeTrajetAllerSimple; rdTypeTrajetAllerSimple = document.getElementById('TypeTrajetAllerSimple'); if (txtDateDepartAller.value == '' || (txtDateDepartRetour.value == '' && !rdTypeTrajetAllerSimple.checked) || idDep == '' || idArr == '') { alert('Please, enter every mandatory field.'); return; } else if ( !rdTypeTrajetAllerSimple.checked && !isDate1LowerOrEqualThanDate2(txtDateDepartAller.value, txtDateDepartRetour.value) ) { txtDateDepartRetour.focus(); txtDateDepartRetour.value = ''; return; } else { getDates();checkopen(); showWaitingMess(); document.frmbook.submit(); } } // Duplication of CheckForm() function // Removing the form.submit action function checkFormWithoutSubmit() { var cmbDep = document.getElementById('id_depart'); var cmbArr = document.getElementById('id_arrivee'); var idDep = cmbArr.options[cmbArr.options.selectedIndex].value; var idArr = cmbDep.options[cmbDep.options.selectedIndex].value; var txtDateDepartAller; txtDateDepartAller = document.getElementById('txtDateAller'); var txtDateDepartRetour; txtDateDepartRetour = document.getElementById('txtDateRetour'); var rdTypeTrajetAllerSimple; rdTypeTrajetAllerSimple = document.getElementById('TypeTrajetAllerSimple'); if (txtDateDepartAller.value == '' || (txtDateDepartRetour.value == '' && !rdTypeTrajetAllerSimple.checked) || idDep == '' || idArr == '') { alert('Please, enter every mandatory field.'); return false; } else if ( rdTypeTrajetAllerSimple.checked && ( txtDateDepartAller.value == '' || !isValidDate(txtDateDepartAller.value))) { alert('Invalid date.'); txtDateDepartRetour.focus(); txtDateDepartRetour.value = ''; return false; } else if ( !rdTypeTrajetAllerSimple.checked && (( txtDateDepartAller.value == '' || !isValidDate(txtDateDepartAller.value)) || (txtDateDepartAller.value == '' || !isValidDate(txtDateDepartAller.value)))) { alert('Invalid date.'); txtDateDepartRetour.focus(); txtDateDepartRetour.value = ''; return false; } else if ( !rdTypeTrajetAllerSimple.checked && !isDate1LowerOrEqualThanDate2(txtDateDepartAller.value, txtDateDepartRetour.value) ) { alert('Returning date is lower than departing date.'); txtDateDepartRetour.focus(); txtDateDepartRetour.value = ''; return false; } else { getDates();checkopenWithoutSubmit(); showWaitingMess(); } return true; } function isDate1LowerOrEqualThanDate2(dte1, dte2) { var j1 = parseInt(getJour(dte1), 10); var j2 = parseInt(getJour(dte2), 10); //alert("jour date aller : " + j1 + " et jour date retour : " + j2); var m1 = parseInt(getMois(dte1), 10); var m2 = parseInt(getMois(dte2), 10); //alert("mois date aller : " + m1 + " et mois date retour : " + m2); var a1 = parseInt(getAnnee(dte1), 10); var a2 = parseInt(getAnnee(dte2), 10); //alert("annee date aller : " + a1 + " et annee date retour : " + a2); if (a1 == a2) { //alert("je suis dans le if des annees"); if (m1 == m2) { //alert("je suis dans le if des mois"); return j1 <= j2; } else { //alert("je suis dans le else des mois"); return m1 <= m2; } } else { //alert("je suis dans le else des annees"); return a1 <= a2; } } function setDate(dte, isAller) { if (isAller == 1) { var txtDateDepartAller; txtDateDepartAller = document.getElementById('txtDateAller'); txtDateDepartAller.value = dte; } else { var txtDateDepartRetour; txtDateDepartRetour = document.getElementById('txtDateRetour'); txtDateDepartRetour.value = dte; } } function closeDiv(isAller) { var divCal; if (isAller == 1) { divCal = document.getElementById('divCalAller'); } else { divCal = document.getElementById('divCalRetour'); } divCal.style.display = 'none'; } function hideCalendar(isAller) { var nomCal = 'divCalRetour' if (isAller == 1) { nomCal = 'divCalAller'; } divCal = document.getElementById(nomCal); if (verifIdDepartAndIdRetour()) { divCal.style.display = 'none'; } }