// JavaScript Document
function wsClickTrack(obj)
 {
}
					
function updateSearchPaths() {
var semiFlexOption='COMPLEX';
var classOfService='ENABLE';
var matrixOn='DISABLE';
    if ( document.RequestAirForm.actionType == null ) {
        acType='nonFlex';
    }
    else if ( document.RequestAirForm.actionType.length == null ) {
        acType=document.RequestAirForm.actionType.value;
    }
    else {
        for (i=0; i < document.RequestAirForm.actionType.length; i++) {
            if (document.RequestAirForm.actionType[i].checked) {
                acType=document.RequestAirForm.actionType[i].value;
                break;
            }
        }
    }
    for (i=1;i<=6;i++) {
        var coupon="couponNumber"+i;
        if((document.getElementById(coupon) != null || (document.getElementById("promoCode") != null) )
            && (acType == 'redeemMiles'))
         {
            if(document.getElementById(coupon).value !='' || (document.getElementById("promoCode").value != '') )
            {
                				alert("meridia.air.request.notavalidcombination");
                return false;
            }
         }
     }
    if(((document.getElementById("refundableSearch") != null)
	    && document.RequestAirForm.refundableSearch.checked)
	    && ((acType == 'redeemMiles') || (acType == 'flex') || (acType == 'flexSimple') || (matrixOn == 'ENABLE' && acType == 'nonFlex')))
    {
       	   alert("meridia.air.request.notavalidpath");
        return false;
    }
    else
    {

        if(((document.getElementById("alternateDates") != null)
            && document.RequestAirForm.alternateDates.checked)
            && (acType != 'semiFlex'))
        {
            			alert("meridia.air.request.notvalidwithaltdate");
            return false;
        }
        if (acType != null && acType == 'semiFlex' && semiFlexOption == 'INTELLISELL')
        {
           document.RequestAirForm.page.value='ssw_SemiFlexOutboundMessage';
           document.RequestAirForm.action.value='SSWSemiFlexService';
           var altDates = document.RequestAirForm.alternateDates;
           if((altDates) && ((altDates.value=='checked') || (altDates.checked)))
           {
                document.RequestAirForm.page.value='ssw_SemiFlexAlternateDatesMessage';
                document.RequestAirForm.action.value='SSWSemiFlexAlternateDates';
                document.RequestAirForm.alternateDates.value='on';
           }
       }
       else if (acType != null && acType == 'redeemMiles') {
           document.RequestAirForm.page.value='ssw_RedeemMilesSearchMessage';
           document.RequestAirForm.action.value='SSWAirAvailService';
       }
       else if (document.RequestAirForm.requestPage.value == 'ssw_CurrentItinReqMessage') {
           document.RequestAirForm.page.value='ssw_CurrentItinReqMessage';
           document.RequestAirForm.action.value='airRequest';
       }
       else {
           document.RequestAirForm.page.value='requestAirMessage_air';
           document.RequestAirForm.action.value='airRequest';
       }
	   		bbrPaxLimitCheck();
	       return true;
    }
}
//
// entry point
//
theToday = new Date();
var dialog;

function openCalendar (monthFldName, dateFldname, monthFldName1, dateFldname1, formNumber, calendarContainer) {

    var loader = new YAHOO.util.YUILoader({
        require: ['calendar', 'container', 'event', 'dom'],
        filter: "DEBUG",
        loadOptional: true,
        base: 'https://ww3.dotres.com/application/javascript/yui/build/',
        onSuccess: function() {
            YAHOO.namespace("com.sabre.gui.calendar");
            
            YAHOO.util.Event.addListener(document, "click", function(e) { 
                var el = YAHOO.util.Event.getTarget(e); 
               var dialogEl = dialog.element; 
            
                if ((el != dialogEl) && (el.nodeName.toUpperCase() != "A")) {
                    dialog.hide();
                    applyStyleToFormElements("select-one", "visible");
                } 
            }); 

			$(calendarContainer).innerHTML = "<div id=\"cal_" + calendarContainer + "\"></div>";

            YAHOO.com.sabre.gui.calendar.init = function() {
                var short_date_format = 'dd-M-yy';
                var dateField = document.forms[0][dateFldname];
                var monthField = document.forms[0][monthFldName];
                theMaxDate = new Date();
                theMaxDate.setDate(theMaxDate.getDate()+330);
                
                var theNewToday = new Date();
                theNewToday.setMonth(monthField.selectedIndex);
                theNewToday.setYear(theYear);
                if (theToday > theNewToday) {
                    theYear++;
               }

                var theYear = theToday.getFullYear();
                
                YAHOO.com.sabre.gui.calendar.cal1 = new YAHOO.widget.CalendarGroup("cal_"+calendarContainer+"_id", "cal_"+calendarContainer, {LOCALE_WEEKDAYS: "1char", PAGES: 2, pagedate: [monthField.selectedIndex+1, theYear].join("/"), selected: [monthField.selectedIndex+1, dateField.value, theYear].join("/"), mindate: theToday, maxdate: theMaxDate, iframe: false});
                YAHOO.com.sabre.gui.calendar.cal1.selectEvent.subscribe(calendarSelectHandler, YAHOO.com.sabre.gui.calendar.cal1, true);
                YAHOO.com.sabre.gui.calendar.cal1.cfg.setProperty("MONTHS_LONG", ["January",
                                                                                  "February",
                                                                                  "March",
                                                                                  "April",
                                                                                  "May",
                                                                                  "June",
                                                                                  "July",
                                                                                  "August",
                                                                                  "September",
                                                                                  "October",
                                                                                  "November",
                                                                                  "December"]);
                YAHOO.com.sabre.gui.calendar.cal1.cfg.setProperty("WEEKDAYS_1CHAR", ["S",
                                                                                     "M",
                                                                                     "T",
                                                                                     "W",
                                                                                     "T",
                                                                                     "F",
                                                                                     "S"]);

                YAHOO.com.sabre.gui.calendar.cal1.render();
			
                function calendarSelectHandler(type, args, obj) {
                    dialog.hide();
                    applyStyleToFormElements("select-one", "visible");
                    dateField.selectedIndex = (args[0][0][2] - 1);
                    monthField.selectedIndex = (args[0][0][1] - 1);
                    theYear = args[0][0][0];
                }
            }

            YAHOO.com.sabre.gui.calendar.init();
    		dialog = new YAHOO.widget.Dialog(calendarContainer, {
                context: ["show", "tl", "bl"],
                close: false,
                draggable: false
            });
            
            applyStyleToFormElements("select-one", "hidden");
           dialog.render();
       },
       onFailure: function(o) {
           alert("error: " + YAHOO.lang.dump(o));
       }
   });

    loader.insert();
}

function updateReturnDate(formName) {
// create new date objects just in case
	var d = new Date();
	var dYear = d.getFullYear();
	var dMonth = formName.depMonth.selectedIndex;
	var dDay = formName.depDay.selectedIndex;
	var today = new Date();
    // set the return day and month currently selected to variables
	var rDy = formName.retDay.selectedIndex;
	var rMon =formName.retMonth.selectedIndex;
     // get the year
	var rYr = d.getFullYear();
	// for next year if the return month is numerically less than the
	//current month then add 1 year

	if (formName.retMonth.selectedIndex < d.getMonth())
	{
		rYr = rYr+1;
	}
    // for next year same as above only for departure
	if (formName.depMonth.selectedIndex < d.getMonth())
	{
		dYear = dYear+1;
	}
	rDate = new Date(rYr, rMon, rDy);
	dDate = new Date(dYear, dMonth, dDay+defaultDepart);
	var rYear = dYear;
	var rMonth = '0';
	var rDay = '0';
	// 30 Days: April-3 June-5 September-8 November-10
	// 31 Days: January-0, March-2, May-4, July-6, August-7, October-9, December-11
	// 28 Days: February-1
	// For Months with 31 days

	if ( (dMonth == '0' || dMonth == '2' || dMonth == '4' || dMonth == '6' || dMonth == '7' || dMonth == '9' || dMonth == '11' )){
		if (dDay == '29') {
			rDay = '0';
// If December, set month back to '0' for January
		if (dMonth == '11') {
			rMonth = '0';
		} else {
			rMonth = dMonth + 1;
		}
	} else if (dDay == '30') {
	rDay = '1';
// If December, set month back to '0' for January
		if (dMonth == '11') {
			rMonth = '0';
		} else {
			rMonth = dMonth + 1;
		}
	} else {
		rDay = dDay + 2;
		rMonth = dMonth;
	}
       // For Months with 30 days
			} else if ((dMonth == '3' || dMonth == '5' || dMonth == '8' || dMonth == '10' )) {
             /* test for invalid dates */
				if (dDay == '30') {
					dDay = '30'; eval (formName.depDay.selectedIndex = dDay);
				}
				if (dDay == '28' || dDay == '29') {
					rDay = '0';
					rMonth = dMonth + 1;
				} else if (dDay == '30') {
					rDay = '1';
					rMonth = dMonth + 1;
				} else {
					rDay = dDay + 2;
					rMonth = dMonth;
				}
				// For February, check for leapyear.

			} else if (dMonth == '1') {
				if (dMonth > rMonth) { rYear += 1; }
                  // Check to see if Feb 29, 30, or 31 is selected for NON-leapyear.
			      // If so, set departure date to Feb 28.


				if ((!leapYear(rYear) && dDay == '28') || dDay == '29' || dDay == '30') {
					dDay = dDay; eval (formName.depDay.selectedIndex = dDay);
				}
				if ((leapYear(rYear) && dDay == '27') || (!leapYear(rYear) && dDay == '26') || dDay ==29 ) {
					rDay = '0'; rMonth = dMonth + 1;
				} else if ((leapYear(rYear) && dDay == '28') || (!leapYear(rYear) && dDay == '27') || dDay == '30' || (!leapYear(rYear) && dDay == '28')) {
				rDay = '1';
				rMonth = dMonth + 1;
				} else {
					rDay = dDay + 2;
					rMonth = dMonth;
				}
			}
        //check to see if on different page
		if(formName.dateChanged != null && formName.dateChanged.value == 'true') return;
		if(formName.retDay.changed == null && formName.changed == null){
			eval (formName.retDay.selectedIndex = rDay);
		}
		if( formName.retMonth.changed == null && formName.changed == null){
			eval (formName.retMonth.selectedIndex = rMonth);
		}
		return;
}

function appendCouponInfo(url)
            {
                window.location.href = buildCouponInfo(url);
            }
function buildCouponInfo(url)
            {
                                                                                                
                //window.location.href = url;
                return url;
            }
//This submit is for iMac
   function confirmNRFATerms() {
		if (document.forms[0].terms.checked) {
			return true;
		}
		else {
			document.forms[0].page.value=document.forms[0].page.value;
			document.forms[0].action.value=document.forms[0].action.value;
			return true;
		}
	}

	function confirmUMNRTerms() {
		if (document.forms[0].terms.checked) {
			return true;
		}
		else {
			document.forms[0].requestPage.value=document.forms[0].page.value;
			document.forms[0].requestAction.value=document.forms[0].action.value;
			document.forms[0].terms.value='false';
			document.forms[0].page.value='ssw_UnaccompaniedMinorMessage';
			document.forms[0].action.value='SSWUnaccompaniedMinor';
			document.forms[0].terms.value='false';
			return true;
		}
	}
	var win;
function openSearchPopup(openUrl, title, scrsize) {
	win = window.open(openUrl , title, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200"+scrsize);
	win.focus();
}
function submit(){
   document.forms[0].submit();
}
function exchangeReplace(baseurl)
{
var url=baseurl ;
for (var j=0; j< document.forms[0].length; j++)
    {
        if(document.forms[0].elements[j].type=='checkbox')
            {
                if(document.forms[0].elements[j].checked)
                {
                    url = url+document.forms[0].elements[j].name + '=on&';
                }
            }
       else if(document.forms[0].elements[j].type=='radio')
            {
                 if(document.forms[0].elements[j].checked)
                {
                    url = url+document.forms[0].elements[j].name + '=' + document.forms[0].elements[j].value +'&';
                }
            }
        else
            {
                url = url+document.forms[0].elements[j].name + '=' + document.forms[0].elements[j].value +'&';
            }
    }
    window.location.replace(url);
}
var shopSeatMap;
function loadShopSeatMap(url) {
shopSeatMap=window.open(url,"seatMap","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=500,alwaysRaised=yes,dependent=yes,screenX=800,screenY=800");
shopSeatMap.focus();
}
function SwapX(graphic) {
if ((document[graphic] != null) && (browserVer >= "4") || ((browserName == "Netscape") && (browserVer == "3"))) {
document[graphic].src=("asterisk.gif");
}
}
function SwapY(graphic) {
if ((document[graphic] != null) && (browserVer >= "4") || ((browserName == "Netscape") && (browserVer == "3"))) {
document[graphic].src=("p.gif");
}
}
var ageWin;
function openAge (url) {
ageWin=window.open(url,'age',"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=670,height=350,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
ageWin.focus();
}

var CityWin
function openCity (posid,returnToForm,returnToTextBox,commercialFlag) {
CityWin=window.open('https://ww3.dotres.com/meridia?posid=56BA&sid=me2re72r9r2mv1-iyyv:d226e9a26020d40a326f075f39a5e73ac5b8bc1128ecffe03701cdaabe92e654&&page=findCityMessage_default&posid=' + posid + '&action=findCity&returnToForm=' + returnToForm + '&returnToTextBox=' + returnToTextBox + '&commercialFlag=' + commercialFlag,'CityWin',"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=435,height=380,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
CityWin.focus();
}

function getChainCode()
{
document.forms[0].hotel1Value.value='SA';
}

function confirmRedirect(alertMsg) {
	input_box=confirm(alertMsg);
	if (input_box==true) {
	// Output when OK is clicked
		return true;

	}
	else {
	// Output when Cancel is clicked
		return false;
	}
}
function doRefresh(actualUrl,toaction,pagenum,recordLocator,page){

    var lang = document.forms[0].language.options[document.forms[0].language.selectedIndex].value;
    var dt = new Date();
    var x = dt.getTime();
    var tempstr=actualUrl+"&language="+lang+"&action="+toaction+"&timestamp="+x+"&PageNumber="+pagenum+"&RecordLocator="+recordLocator+"&page="+page;
				self.location.replace(tempstr);
}

var isLoaded = false;
function loaded() {
  isLoaded =true;
}

//changed the link in the window.open  for the SPR 22156
function openVT(language,airlineCode){
var lang=language;
var airline=airlineCode;
var  win = window.open('https://www.virtuallythere.com/new/homePage.html?pnr=&name=&language='+lang+'&host='+airline+'&pcc=&clocktype=12&error=&nosub=N','VTO',
    'width=670,height=350,screenX=200,screenY=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
    win.focus();
}
//change ends for SPR 22156

var windowParam="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=670,height=300,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200";
var cRateWin;
function openCarRateWin (url) {
cRateWin=window.open(url,'carPolicyWin',windowParam);
cRateWin.focus();
}

var agencyInfoWin;
function openAgencyRate (url) {
	agencyInfoWin=window.open(url,'AgencyRateInformation',"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width=670,height=	350,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
	agencyInfoWin.focus();
}

var fareRulesWin;
function openFareRules (url) {
	fareRulesWin=window.open(url,'FareRules',"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=670,height=500,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
	fareRulesWin.focus();
}

var faqWin;
function openfaq (url) {
faqWin=window.open('faq.html','faqWin',windowParam);
faqWin.focus();
}

var openTaxesFees;
function openTaxesFees(url){
var dt = new Date();
var x = dt.getTime();
actualUrl=url+"page=requestTaxesFeesMessage_common&action=requestTaxesFees&timestamp="+x;
myTaxesFeesWin=window.open(actualUrl,'taxesFees',"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=670,height=500,alwaysRaised=yes,dependent=yes");
myTaxesFeesWin.focus();
}


var securityWin;
function openSecurity (url) {
actualUrl=url+"&action=requestSecurity";
securityWin=window.open(actualUrl,'securityWin',windowParam);
securityWin.focus();
}

var privacyWin;
function openPrivacy (url) {
actualUrl=url+"&action=requestPrivacy";
privacyWin=window.open(actualUrl,'privacyWin',windowParam);
privacyWin.focus();
}
var legalWin;
function openLegalNotice (url) {
actualUrl=url+"&action=requestLegalNotice";
legalWin=window.open(actualUrl,'legalWin',"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=670,height=300,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
legalWin.focus();
}
var customPrivacyWin;
function openCustomprivacyPolicy(url) {
actualUrl=url+"&action=requestCustomPrivacy";
customPrivacyWin=window.open(actualUrl,'customPrivacyWin',windowParam);
customPrivacyWin.focus();
}

var flexCalWin;
function openFlexCal (url, promocode) {
if(promocode != '')
{
    url = buildCouponInfo(url + promocode);
}
flexCalWin=window.open(url,'flexCalWin',windowParam);
flexCalWin.focus();
}

var flightInfoWin;
function doServices(form_input){
	var strVal = form_input.options[form_input.selectedIndex].value;
	var strJS = strVal.substring(11,strVal.length);
    var targetObjName='linkURLTarget'+(form_input.selectedIndex +1);
    var targetObj=document.getElementById(targetObjName);
    if(targetObj!=null && targetObj!=undefined && targetObj.value=='NEW_WINDOW' && form_input.name=='config_links')
    {
        var linkWindow;
        linkWindow=window.open(strVal,'leftNavLink',"toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=1000,height=800,alwaysRaised=yes,dependent=yes");
        linkWindow.focus();

    }
    else
    {
          if (strVal.substring(0,10)=="javascript") {
            eval (strJS);
        }
        if (strVal.substring(0,4)=="http") {
            parent.location.href=strVal;
        }
        if (strVal.substring(0,1)=="/") {
            self.location.href=strVal;
            }
	}
}


browserVer = parseInt(navigator.appVersion);
browserName = navigator.appName;

function opencurrency (amountFrom,currencyFrom) {
//changed code for SPR 22680 starts
//var url='https://ww3.dotres.com/meridia?posid=56BA&sid=me2re72r9r2mv1-iyyv:d226e9a26020d40a326f075f39a5e73ac5b8bc1128ecffe03701cdaabe92e654&&amp;page=requestConvertCurrencyMessage_common&amp;action=requestCurrencyConv';
//url=url + '&amp;amountFrom='+amountFrom+'&amp;currencyFrom='+currencyFrom;

var url='https://ww3.dotres.com/meridia?posid=56BA&sid=me2re72r9r2mv1-iyyv:d226e9a26020d40a326f075f39a5e73ac5b8bc1128ecffe03701cdaabe92e654&&page=requestConvertCurrencyMessage_common&action=requestCurrencyConv';
url=url + '&amountFrom='+amountFrom+'&currencyFrom='+currencyFrom;
//change for SPR 22680 ends here

currencyWin=window.open(url,'currencyWin',"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=650,height=200,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
currencyWin.focus();
}


function opentoplink () {
var url="http://www.goclassic.co.uk";
var url_default="";
if (url == "link_requestAir_air_t") {
    if (url_default != "link_agency_air_tdef") {
        url = url_default;
    } else {
        url = "";
    }
}
if (url != "") {
    bannerWin=window.open(url,'bannerWin',"toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=670,height=300");
    bannerWin.focus();
    }
}
function openbottomlink () {
var url="http://www.goclassic.co.uk";
var url_default="";
if (url == "link_requestAir_air_b") {
    if (url_default != "link_agency_air_bdef") {
        url = url_default;
    } else {
        url = "";
    }
}
if (url != "") {
    bannerWin=window.open(url,'bannerWin',"toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
    //bannerWin.resizeBy(-20,-20);
    //bannerWin.moveBy(10,10);
    bannerWin.focus();
    }
}
function winCheck(){
   var  startUrl="http://www.goclassic.co.uk";
         if(this.opener!=null){
         this.opener.document.open();
         this.opener.document.write("<HTML><HEAD><TITLE>SESSION EXPIRATION</TITLE></HEAD><BODY ><p><u>Your session has expired. Please restart:</u></p>");
         this.opener.document.write("<p>goto <a href='"+startUrl+"' target='_top'>Home page</a></p></BODY></HTML>");
         this.opener.document.close();
         this.opener.focus();
         self.close();
    }

}
var flifoWin
function openflifo (url) {
flifoWin=window.open(url,'flifoWin',"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=670,height=340,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
flifoWin.focus();
}
            
var flightlink
 function flightnumlink(url,deptDate,depArr,deptTime)
 {
  var  windowWidth="";
  var windowHeight="";
  if(deptDate)
  {
      depDate =  '&depDate=' + formatDate(deptDate);

  }
  else
  {
    depDate = "";
  }
  deptTime = formatTime(deptTime);
  url = url+depDate+ depArr+ deptTime;
  flightlink=window.open(url,'FlightPerformance',"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+windowWidth +",height="+windowHeight +",alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
  flightlink.focus();
 }

 function formatDate(deptDate){
      if(deptDate.indexOf('-') != -1)
      {
         depDate= deptDate.split('-')

         year=depDate[0]
         month=depDate[1]

         day=depDate[2]
         monthNames =new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC")
         var finaldate=day+monthNames[parseInt(month)-1]+year
         return(finaldate)
      }
      else
      {
         return(deptDate)
      }
 }
 function formatTime(deptTime){
          if(deptTime.indexOf(':') != -1)
          {
                depTime= deptTime.split(':')
                finaltime=depTime[0]+depTime[1]
                return(finaltime)
          }
          else
          {
              return(deptTime)
          }
  }

function processCalendarTableCells(calendarElements)
{
    for (var i = 0; i < calendarElements.length; i++)
    {
        calendarElements[i].parentNode.className = 'cal_notReq';
		if (calendarElements[i].checked) {
		    calendarElements[i].parentNode.className = 'cal_req';
		}
    }
}

function doCalendarDateCheck(id) {
	if (id != '')
	{
       processCalendarTableCells(document.forms[0].depDateMonth)
	   if (document.forms[0].retDateMonth.length > 0)
	   {
           processCalendarTableCells(document.forms[0].retDateMonth);
	   }
	}

    if (document.forms[0].depDateMonth == null || document.forms[0].retDateMonth == null)
	{
        return true;
    }

    var depDate = null;
    var retDate = null;

    var depDateLen = document.forms[0].depDateMonth.length;

    if (!depDateLen)
	{
        depDate = document.forms[0].depDateMonth.value;
    }
	else
	{
        for (var x = 0; x < depDateLen; x++)
		{
            if (document.forms[0].depDateMonth[x].checked)
			{
                depDate = document.forms[0].depDateMonth[x].value;
                break;
            }
        }
    }
		    return true;
}


// add functions to auto update the date selections to prevent a user
// from attempting to book flights out of sequence

// initialize the date
var now = new Date();
var depmonthnumber = now.getMonth();
var retmonthnumber = now.getMonth();
var monthday    = now.getDate();
var year        = now.getYear();
var defaultDepart = '7';
	
			var defaultReturn = '21';
	//vars for the configurable date advance set in SAT
//var defaultDepart;
//var defaultReturn;

// is this a leap year
function leapYear(theYear) {
	if ( ((theYear % 4 == 0) && (theYear % 100 != 0)) || (theYear % 400 == 0) ) {
		return true;
	} else {
		return false;
	}
}


function validateDate(theForm) {
	var d = new Date();
	var dYear = d.getFullYear();
	var formName = eval('document.' + theForm);
	var dMonth = formName.depMonth.selectedIndex;
	var dDay = formName.depDay.selectedIndex;
	// For Months with 31 days

	if ( (dMonth == '0' || dMonth == '2' || dMonth == '4' || dMonth == '6' || dMonth == '7' || dMonth == '9' || dMonth == '11' )){ if (dDay == '30' || dDay == '31') { dDay = '29';
	//eval (formName.departureDay.selectedIndex = dDay);

	}
    // For Months with 30 days
	} else if ((dMonth == '3' || dMonth == '5' || dMonth == '8' || dMonth == '10' )) { if (dDay == '30' || dDay == '31') { dDay = '29'; eval (formName.depDay.selectedIndex = dDay); }
	// For February, check for leapyear.

	} else if (dMonth == '1') {
		if ((!leapYear(dYear) && dDay == '28') || dDay == '29' || dDay == '30') {
			dDay = '27';
			eval (formName.depDay.selectedIndex = dDay);
		}
	}
}

function validateReturn(theForm) {
	var d = new Date();
	var dYear = d.getFullYear();
	var formName = eval('document.' + theForm);
	var dMonth = formName.retMonth.selectedIndex;
	var dDay = formName.retDay.selectedIndex;
		// For Months with 31 days

	if ( (dMonth == '0' || dMonth == '2' || dMonth == '4' || dMonth == '6' || dMonth == '7' || dMonth == '9' || dMonth == '11' )){
		if (dDay == '30' || dDay == '31') {
			dDay = '29';
			//eval (formName.returnDay.selectedIndex = dDay);

		}
		// For Months with 30 days

	} else if ((dMonth == '3' || dMonth == '5' || dMonth == '8' || dMonth == '10' )) {
		if (dDay == '30' || dDay == '31') {
			dDay = '29';
			eval (formName.retDay.selectedIndex = dDay);
		}
		// For February, check for leapyear.

	} else if (dMonth == '1') {
		if ((!leapYear(dYear) && dDay == '28') || dDay == '29' || dDay == '30') {
			dDay = '27';
			eval (formName.retDay.selectedIndex = dDay);
		}
	}
}

function updateChangedDate(selectObject){
	selectObject.changed = true;
	if(selectObject.form.dateChanged) selectObject.form.dateChanged.value = true;
}

// end the date advance code



function makeArray(n) {
this.length = n;
return this;
}
function whoCheckedIt() {
	if (!document.airAvailSemiForm.out.length) {
		document.airAvailSemiForm.itin_selected.value = document.airAvailSemiForm.out.value;
	}
	else {
		for (var i = 0; i <document.airAvailSemiForm.out.length; i++) {
			if (document.airAvailSemiForm.out[i].checked) {
				document.airAvailSemiForm.itin_selected.value = i;
			}
		}
	}
	document.airAvailSemiForm.submit();
}
//changes done for SPR 99767
function whoCheckedItFlex(url)
{
   var selected=0;
   var radioId = document.airAvailFlexForm.selectedRadio;

   if(radioId != null && radioId != undefined)
   {
       for (var i = 0; i <radioId.length; i++)
       {
            if (radioId[i].checked)
            {
               selected=radioId[i].value;
               break;
            }
       }
    }
    if(radioId.length == undefined && selected == 0)
    {
        if(document.airAvailFlexForm.selectedRadio.checked)
        {
            selected = document.airAvailFlexForm.selectedRadio.value;
        }
    }
    var altDate='AltDate'+selected;
    var promoCode='PromoCode'+selected;
    var promocodeUrl='';
    if(document.getElementById(altDate).value=='true')
    {
       if(document.getElementById(promoCode).value!='')
       {
           promocodeUrl='&promoCode='+document.getElementById(promoCode).value;
       }
       url =url+'&actionType=flexCal';
       url =url+'&selected='+selected;
       openFlexCal(url,promocodeUrl);
       return;
    }
    else
    {
       if(document.getElementById(promoCode).value!='')
       {
           url=url+'&promoCode='+document.getElementById(promoCode).value;
       }
       url =url+'&actionType=flexFlights';
    }
    url =url+'&selected='+selected;
    window.location.href=url;
}

function whoCheckedItFlexSimple(url)
{
   var selected=0;
   var radioId = document.airAvailFlexSimpleForm.selectedRadio;
   if(radioId != null && radioId != undefined)
   {
       for (var i = 0; i <radioId.length; i++)
       {
            if (radioId[i].checked)
            {
               selected=radioId[i].value;
               break;
            }
       }
    }
    if(radioId.length == undefined && selected == 0)
    {
        if(document.airAvailFlexSimpleForm.selectedRadio.checked)
        {
            selected = document.airAvailFlexSimpleForm.selectedRadio.value;
        }
    }

     var promoCode='PromoCode'+selected;
      if(document.getElementById(promoCode).value!='')
       {
           url=url+'&promoCode='+document.getElementById(promoCode).value;
       }
     url =url+'&fareindex='+selected;
     window.location.href=url;
}

//
// global declarations and initialization
//
function init () {
theDate         = new Date();
today           = new Date();
currMonth       = today.getMonth();
msPerDay        = 24*60*60*1000;
cookieString    = "dispMonth="+currMonth+";";
document.cookie = cookieString;
startOfString   = document.cookie.indexOf("dispMonth");
countbegin      = document.cookie.indexOf("=",startOfString) + 1;
countend        = document.cookie.indexOf(";",countbegin);
if (countend == -1) {
countend = document.cookie.length;
}
dispMonth     = eval ("document.cookie.substring(countbegin,countend)");
firstOfMonth  = new Date(today.getYear(),dispMonth,1);


monthName = new Array("","January","February","March","April","May","June","July","August","September","October","November","December");
}

function applyStyleToFormElements(elementType, elementStyle) {
    if(document.all) {
        for(var i = 0; i < document.forms[0].elements.length; i++) {
            var element = document.forms[0].elements[i];
            if(elementType == element.type)
                element.style.visibility = elementStyle;
        }
    }
}


//
// set the month
//
function changeMonth (increment) {
nextMonth = dispMonth;
if (increment == 1) {
nextMonth++;
} else {
nextMonth--;
}
if (nextMonth == 12)
   nextMonth = 0;
if (nextMonth == -1)
   nextMonth = 11;
dispMonth = nextMonth;
document.cookie="dispMonth="+nextMonth;
redraw(increment);

}
//
// generate the calendar document
//
function drawCalendar (theDate) {
monthNum = theDate.getMonth() + 1;
htmlBuffer  = "<HTML><head><title>Calendar</title><link type='text/css' href='application/presentation/default/vm_custom.css' rel='stylesheet'></head><BODY ><FORM>";
				                htmlBuffer += "<CENTER><TABLE border='1' cellpadding='0' cellspacing='1' BGCOLOR=#ffffff bordercolor='#9FCAC0'#6699cc><TH COLSPAN=1 class='fontPopupCalendarBackground'><INPUT class='input_button' TYPE=BUTTON NAME=monthDn VALUE=\"<<\" onClick=callingForm.changeMonth(-1)>";
htmlBuffer += "<TH COLSPAN=5 class='calTHbg' width='150'>"+monthName[monthNum];
// getYear returns the year in year - 1900
// this causes ugly display
var tempYear = theDate.getYear()
if ( tempYear <= 1900 ) {
tempYear += 1900;
}
htmlBuffer += " " + tempYear;


htmlBuffer += "</TH></FONT><td COLSPAN=1 align='center' class='fontPopupCalendarBackground'><INPUT class='input_button' TYPE=BUTTON NAME=monthUp VALUE=\">>\" onClick=callingForm.changeMonth(1)></td><TR>";
htmlBuffer += "<TH class='font_title_light_bold'><FONT COLOR=#000000>S</FONT><TH  class='font_title_light_bold'><FONT COLOR=#000000>M</FONT><TH  class='font_title_light_bold'><FONT COLOR=#000000>T</FONT><TH  class='font_title_light_bold'><FONT COLOR=#000000>W</FONT><TH  class='font_title_light_bold'><FONT COLOR=#000000>T</FONT><TH  class='font_title_light_bold'><FONT COLOR=#000000>F</FONT><TH  class='font_title_light_bold'><FONT COLOR=#000000>S</FONT><TR>";
drawBody(theDate);
htmlBuffer += "<\/TABLE><\/BODY><\/HTML>";
}
//
// generate the calendar body
//
function drawBody (theDate) {
//a fix for DST problem
theDate.setHours(11);
theDate.setMinutes(30);
thisMonth = theDate.getMonth();
thisDate  = theDate.getDate();
firstSunday(theDate);
for (w=0; w<6; w++) {
for (d=0; d<7; d++) {
date = theDate.getDate();
htmlBuffer   += "<TD ALIGN=CENTER class='font_default_center'>";
// skip previous month
if (theDate.getMonth() != thisMonth) {
htmlBuffer += "<BR>";
} else {
htmlBuffer += "<INPUT class='input_cal' TYPE=BUTTON NAME="+date+" VALUE=";
if ( date < 10 ) {
htmlBuffer += "0";
}
htmlBuffer += date+" onClick=callingForm.fillDate(" + date + ")>";
}
// increment the date
newTime = theDate.getTime() + msPerDay;
theDate.setTime(newTime);

}
htmlBuffer += "<TR>";
}
htmlBuffer += "<\/FORM>";
}
//
// reset the startdate to get the
// previous sunday before the current date
// so that the drawing can begin from a sunday
//
function firstSunday (fromDate) {
while (fromDate.getDay() != 0) {
newTime = fromDate.getTime() - msPerDay;
fromDate.setTime(newTime);
}
}

function openVTDest(url, destCity, errorUrl, language){
                
				var nonFlex = true;var nonFlexDisabled = false;
				
               			    var semiFlex = true;var semiFlexDisabled = false;
				
								var flex = true;var flexDisabled = false;
							    var lightweight = true;var lightweightDisabled = false;
				                var multiDest = true;var multiDestDisabled = false;
			    			     var redeemMiles = false;var redeemMilesDisabled = false;
				

	var dt = new Date();
 	var x = dt.getTime();
	var openUrl;
	var searchType;
	var openPopupWindow = true;
	var agencyDefinedUrl = window.location.protocol + "//" + window.location.host + errorUrl.replace(/&amp;/gi,"&")+"&timestamp="+x;
	var vtoUrl = url+"?destCity="+escape(destCity)+"&url="+ window.location.protocol + "//" + window.location.host + errorUrl.replace(/&/gi,"%26") + "&lang="+language;

	for(var i = 0; i < document.RequestAirForm.actionType.length; i++){
		if(document.RequestAirForm.actionType[i].checked){
			searchType = document.RequestAirForm.actionType[i].value;
		}
	}

	if(!searchType){
		searchType = document.RequestAirForm.actionType.value;
	}

  	if(searchType == "nonFlex"){
		if(nonFlex)
			openUrl = agencyDefinedUrl;
		else if(nonFlexDisabled)
			openPopupWindow = false;
		else
			openUrl = vtoUrl;
	}
	else if(searchType == "semiFlex"){
		if(semiFlex)
			openUrl = agencyDefinedUrl;
		else if(semiFlexDisabled)
			openPopupWindow = false;
		else
			openUrl = vtoUrl;
	}
	else if(searchType == "flex"){
		if(flex)
			openUrl = agencyDefinedUrl;
		else if(flexDisabled)
			openPopupWindow = false;
		else
			openUrl = vtoUrl;
	}
	else if(searchType == "flexSimple"){
		if(flex)
			openUrl = agencyDefinedUrl;
		else if(flexDisabled)
			openPopupWindow = false;
		else
			openUrl = vtoUrl;
	}
	else if(searchType == "lightweight"){
		if(lightweight)
			openUrl = agencyDefinedUrl;
		else if(lightweightDisabled)
			openPopupWindow = false;
		else
			openUrl = vtoUrl;
	}
	else if(searchType == "multiDest"){
		if(multiDest)
			openUrl = agencyDefinedUrl;
		else if(multiDestDisabled)
			openPopupWindow = false;
		else
			openUrl = vtoUrl;
	}
	else if(searchType == "redeemMiles"){
		if(redeemMiles)
			openUrl = agencyDefinedUrl;
		else if(redeemMilesDisabled)
			openPopupWindow = false;
		else
			openUrl = vtoUrl;
	}

	if(openPopupWindow){
		openSearchPopup(openUrl, 'VTO', 'width=670,height=350');
	}

}

var win;
function openSearchPopup(openUrl, title, scrsize) {
	win = window.open(openUrl , title, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200"+scrsize);
	win.focus();
}


function openPopUpLov(url)
    {
        popup = window.open(url, 'LOV', 'toolbar=no,location=no,directories=no,status=no,scrollbars=auto,menubar=no,resizable=yes,copyhistory=yes,width=320,height=300,screenX=275,screenY=290');
    }

function setSelect() {
    chkMatrix();
 }

function chkMatrix() {
        
                  var flag;
        if(!(document.getElementById('fareMatrixHiddenControl') == null || document.getElementById('fareMatrixHiddenControl') == undefined ||document.getElementById('fareMatrixHiddenControl').value == '' ))
        {
            if(document.getElementById('fareMatrixHiddenControl').value == 'dontshow')
            {
               flag = 'none';
            }
            if(document.getElementById('fareMatrixHiddenControl').value == 'show')
            {
                flag = 'block';
            }
             if(!(document.getElementById('fareMatrixRow') == null || document.getElementById('fareMatrixRow')== undefined || document.getElementById('fareMatrixRow').style.display == ''))
                document.getElementById('fareMatrixRow').style.display=flag;
             if(!(document.getElementById('fareMatrixRowDropDown') == null || document.getElementById('fareMatrixRowDropDown')== undefined || document.getElementById('fareMatrixRowDropDown').style.display == ''))
                document.getElementById('fareMatrixRowDropDown').style.display=flag;
             if(!(document.getElementById('fareMatrixRow1') == null || document.getElementById('fareMatrixRow1')== undefined || document.getElementById('fareMatrixRow1').style.display == ''))
                document.getElementById('fareMatrixRow1').style.display=flag;
        }
}


        	function showCouponInputBox(form)  {
		}
    

function bbrPaxLimitCheck() {

    	        var prefAirlinesEnabled='DISABLE';
        var desUrl='ccs.sabre.com/Sandbox/Meridia';
        		var baseUrl='https://ww3.dotres.com/meridia?posid=56BA&sid=me2re72r9r2mv1-iyyv:d226e9a26020d40a326f075f39a5e73ac5b8bc1128ecffe03701cdaabe92e654&'+"action=pause&page="+'requestAirMessage_air'+"&language="+'en';

        var vtoDestLang='en';
        var fredDiscountEnabled='DISABLE';
        var customizedMsgEnabled='DISABLE'

        var productId='RES';
        var ipccId='56BA';
        var blockedChdInfIPCCs='7F17';
        var blockedChdInfCities='CUN,SJD,MZT,ZIH,CZM,PVR,GDL,YYC';
        var response="true";


        var totalPax = 0;
		var totalAdult = 0;
        var totalSenior = 0;
        var totalYouth = 0;
        var totalStudent = 0;
        var totalMilitary = 0;
        var totalInfNoSeat = 0;
		var totalInfWithSeat = 0;
        var totalStateResident=0;
        var totalEmigrant=0;
        var totalDisabled=0;
        var totalMinor = 0;

		var totalEachPaxTypes =new Array(11);
		var indexEachPaxType;
		for (indexEachPaxType=1;indexEachPaxType<=10;indexEachPaxType=indexEachPaxType+1)
        {
			totalEachPaxTypes[indexEachPaxType] = 0;
        }

		var totalConfPaxTypes = 0;

		var isEnabledPaxTypesCombinable =new Array(11);
		isEnabledPaxTypesCombinable[1] = 'DISABLE';
		isEnabledPaxTypesCombinable[2] = 'DISABLE';
		isEnabledPaxTypesCombinable[3] = 'DISABLE';
		isEnabledPaxTypesCombinable[4] = 'DISABLE';
		isEnabledPaxTypesCombinable[5] = 'DISABLE';
		isEnabledPaxTypesCombinable[6] = 'DISABLE';
		isEnabledPaxTypesCombinable[7] = 'DISABLE';
		isEnabledPaxTypesCombinable[8] = 'DISABLE';
		isEnabledPaxTypesCombinable[9] = 'DISABLE';
		isEnabledPaxTypesCombinable[10] = 'DISABLE';


        var paxTypesNames =new Array(11);
        paxTypesNames[1] = '';
        paxTypesNames[2] = '';
        paxTypesNames[3] = '';
        paxTypesNames[4] = '';
        paxTypesNames[5] = '';
        paxTypesNames[6] = '';
        paxTypesNames[7] = '';
        paxTypesNames[8] = '';
        paxTypesNames[9] = '';
        paxTypesNames[10] = '';



        var blnMexico = false;
        var isMultiDest=false;        // Log #18111 -Multi Dest iting is allowing UMNR whereas it should not

            if (blockedChdInfIPCCs.indexOf(ipccId) >= 0)
            if (productId == 'SABRESONIC')
            {
                // no children or infs for Mexico travel
                var totalChild = 0;
               // if(document.RequestAirForm.CHD !=null) {
               //     totalChild = totalChild+document.RequestAirForm.CHD[document.RequestAirForm.CHD.selectedIndex].value;
               // }
               // if(document.RequestAirForm.INF !=null) {
               //     totalChild = totalChild+document.RequestAirForm.INF[document.RequestAirForm.INF.selectedIndex].value;
               // }
              //  if(document.RequestAirForm.IFS !=null) {
              //      totalChild = totalChild+document.RequestAirForm.IFS[document.RequestAirForm.IFS.selectedIndex].value;
              //  }
                if(document.RequestAirForm.UMNR !=null) {
                    totalChild = totalChild+document.RequestAirForm.UMNR[document.RequestAirForm.UMNR.selectedIndex].value;
                }
                if (totalChild > 0)
                {
                    if(!blnMexico && document.RequestAirForm.departCity != null )
                    {
                        blnMexico = checkRestrictedCities(document.RequestAirForm.departCity, blockedChdInfCities);
                    }

                    if(!blnMexico && document.RequestAirForm.departCity1 != null ) {
                        blnMexico = checkRestrictedCities(document.RequestAirForm.departCity1, blockedChdInfCities);
                    }

                    if(!blnMexico && document.RequestAirForm.departCity2 != null ) {
                        if(!isMultiDest) isMultiDest=document.RequestAirForm.departCity2.value != '';      // Log #18111 -Multi Dest iting is allowing UMNR whereas it should not
                        if(isMultiDest)  blnMexico = checkRestrictedCities(document.RequestAirForm.departCity2, blockedChdInfCities);
                    }
                    if(!blnMexico && document.RequestAirForm.departCity3 != null ) {
                        if(!isMultiDest)isMultiDest=document.RequestAirForm.departCity3.value != '';      // Log #18111 -Multi Dest iting is allowing UMNR whereas it should not
                        if(isMultiDest) blnMexico = checkRestrictedCities(document.RequestAirForm.departCity3, blockedChdInfCities);
                    }
                    if(!blnMexico && document.RequestAirForm.departCity4 != null ) {
                        if(!isMultiDest)isMultiDest=document.RequestAirForm.departCity4.value != '';      // Log #18111 -Multi Dest iting is allowing UMNR whereas it should not
                        if(isMultiDest) blnMexico = checkRestrictedCities(document.RequestAirForm.departCity4, blockedChdInfCities);
                    }
                    if(!blnMexico && document.RequestAirForm.returnCity != null ) {
                        blnMexico = checkRestrictedCities(document.RequestAirForm.returnCity, blockedChdInfCities);
                    }
                    if(!blnMexico && document.RequestAirForm.returnCity1 != null ) {
                        blnMexico =  checkRestrictedCities(document.RequestAirForm.returnCity1,blockedChdInfCities);
                    }
                    if(!blnMexico && document.RequestAirForm.returnCity2 != null ) {
                       if(!isMultiDest)isMultiDest=document.RequestAirForm.returnCity2.value != '';      // Log #18111 -Multi Dest iting is allowing UMNR whereas it should not
                       if(isMultiDest) blnMexico = checkRestrictedCities(document.RequestAirForm.returnCity2,blockedChdInfCities);
                    }
                    if(!blnMexico && document.RequestAirForm.returnCity3 != null ) {
                        if(!isMultiDest)isMultiDest=document.RequestAirForm.returnCity3.value != '';      // Log #18111 -Multi Dest iting is allowing UMNR whereas it should not
                        if(isMultiDest) blnMexico = checkRestrictedCities(document.RequestAirForm.returnCity3,blockedChdInfCities);
                    }
                    if(!blnMexico && document.RequestAirForm.returnCity4 != null ) {
                        if(!isMultiDest)isMultiDest=document.RequestAirForm.returnCity4.value != '';      // Log #18111 -Multi Dest iting is allowing UMNR whereas it should not
                        if(isMultiDest) blnMexico = checkRestrictedCities(document.RequestAirForm.returnCity4,blockedChdInfCities);
                    }

                }
                if(blnMexico)
                {
                                alert("meridia.air.request.childandinfantpolicy");
                    return;
                }
            }
        if (document.RequestAirForm.ADT != null && document.RequestAirForm.ADT != undefined) {
            numOfAdult=document.RequestAirForm.ADT.options[document.RequestAirForm.ADT.selectedIndex].value;
            totalAdult = parseInt(numOfAdult);
            totalPax += totalAdult;
        }
        if (document.RequestAirForm.YTH != null) {
            numOfYouth=document.RequestAirForm.YTH.options[document.RequestAirForm.YTH.selectedIndex].value;
            totalYouth = parseInt(numOfYouth);
            totalPax += totalYouth;
        }
        if (document.RequestAirForm.CHD != null) {
            numOfChild=document.RequestAirForm.CHD.options[document.RequestAirForm.CHD.selectedIndex].value;
            totalChild=parseInt(numOfChild);
            totalPax += parseInt(numOfChild);
        }
        if (document.RequestAirForm.SCR != null) {
            numOfSenior=document.RequestAirForm.SCR.options[document.RequestAirForm.SCR.selectedIndex].value;
            totalSenior = parseInt(numOfSenior);
            totalPax += totalSenior;
        }
        if (document.RequestAirForm.STU != null) {
            numOfStudent=document.RequestAirForm.STU.options[document.RequestAirForm.STU.selectedIndex].value;
            totalStudent = parseInt(numOfStudent);
            totalPax += totalStudent;
        }
        if (document.RequestAirForm.MIL != null) {
            numOfMilitary=document.RequestAirForm.MIL.options[document.RequestAirForm.MIL.selectedIndex].value;
            totalMilitary = parseInt(numOfMilitary);
            totalPax += totalMilitary;
        }
        if (document.RequestAirForm.UMNR != null) {
            numOfMinors=document.RequestAirForm.UMNR.options[document.RequestAirForm.UMNR.selectedIndex].value;
            totalMinor = parseInt(numOfMinors);
            totalPax += totalMinor;
        }
        if (document.RequestAirForm.IFS != null) {
            numOfIfs=document.RequestAirForm.IFS.options[document.RequestAirForm.IFS.selectedIndex].value;
            totalInfWithSeat = parseInt(numOfIfs);
            totalPax += totalInfWithSeat;
        }
        if (document.RequestAirForm.INF != null) {
            numOfInf=document.RequestAirForm.INF.options[document.RequestAirForm.INF.selectedIndex].value;
            totalInfNoSeat += parseInt(numOfInf);
        }
        if (document.RequestAirForm.STR != null) {
            numOfSTR=document.RequestAirForm.STR.options[document.RequestAirForm.STR.selectedIndex].value;
            totalStateResident=parseInt(numOfSTR);
            totalPax += totalStateResident;
        }

        if (document.RequestAirForm.EMI != null) {
            numOfEMI=document.RequestAirForm.EMI.options[document.RequestAirForm.EMI.selectedIndex].value;
            totalEmigrant=parseInt(numOfEMI);
            totalPax += totalEmigrant;
        }

        if (document.RequestAirForm.DIS != null) {
            numOfDIS=document.RequestAirForm.DIS.options[document.RequestAirForm.DIS.selectedIndex].value;
            totalDisabled=parseInt(numOfDIS);
            totalPax += totalDisabled;
        }

        var index;
        for( index = 1; index <= 10; index++) {
        	var paxTypeName = document.getElementById(paxTypesNames[index]);
 	        if (paxTypeName != null) {
                var numOfConfPaxTypesPassenger=paxTypeName.options[paxTypeName.selectedIndex].value;
                totalEachPaxTypes[index] = parseInt(numOfConfPaxTypesPassenger);
                totalConfPaxTypes += totalEachPaxTypes[index];
           }
        }
        if (totalSenior > 0 && (totalSenior != totalPax || totalInfNoSeat > 0)) {
                        alert("Cannot combine Senior Citizen with other passenger types. Please make a separate reservation for this passenger type.");
            return;
        }
        if (totalYouth > 0 && (totalYouth != totalPax || totalInfNoSeat > 0)) {
                        alert("Cannot combine Youth with other passenger types. Please make a separate reservation for this passenger type.");
            return;
        }
        if (totalStudent > 0 && (totalStudent != totalPax || totalInfNoSeat > 0)) {
                        alert("Cannot combine Student with other passenger types. Please make a separate reservation for this passenger type.");
            return;
        }
        if (totalMilitary > 0 && (totalMilitary != totalPax || totalInfNoSeat > 0)) {
                        alert("Cannot combine Military with other passenger types. Please make a separate reservation for this passenger type.");
            return;
        }
        var numPsgrTypes = totalAdult + totalInfWithSeat + totalSenior + totalYouth + totalStudent + totalMilitary + totalMinor;

        var numExtendedTypes = totalEmigrant + totalDisabled;

        if (totalStateResident > 0 && ((numPsgrTypes + numExtendedTypes) > 0)) {
                        alert("meridia.air.request.stateResidentnotcombine");
            return;
        }

        numExtendedTypes = totalStateResident + totalDisabled;

        if (totalEmigrant > 0 && ((numPsgrTypes + numExtendedTypes) > 0)) {
                        alert("meridia.air.request.emigrantnotcombine");
            return;
        }
        if (totalDisabled > 0 && (totalDisabled != totalPax || totalInfNoSeat > 0)) {
                        alert("meridia.air.request.disablednotcombine");
            return;
        }

        if (totalMinor > 0 && (totalMinor != totalPax || totalInfNoSeat > 0)) {
                        alert("meridia.air.request.minornotcombine");
            return;
        }

        var numOfAllPass = totalPax;
        var isNotCombine = false;
        for ( var int = 1; int <= 10; int++) {
        	if(((isEnabledPaxTypesCombinable[int]== 'DISABLE') && (totalEachPaxTypes[int] > 0) && (numOfAllPass > 0)) || ((isEnabledPaxTypesCombinable[int]== 'DISABLE') && (totalEachPaxTypes[int]> 0) &&(totalEachPaxTypes[int] < totalConfPaxTypes))){
        		isNotCombine = true;
        	}
		}

       	 if (isNotCombine) {
                      alert("The types are not combinable");
           return;
       	 }



		        totalPax =totalPax + totalConfPaxTypes;
        //Fred pricing change start
        //if (fredDiscountEnabled == 'ENABLE') {
        //	if (document.RequestAirForm.groupId != null ) {
        //		if (document.RequestAirForm.groupId.value != "") {
        //			if (totalPax > numOfAdult || totalInfNoSeat > 0) {
        //				alert("Meeting Id can be only used with adult passenger type.");
        //				return;
        //			}
        //		}
        //	}
        //}
        // ends
            bbrFlag="false";
            if(prefAirlinesEnabled=='ENABLE'){
                carrier1=document.RequestAirForm.airline1.value;
                carrier2=document.RequestAirForm.airline2.value;
                carrier3=document.RequestAirForm.airline3.value;
                bbrList=new Array("B6","CH","DJ","DO","G3","HI","H2","I9","MM","MO","P5","SG","S3","TV","VF","VP","VQ","WN","W2","2A","2G","5L","9B");
                for(var i=0;i<bbrList.length;i++){
                    if(carrier1==bbrList[i] || carrier2==bbrList[i] || carrier3==bbrList[i]){
                        bbrFlag=true;
                        break;
                    }
                }
            }
            var retCity="";
            if(document.RequestAirForm.returnCity!=null){
                retCity=document.RequestAirForm.returnCity.value;
            }
            else if(document.RequestAirForm.returnCity1!=null){
                retCity=document.RequestAirForm.returnCity1.value;
            }
        if ( (totalPax > 4) && (bbrFlag==true) )
        {
                                response=confirm("This airline does not allow greater than 4 passengers.");
                if (response == true)
                {
                        openVTDest('http://'+ desUrl, retCity, baseUrl, vtoDestLang);
                        document.RequestAirForm.submit();
                }
        } else {
                // Added && customizedMsgEnabled == 'ENABLE' for UMNR tracker 17907
                if (totalMinor > 0 && customizedMsgEnabled == 'ENABLE') {
                    setUMNR();
                }

                openVTDest('http://'+ desUrl, retCity, baseUrl, vtoDestLang);



                document.RequestAirForm.submit();
               }


    
    }
    function setUMNR(){
        document.RequestAirForm.requestPage.value=document.RequestAirForm.page.value;
        document.RequestAirForm.requestAction.value=document.RequestAirForm.action.value;
        if(document.RequestAirForm.actionType==null || document.RequestAirForm.actionType.length==null){
            document.RequestAirForm.requestActionType.value='nonFlex';
        }
        else{
            for(var i=0;i<document.RequestAirForm.actionType.length;i++){
                if(document.RequestAirForm.actionType[i].checked){
                    document.RequestAirForm.requestActionType.value=document.RequestAirForm.actionType[i].value;
                }
            }
        }
        document.RequestAirForm.page.value='ssw_UnaccompaniedMinorMessage';
        document.RequestAirForm.action.value='SSWUnaccompaniedMinor';
        return true;
    }

    function checkRestrictedCities(input,cityList)
    {
        var cityArray = cityList.split(",");
        for (var i = 0;i<cityArray.length;i++)
        {
            if(input.value 	== cityArray[i])
            {
                return true;
            }
        }
        return false;
    }


function setMultiDestinationCities(depart_name, return_name) {
        returnEl=document.forms[0].elements[return_name];

        var sel_indx = returnEl.selectedIndex;
        var selectedCityOption;


		sel_indx = 0;
        if (sel_indx > 0)
        {
             selectedCityOption = returnEl.options[sel_indx].value;
        }
		        returnEl.options.length=1;
	     					        repaintDest(depart_name, return_name);

         		var tmpArray  = new Array(returnEl.options.length);
		for ( var i = 0; i < returnEl.options.length; i++ )
		{
    		  tmpArray[i]  = new Array(returnEl.options[i].text,returnEl.options[i].value);
		}
		tmpArray.sort();

		for ( var i = 0; i < returnEl.options.length; i++ )
		{
    		  returnEl.options[i].text  = tmpArray[i][0];
    		  returnEl.options[i].value = tmpArray[i][1];
		}
 		if (selectedCityOption)
        {
               setReturnSelectedIndex(selectedCityOption, return_name);
        }

		var old_to = "${oldTo}";
		if (old_to.length == 3)
		{
			resetTo(return_name, old_to);
		} else {
			document.forms[0].elements[return_name].selectedIndex = 0;
		}

		var old_R1 = "${oldR1}";
		var old_R2 = "${oldR2}";
		var old_R3 = "${oldR3}";
		var old_R4 = "${oldR4}";


		if (old_R1.length == 3)
		{
			resetAll(return_name,old_R1,old_R2,old_R3,old_R4)
		}

}

function resetTo(return_name,old_to) {
	returnEl=document.forms[0].elements[return_name];
	for (i=1; i < returnEl.options.length; i++) {
		if( returnEl.options[i].value == old_to) {
			returnEl.options[i].selected = "selected";
			return true;
		}
	}
	returnEl.options[0].selected = "selected";
}

function resetAll(return_name,old_R1,old_R2,old_R3,old_R4) {
	returnEl=document.forms[0].elements[return_name];
	if (return_name.indexOf(1) > -1) {resetTo(return_name,old_R1);}
	if (return_name.indexOf(2) > -1) {resetTo(return_name,old_R2);}
	if (return_name.indexOf(3) > -1) {resetTo(return_name,old_R3);}
	if (return_name.indexOf(4) > -1) {resetTo(return_name,old_R4);}
}
