// JavaScript Document
function getTop(MyObject) {
if (MyObject.offsetParent) return (MyObject.offsetTop + getTop(MyObject.offsetParent));
else return (MyObject.offsetTop);
}
function getLeft(MyObject) {
if (MyObject.offsetParent) return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
else return (MyObject.offsetLeft);
}
function ShowTipsPassengers() {
// Change the size of the iFrame tips on Opera navigator
var iFrame=document.getElementById("popup2iFrame");
var popup1Cmp=document.getElementById("popup1");
var popup2Cmp=document.getElementById("popup2");
if (navigator.userAgent.toLowerCase().indexOf('opera') != -1) {
iFrame.style.width="0px";
iFrame.style.height="0px";
} else {
var sX=popup1Cmp.offsetWidth+"px";
var sY=popup1Cmp.offsetHeight+"px";
iFrame.style.width=sX;
iFrame.style.height=sY;
popup2Cmp.style.width=sX;
popup2Cmp.style.height=sY;
}
// Move the position of the tips
var iCmp = document.getElementById("lnkTraInfo");
var pY = getTop(iCmp) + 15;
var pX = getLeft(iCmp) + 15;
popup1Cmp.style.top=pY+"px";
popup1Cmp.style.left=pX+"px";
popup2Cmp.style.top=pY+"px";
popup2Cmp.style.left=pX+"px";
// Force the size of the iframe and div to 0 in case IE < 5.1
var navig = navigator.userAgent.toLowerCase();
var msie50x = navig.indexOf("msie 5.0");
if (msie50x != -1) {
popup2Cmp.style.width=0;
popup2Cmp.style.height=0;
iFrame.style.height=0;
iFrame.style.width=0;
}
MM_showHideLayers('popup2','','show','popup1','','show');
}
function HideTipsPassengers() {
var iFrame=document.getElementById("popup2iFrame");
iFrame.style.width="0px";
iFrame.style.height="0px";
MM_showHideLayers('popup2','','hide','popup1','','hide');
}
// Set variables for DateLists in OneWay tab
function DateListsInitO () {
if (ADVS.OneWayDateListNotInitialized) {
DateList1 = new DateList();
// Date lists management
// Data comming from DataMap, booking engine, DataBase
DateList1.monthsNames = ["Ene ","Feb ","Mar ","Abr ","May ","Jun ","Jul ","Ago ","Sep ","Oct ","Nov ","Dic ",""];
DateList1.daysNames = ["Domingo ","Lunes ","Martes ","Miércoles ","Jueves ","Viernes ","Sábado ",""];
DateList1.startAvailDate = "H12";
DateList1.endAvailDate = "M10";
DateList1.currentDate = new Date();
DateList1.betweenDays = 1;
// HTML components
DateList1.classDisabled = "dateListsDisabled";
//DateList1.grpStart = [document.ADVSForm.Month1,document.ADVSForm.Day1,document.getElementById("originDateDayOfWeekCell1"),document.ADVSForm.Hours1];
DateList1.grpStart = [document.ADVSForm.Month1,document.ADVSForm.Day1,document.getElementById("originDateDayOfWeekCell1"),document.getElementById("Hours1")];
DateList1.initDateLists();
DateList1.setDateTimeComposedString(DateList1.grpStart,"","");
// Init with old values in case of Back navigator
var beginDate=document.getElementById("backB1Date").value;
if (beginDate != "") DateList1.setDateTimeComposedString(DateList1.grpStart,beginDate,"");
ADVS.OneWayDateListNotInitialized = false;
}
}
// Set variables for DateLists in RoundTrip tab
function DateListsInitR () {
if (ADVS.RoundTripDateListNotInitialized) {
var initDate = "";
if (!ADVS.OneWayDateListNotInitialized) {   // One way has already been displayed, wee keep the current date of components
initDate = DateList1.getDateTimeComposedString(DateList1.grpStart);
}
DateList1 = new DateList();
// Date lists management
// Data comming from DataMap, booking engine, DataBase
DateList1.monthsNames = ["Ene ","Feb ","Mar ","Abr ","May ","Jun ","Jul ","Ago ","Sep ","Oct ","Nov ","Dic ",""];
DateList1.daysNames = ["Domingo ","Lunes ","Martes ","Miércoles ","Jueves ","Viernes ","Sábado ",""];
DateList1.startAvailDate = "H12";
DateList1.endAvailDate = "M10";
DateList1.currentDate = new Date();
DateList1.betweenDays = 1;
// HTML components
DateList1.classDisabled = "dateListsDisabled";
DateList1.grpStart = [document.ADVSForm.Month1,document.ADVSForm.Day1,document.getElementById("originDateDayOfWeekCell1"),document.getElementById("Hours1")];
DateList1.grpEnd = [document.ADVSForm.Month2,document.ADVSForm.Day2,document.getElementById("returnDateDayOfWeekCell"),document.getElementById("Hours2")];
DateList1.initDateLists();
if (initDate != "") {     // Init with date of One Way tab
DateList1.setDateTimeComposedString(DateList1.grpStart,initDate,"!");
} else {                  // Init with old values in case of Back navigator
var endDate=document.getElementById("backE1Date").value;
if (endDate != "") DateList1.setDateTimeComposedString(DateList1.grpEnd,endDate,"");
else {
DateList1.setDateTimeComposedString(DateList1.grpEnd,"","");
}
var beginDate=document.getElementById("backB1Date").value;
if (beginDate != "") DateList1.setDateTimeComposedString(DateList1.grpStart,beginDate,"");
else {
DateList1.setDateTimeComposedString(DateList1.grpStart,"","");
}
}
ADVS.OneWayDateListNotInitialized = false;
ADVS.RoundTripDateListNotInitialized = false;
}
}
// Set variables for DateLists in Complex tab
function DateListsInitC() {
if (ADVS.ComplexDateListNotInitialized) {
hasBeenModifiedByUser = new Array();
var numbOfStep = 7;
for(var i=1; i<numbOfStep; i++){
hasBeenModifiedByUser[i] = false;
month = "document.ADVSForm.Month" + i +"Cpx";
day = "document.ADVSForm.Day" + i+"Cpx";
hours = "Hours"+i+"Cpx";
weekDay = "originDateDayOfWeekCell" + i+"Cpx";;
eval("var tmpDateList = new DateList();");
// Date lists management
// Data comming from DataMap, booking engine, DataBase
tmpDateList.monthsNames = ["Ene ","Feb ","Mar ","Abr ","May ","Jun ","Jul ","Ago ","Sep ","Oct ","Nov ","Dic ",""];
tmpDateList.daysNames = ["Domingo ","Lunes ","Martes ","Miércoles ","Jueves ","Viernes ","Sábado ",""];
tmpDateList.startAvailDate = "H12";
tmpDateList.endAvailDate = "M10";
tmpDateList.currentDate = new Date();
tmpDateList.betweenDays = 1;
// HTML components
tmpDateList.classDisabled = "dateListsDisabled";
tmpDateList.grpStart = [eval(month),eval(day),document.getElementById(weekDay),document.getElementById(hours)];
tmpDateList.initDateLists();
if (i!=1) eval("Add7Days(DateList"+(i-1)+"Cpx,tmpDateList,\"TRUE\");");
eval("DateList"+i+"Cpx = tmpDateList;");
// Init with old values in case of Back navigator
var dateCpx=document.getElementById("backB"+i+"CpxDate").value;
if (dateCpx != "")
tmpDateList.setDateTimeComposedString(tmpDateList.grpStart,dateCpx,"TRUE");
}
// init with values returned by BE (in case no back browser)
if (document.getElementById("backTRIP_TYPE").value == "") {
}
ADVS.ComplexDateListNotInitialized = false;
}
// Init first date with departure date of One Way or Round trip tab
if (!ADVS.OneWayDateListNotInitialized) {   // One way or Round trip has already been displayed, wee keep the current date of components
var initDate = DateList1.getDateTimeComposedString(DateList1.grpStart);
var hoursOW = document.getElementById("Hours1");
var anyTime = "FALSE";
if (hoursOW && hoursOW.value == "ANY")
anyTime = "TRUE";
DateList1Cpx.setDateTimeComposedString(DateList1Cpx.grpStart,initDate,anyTime);
Add7DaysToAllNextSegments(1);
}
}
function Add7Days (bDateList,eDateList,eAnyTime) {
var expr = "eDateList.setDateTimeComposedString(eDateList.grpStart,\"";
eval("var prevDate = bDateList.getDateTimeComposed(bDateList.grpStart);");
var prevDateTime = prevDate.getTime();   // Time of prevDate (milliseconds since 1970)
prevDate.setTime(prevDateTime+(1 * 24 * 60 * 60 * 1000));   // 7 days in milliseconds
// Convert date to String
var prevDateString = "";
var prevDateYear = prevDate.getYear();
var prevDateMonth = prevDate.getMonth() + 1;
var prevDateDay = prevDate.getDate();
var prevDateHours = prevDate.getHours();
var prevDateMinutes = prevDate.getMinutes();
var prevDateSeconds = prevDate.getSeconds();
if (prevDateYear < 1000) prevDateYear+=1900;
prevDateString += prevDateYear;
if (prevDateMonth<10) prevDateString += "0";
prevDateString += prevDateMonth;
if (prevDateDay<10) prevDateString += "0";
prevDateString += prevDateDay;
if (prevDateHours<10) prevDateString += "0";
prevDateString += prevDateHours;
if (prevDateMinutes<10) prevDateString += "0";
prevDateString += prevDateMinutes;
if (prevDateSeconds<10) prevDateString += "0";
prevDateString += prevDateSeconds;
expr += prevDateString;
expr += "\",eAnyTime);";
eval(expr);
}
function Add7DaysToAllNextSegments (currentSegment) {
hasBeenModifiedByUser[currentSegment] = true;
var numbOfStep = 7;
for(segmentIndex=currentSegment+1;segmentIndex<numbOfStep;segmentIndex++) {
if (! hasBeenModifiedByUser[segmentIndex]) {
var exprSegment = "Add7Days(DateList"+(segmentIndex-1)+"Cpx,DateList"+segmentIndex+"Cpx,\"TRUE\");";
eval(exprSegment);
}
}
}
function LocationsInitOR () {
if (ADVS.LocationORNotInitialized) {
// Init B_Location and E_Location smartdropdown and fields with old value in case of back navigator
var B_LOC = "";
var E_LOC = "";
var backBLoc = document.getElementById("backB_LOCATION_1").value;
var backELoc = document.getElementById("backE_LOCATION_1").value;
if (backBLoc != "") {
B_LOC = backBLoc;
E_LOC = backELoc;
document.ADVSForm.B_LOCATION_1.value=backBLoc;
document.ADVSForm.E_LOCATION_1.value=backELoc;
} else {
}
ADVS.LocationORNotInitialized = false;
}
}
function LocationsInitM () {
if (ADVS.LocationMNotInitialized) {
var numbOfStep = 7;
// Init B_Location and E_Location fields with old value in case of back navigator
for(var i=1;i<numbOfStep;i++) {
eval("var backBLoc = document.getElementById('backB_LOCATION_"+i+"_Cpx').value;");
eval("var backELoc = document.getElementById('backE_LOCATION_"+i+"_Cpx').value;");
if (backBLoc != "") {
eval("document.getElementById('B_LOCATION_"+i+"_Cpx').value = backBLoc;");
eval("document.getElementById('E_LOCATION_"+i+"_Cpx').value = backELoc;");
}
}
ADVS.LocationMNotInitialized = false;
}
}
// Set the flexible by dropdown list
function FlexibleByInitO () {
if (ADVS.FlexibleByONotInitialized) {
var dateRange1 = document.ADVSForm.DATE_RANGE_VALUE_1;
if (dateRange1 && dateRange1.tagName.toLowerCase()=="select") {
for(i=0;i<dateRange1.options.length;i++) {
dateRange1.options[i].selected=false;
}
dateRange1.options[0].selected=true;
dateRange1.selectedIndex = 0;
ADVS.showTimeSelection(document.ADVSForm.FLEXIBLE_CHK_1,1);
ADVS.showTimeSelection(document.ADVSForm.DATE_RANGE_VALUE_1,1);
}
ADVS.FlexibleByONotInitialized = false;
}
}
// Set the flexible by dropdown list
function FlexibleByInitR () {
if (ADVS.FlexibleByRNotInitialized) {
var dateRange2 = document.ADVSForm.DATE_RANGE_VALUE_2;
if (dateRange2 && dateRange2.tagName.toLowerCase()=="select") {
for(i=0;i<dateRange2.options.length;i++) {
dateRange2.options[i].selected=false;
}
dateRange2.options[0].selected=true;
dateRange2.selectedIndex = 0;
ADVS.showTimeSelection(document.ADVSForm.FLEXIBLE_CHK_2,2);
ADVS.showTimeSelection(document.ADVSForm.DATE_RANGE_VALUE_2,2);
}
ADVS.FlexibleByRNotInitialized = false;
}
}
// Set the commercial fare family dropdown list
function CommercialFFInit () {
if (ADVS.CommercialFFRNotInitialized) {
var commercialFF;
var indexToSelect;
commercialFF = document.ADVSForm.COMMERCIAL_FARE_FAMILY_1;
if (commercialFF) {
indexToSelect = -1;
for(i=0;i<commercialFF.options.length;i++) {
commercialFF.options[i].selected=false;
if (commercialFF.options[i].value == "") {
indexToSelect = i;
}
}
if (indexToSelect != -1) {
commercialFF.options[indexToSelect].selected=true;
commercialFF.selectedIndex = indexToSelect;
}
}
ADVS.CommercialFFRNotInitialized = false;
}
}
function selectOTab() {
// Display Tab components
ADVS.showTripTypeForm('O',ADVS.searchFlow);
// Set components
FlexibleByInitO();
LocationsInitOR();
DateListsInitO();
CommercialFFInit();
// Display Tab components (second time for refreshing the departure time with flexible by choice)
ADVS.showTripTypeForm('O',ADVS.searchFlow);
}
function selectRTab() {
// Display Tab components
ADVS.showTripTypeForm('R',ADVS.searchFlow);
// Set components
FlexibleByInitO();
FlexibleByInitR();
LocationsInitOR();
DateListsInitR();
CommercialFFInit();
// Display Tab components (second time for refreshing the departure time with flexible by choice)
ADVS.showTripTypeForm('R',ADVS.searchFlow);
}
function selectMTab() {
// Display Tab components
ADVS.showTripTypeForm('M',ADVS.searchFlow);
// Set components
LocationsInitM();
DateListsInitC();
}
function ADVS_applyFareTypeListChange(searchFlow) {
return;
}
function ADVS_applyTimeListChange(searchFlow) {
return;
}
function applyMasterPricerNumberOfStep(searchFlow) {
return;
}
function applyRangeCheckbox(searchFlow) {
return;
}
function ADVS_pageOnLoad () {
LocalErrorInit();
// Search requested
ADVS.isMasterPricerSearch = true;
ADVS.isWebfaresSearch = false;
ADVS.isWebSearchButton = false;
// In case of back, display the correct tab
var backPricingType = document.getElementById("backPricingType");
if(backPricingType){
if(backPricingType.value !=""){
ADVS.searchFlow = backPricingType.value;
}
}
var backTripType = document.getElementById("backTRIP_TYPE").value;
if (backTripType != "") {     // A back browser
eval("select"+backTripType+"Tab();");
} else {                      // Not a back browser
eval("select"+ADVS.tripType+"Tab();");
// this method to display the BE error has not to be called in case
// of back browser as if there is a back browser, this means that
// there is no more BE error since the user does a back on the avail
// page. And as the browser keeps the BE error which is set in jstl
// this method has to be called only if this is not a back !
initWDSErrorBE();
}
}