//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 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://cert.sabresonicweb.com/cert1/meridia?posid=88N7&sid=m1r2r72mim2rve-yyyv:b665b2b9648bbd389a03737ff043712bc38fb28e5cd38c580fb3674fd96b96fc&&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;


window.document.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) {
flexCalWin=window.open(url,'flexCalWin',windowParam);
flexCalWin.focus();
}


var flightInfoWin;


browserVer = parseInt(navigator.appVersion);
browserName = navigator.appName;

function opencurrency (amountFrom,currencyFrom) {
//changed code for SPR 22680 starts
//var url='/cert1/meridia?posid=88N7&sid=m1r2r72mim2rve-yyyv:b665b2b9648bbd389a03737ff043712bc38fb28e5cd38c580fb3674fd96b96fc&&amp;page=requestConvertCurrencyMessage_common&amp;action=requestCurrencyConv';
//url=url + '&amp;amountFrom='+amountFrom+'&amp;currencyFrom='+currencyFrom;

var url='https://cert.sabresonicweb.com/cert1/meridia?posid=88N7&sid=m1r2r72mim2rve-yyyv:b665b2b9648bbd389a03737ff043712bc38fb28e5cd38c580fb3674fd96b96fc&&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=480,height=200,alwaysRaised=yes,dependent=yes,screenX=200,screenY=200");
currencyWin.focus();
}

function opentoplink () {
var url="link_requestAir_air_t";
var url_default="link_agency_air_tdef";
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="link_requestAir_air_b";
var url_default="link_agency_air_bdef";
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.caymanairways.com/";
      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();
    }

}

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();    
}

//
// 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");
}
//
// entry point
//
function openCalendar (monthFldName, dateFldname,monthFldName1, dateFldname1,formNumber) {
init();
formNum  = formNumber;
//NQF: begin 
//added to accept LHS variable of this type : arr(x)
for (var j=0; j< document.forms[formNum].length; j++) {
if ( document.forms[formNum].elements[j].name.toLowerCase() == monthFldName.toLowerCase()) {
monthFld = "elements["+j+"]";
dispMonth=document.forms[formNum].elements[j].selectedIndex;
} 
if ( document.forms[formNum].elements[j].name.toLowerCase() == dateFldname.toLowerCase() ) {
dateFld = "elements["+j+"]";
}

if(monthFldName1!=''){
if ( document.forms[formNum].elements[j].name.toLowerCase() == monthFldName1.toLowerCase()) {
monthFld1 = "elements["+j+"]";
} }else{
monthFld1 = '';

}

if(dateFldname1!=''){
if ( document.forms[formNum].elements[j].name.toLowerCase() == dateFldname1.toLowerCase() ) {
dateFld1 ="elements["+j+"]";
} }else{
dateFld1 ='';
}


}
//NQF: end
windowOptions  = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,width=275,height=290";
calendarWindow = this.open("","calendarWindow",windowOptions);
calendarWindow.callingForm = this;
redraw(-1);
}
/*function openCalendar(monthFldName, dateFldname,monthFldName1, dateFldname1,formNumber)
{
	windowOptions  = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,width=275,height=290";
	window.open("application/presentation/default/calendar.html","calendarWindow",windowOptions);
}*/
//
// repaint the calendar
//
function redraw(increment) {
calendarWindow.callingForm = this;
//Y2K Browser compatibility issues. getYear() function works for IE.. but had to be
//altered to appear correctly for Netscape. 
if (navigator.appName =='Netscape' ) {
newYear = today.getYear();
newYear = 1900 + newYear;
}
else {  newYear = today.getYear();
}
var tmpDate = new Date();
tmpDate.setMonth(dispMonth);
if ( tmpDate.getTime() < today.getTime() )
newYear++;
firstOfMonth = new Date(newYear,dispMonth,1);
//End Y2K Browser fix. 
calendarWindow.document.open();
calTitle = "<TITLE>.res [ calendar ]<\/TITLE>";


calendarWindow.document.write(calTitle);
drawCalendar(firstOfMonth);
calendarWindow.document.write(htmlBuffer);
calendarWindow.document.close();
calendarWindow.callingForm = this;
//calendarWindow.focus();
if (increment == 1) {
	calendarWindow.document.forms[0].monthUp.focus();
}else {
	calendarWindow.document.forms[0].monthDn.focus();
}

}
//
// fill the calling forms date and month
//
function fillDate(filler) {
var m = monthNum-1;
var d = filler-1;

eval("document.forms[" + formNum + "]." + monthFld + ".selectedIndex=" + m);
eval("document.forms[" + formNum + "]." + dateFld  + ".selectedIndex=" + d);

if(monthFld1!='')
eval("document.forms[" + formNum + "]." + monthFld1 + ".selectedIndex=" + m);

if(dateFld1!='') {            
eval("document.forms[" + formNum + "]." + dateFld1  + ".selectedIndex=" + d+1);
}

calendarWindow.close();
}
//
// 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='https://cert.sabresonicweb.com/cert1/application/presentation/88N7/custom.css' rel='stylesheet'></head><BODY BGCOLOR=#ffffff><FORM>";

htmlBuffer += "<CENTER><TABLE border='1' cellpadding='0' cellspacing='1' 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='font_title_dark' 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 += "</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 = false;var nonFlexDisabled = true;var semiFlex = false;var semiFlexDisabled = true;var flex = false;var flexDisabled = true;var lightweight = false;var lightweightDisabled = false;var multiDest = false;var multiDestDisabled = true;var redeemMiles = false;var redeemMilesDisabled = true;
			
	
	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 updateSearchPaths() {

var semiFlexOption='SIMPLE';
var classOfService='ENABLE';
     

    if ( document.RequestAirForm.actionType == null ) { 
        acType='nonFlex'; 
    }
    else if ( document.RequestAirForm.actionType.length == null ) {
        acType=document.RequestAirForm.actionType.value; 
    }
    else if ( classOfService == 'ENABLE' ) {
        if ( document.RequestAirForm.classService.value == 'PremiumCoachClass' ) {
             acType='nonFlex';
             for (i=0; i < document.RequestAirForm.actionType.length; i++) { 
            	if (document.RequestAirForm.actionType[i].checked) { 
                	acType=document.RequestAirForm.actionType[i].value;
                	document.RequestAirForm.actionType[i].value='nonFlex';                		                				                	
                	break; 
            	}             	
        	}              
        } else {
             for (i=0; i < document.RequestAirForm.actionType.length; i++) { 
            	if (document.RequestAirForm.actionType[i].checked) { 
                	acType=document.RequestAirForm.actionType[i].value;					               	
                	break; 
            	}             	
        	}
        } 
    }     
    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("Not a valid combination");
                return false;
            }
         }
     }
    if(((document.getElementById("refundableSearch") != null)
	    && document.RequestAirForm.refundableSearch.checked)
	    && ((acType == 'redeemMiles') || (acType == 'flex') || (acType == 'flexSimple')))
    {
       alert("Cannot combine this shopping path with refundable fares.");
        return false;
    }
    else
    {

        if(((document.getElementById("alternateDates") != null)
            && document.RequestAirForm.alternateDates.checked)
            && (acType != 'semiFlex'))
        {
            alert("Cannot combine this shopping path with alternate dates.");
            return false;
        }
        if (acType != null && acType == 'semiFlex' && semiFlexOption == 'INTELLISELL')
        {
           document.RequestAirForm.page.value='ssw_SemiFlexOutboundMessage';
           document.RequestAirForm.action.value='SSWSemiFlexService';
           if(((document.RequestAirForm.alternateDates) && (document.RequestAirForm.alternateDates.checked)) || (document.getElementById("alternateDates") && (document.getElementById("alternateDates").value=='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;
    }
}

function bbrPaxLimitCheck() {

  
var prefAirlinesEnabled='DISABLE';
var desUrl='ccs.sabre.com/Sandbox/Meridia';
var baseUrl='https://cert.sabresonicweb.com/cert1/meridia?posid=88N7&sid=m1r2r72mim2rve-yyyv:b665b2b9648bbd389a03737ff043712bc38fb28e5cd38c580fb3674fd96b96fc&'+"action=pause&page="+'requestAirMessage_air'+"&language="+'en';
var vtoDestLang='en';
var fredDiscountEnabled='DISABLE';
var customizedMsgEnabled='DISABLE' 

var productId='SABRESONIC';
var ipccId='88N7';
var blockedChdInfIPCCs='7F17';
var blockedChdInfCities='CUN,SJD,MZT,ZIH,CZM,PVR,GDL,YYC';
var response="true";


var totalPax = 0;
var totalSenior = 0;
var totalYouth = 0;
var totalStudent = 0;
var totalMilitary = 0;
var totalInfNoSeat = 0;
var totalStateResident=0;
var totalEmigrant=0;
var totalDisabled=0;
var totalMinor = 0;
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) {
    numOfAdult=document.RequestAirForm.ADT.options[document.RequestAirForm.ADT.selectedIndex].value;
    totalPax += parseInt(numOfAdult);
}
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;
    totalPax += parseInt(numOfIfs);
}
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;
}
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;
}
if (totalStateResident > 0 && (totalStateResident != totalPax || totalInfNoSeat > 0)) {
    alert("Cannot combine State Resident with other passenger types. Please make a separate reservation for this passenger type.");
    return;
}
if (totalEmigrant > 0 && (totalEmigrant != totalPax || totalInfNoSeat > 0)) {
    alert("Cannot combine Emigrant with other passenger types.  Please make a separate reservation for this passenger type.");
    return;
}
if (totalDisabled > 0 && (totalDisabled != totalPax || totalInfNoSeat > 0)) {
    alert("Cannot combine Disabled with other passenger types.  Please make a separate reservation for this passenger type.");
    return;
}

if (totalMinor > 0 && (totalMinor != totalPax || totalInfNoSeat > 0)) {
    alert("Cannot combine Unaccompanied Minor with other passenger types. \nPlease make a separate reservation for this passenger type.");
    return;
}
//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;
        if (sel_indx > 0)
        {
             selectedCityOption = returnEl.options[sel_indx].value;
        }

        returnEl.options.length=14;
        
  
        returnEl.options[1].value="BOS";
        returnEl.options[1].text="Boston (BOS) ";

      
        returnEl.options[2].value="CYB";
        returnEl.options[2].text="Cayman Brac (CYB) ";

      
        returnEl.options[3].value="FLL";
        returnEl.options[3].text="Ft Lauderdale (FLL) ";

      
        returnEl.options[4].value="GCM";
        returnEl.options[4].text="Grand Cayman (GCM) ";

      
        returnEl.options[5].value="HAV";
        returnEl.options[5].text="Havana (HAV) ";

      
        returnEl.options[6].value="IAH";
        returnEl.options[6].text="Houston-Intercontinental (IAH) ";

      
        returnEl.options[7].value="KIN";
        returnEl.options[7].text="Kingston (KIN) ";

      
        returnEl.options[8].value="LYB";
        returnEl.options[8].text="Little Cayman (LYB) ";

      
        returnEl.options[9].value="MBJ";
        returnEl.options[9].text="Montego Bay (MBJ) ";

      
        returnEl.options[10].value="MCO";
        returnEl.options[10].text="Orlando International (MCO) ";

      
        returnEl.options[11].value="MIA";
        returnEl.options[11].text="Miami (MIA) ";

      
        returnEl.options[12].value="ORD";
        returnEl.options[12].text="Chicago-O'Hare (ORD) ";

      
        returnEl.options[13].value="TPA";
        returnEl.options[13].text="Tampa (TPA) ";

      

        repaintDest(depart_name, return_name);

        if (selectedCityOption) 
        {
               setReturnSelectedIndex(selectedCityOption, return_name);
        }
        
  		<!-- sorting return cities by 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];
		}        
}		
  
var dest_array = new Array(13);
var city_array = new Array("GCM","LYB","CYB","KIN","MBJ","MIA","FLL","ORD","IAH","MCO","TPA","BOS","HAV");
dest_array[0] = "LYB,CYB,KIN,MBJ,MIA,FLL,ORD,IAH,MCO,TPA,BOS,HAV";
dest_array[1] = "LYB,CYB,KIN,MBJ,MIA,FLL,ORD,IAH,MCO,TPA,BOS,HAV";
dest_array[2] = "LYB,CYB,KIN,MBJ,MIA,FLL,ORD,IAH,MCO,TPA,BOS,HAV";
dest_array[3] = "GCM,LYB,CYB";
dest_array[4] = "GCM,LYB,CYB";
dest_array[5] = "GCM,LYB,CYB";
dest_array[6] = "GCM,LYB,CYB";
dest_array[7] = "GCM,LYB,CYB";
dest_array[8] = "GCM,LYB,CYB";
dest_array[9] = "GCM,LYB,CYB";
dest_array[10] = "GCM,LYB,CYB";
dest_array[11] = "GCM,LYB,CYB";
dest_array[12] = "GCM,LYB,CYB";


function repaintDest(depart_name, return_name) {
  departEl=document.forms[0].elements[depart_name];
  returnEl=document.forms[0].elements[return_name];

  sel_ndx = departEl.selectedIndex;

  if(document.getElementById("hidReturnCity") != null){
    ret_sel_val= document.forms[0].hidReturnCity.value;
  }
  else{
    ret_sel_val = returnEl.options[returnEl.selectedIndex].value;
  }

  if (sel_ndx > 0 && sel_ndx <= dest_array.length) {
    valid_destinations = getValidDest(departEl.options[sel_ndx].value);

    if (valid_destinations == null || valid_destinations == "") {
      allDestCities(depart_name, return_name);
    }
    else {
      for (j=1,entries=0; j < returnEl.options.length; j++) {
        if (isValid(returnEl.options[j].value, valid_destinations)) {
          returnEl.options[entries+1].value=returnEl.options[j].value;
          returnEl.options[entries+1].text=returnEl.options[j].text;
          entries++;
        }
      }
      for (j=entries+1; j < returnEl.options.length; j++) {
        returnEl.options[j].value="";
        returnEl.options[j].text="";
      }
      returnEl.options.length=entries+1;

      if(ret_sel_val != null && ret_sel_val != "") {
      	setReturnSelectedIndex(ret_sel_val, return_name);
      }
    }
  }
  else {
    allDestCities(depart_name, return_name);
  }
}

function isValid(city_code, valid_destinations) {
  valid_array = valid_destinations.split(',');
  for (i=0; i < valid_array.length; i++) {
    if (city_code == valid_array[i]) {
      return true;
    }
  }
  return false;
}

function setReturnSelectedIndex(ret_sel_val, return_name) {
	returnEl=document.forms[0].elements[return_name];
	for (i=1; i < returnEl.options.length; i++) {
		if( returnEl.options[i].value == ret_sel_val) {
			returnEl.options[i].selected = "selected";
		}
	}
}

function allDestCities(depart_name, return_name) {
  departEl=document.forms[0].elements[depart_name];
  returnEl=document.forms[0].elements[return_name];
  returnEl.options.length=departEl.options.length;
  for (j=0; j < departEl.options.length; j++) {
    returnEl.options[j].value=departEl.options[j].value;
    returnEl.options[j].text=departEl.options[j].text;
  }
}

function getValidDest(city_code) {
  for (j=0; j < city_array.length; j++) {
    if (city_code == city_array[j])
      return dest_array[j];
  }
  return "";
}
