// commonAcolHomePageFunctions.js


//------------------------------------------------------------------------------
var TOO_MANY_PASSENGERS;
var Language;
var ORIG_IS_AMBIGUOUS;
var DEST_IS_AMBIGUOUS;
var ENTER_FLIGHTNO;
var INVALID_AEROPLANNO;
var INVALID_PIN;

if (Language == "english" || Language == "us") {
  TOO_MANY_PASSENGERS = "The total number of passengers cannot exceed 9. Please select a different number of adults or children.";
  ORIG_IS_AMBIGUOUS = "Origin city is ambiguous.  Please select a city.";
  DEST_IS_AMBIGUOUS = "Destination city is ambiguous. Please select a city.";
  ENTER_FLIGHTNO = "Please enter the flight number.";
  INVALID_AEROPLANNO = "Invalid Aeroplan number.";
  INVALID_PIN = "Invalid PIN.";
}
else { //french
  TOO_MANY_PASSENGERS = "Le nombre total de passagers ne peut pas excéder le nombre de 9. Veuillez sélectionner un nombre différent d'adultes ou d'enfants.";
  ORIG_IS_AMBIGUOUS = "La ville d'origine n'est pas claire. Veuillez choisir une ville.";
  DEST_IS_AMBIGUOUS = "La ville de destination n'est pas claire. Veuillez choisir une ville.";
  ENTER_FLIGHTNO = "Entrez le numéro de vol.";
  INVALID_AEROPLANNO = "Numéro d'Aeroplan invalide.";
  INVALID_PIN = "PIN invalide.";
}

var POSITIVE_INFINITY = Math.pow(2, 32);
var DepartureAmbiguous = true;
var ArrivalAmbiguous = true;
var Valid = false;
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
var langCookieLifetime = 5 * 365; // 5 years


//------------------------------------------------------------------------------
function autoTab(input,len, e) {
    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
}


//------------------------------------------------------------------------------
function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
        if(arr[index] == ele)
        found = true;
        else
        index++;
    return found;
}


//------------------------------------------------------------------------------
function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
    }
    return true;
}


//------------------------------------------------------------------------------
// function to open enrollment warning window
var EnrollE = null;
var EnrollF = null;
function openEnroll() {
    if (Language == "english" || Language == "us") {
        // english
   if (EnrollE == null || EnrollE.closed) {
     self.name="Logon";
     EnrollE = window.open("https://w4.aircanada.ca/aeroplan/enrollment_warningE.html","EnrollE","height=470,width=800,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no");
   }
   else {
     EnrollE.focus();
   }
   return false;
    }
    else {
        // french
   if (EnrollF == null || EnrollF.closed) {
     self.name="Logon";
     EnrollF = window.open("https://w4.aircanada.ca/aeroplan/enrollment_warningF.html","EnrollF","height=470,width=800,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no");
   }
   else {
     EnrollF.focus();
   }
   return false;
    }
}


//------------------------------------------------------------------------------
function openWindow(event, target, FileName, windowName, width, height) {
    if (!(width && height)) {
        width = 800;
        height = 600;
    }

    if (checkMouseDown(event, target)) {
        _openWindow(false, FileName, windowName, width, height);
    }
}


//------------------------------------------------------------------------------
function _openWindow(dependant, FileName, windowName, width, height) {
    wh = window.open(FileName, windowName, 'dependant=' + (dependant ? 'yes' : 'no') + ',resizable=yes'  + ',width=' + width + ',height=' + height);
    wh.topwin = self;
    wh.focus();
}


//------------------------------------------------------------------------------
matchAmbiArray = false;
function findMatch(text) {
    matchAmbiArray = false;
    keyWordsArray = new Array("Charleston","Chicago","Dallas","Kingston","London","Manchester","New York","Sydney","Tokyo","Toronto","Washington");

rEtext = text;
    eval("rExp = /^" + rEtext.replace(/\//g, "\\\/").replace(/\(/g, " ").replace(/\)/g, " ") + "/i");


    if (text.length == 3) {
        // alert(rExp);

        for (i=0; i<Cities.length; i++) {
            if (Cities[i][0].match(rExp)) {
                return new Array(false, Cities[i]);
            }
        }
    }
    found = false;
    ambiguous = false;
    if (text.length >= 3) {
        // alert(rExp);
        //if cityField.value matches one of the 15 ambiguous city names in keyWordsArray
        for (j = 0; j < keyWordsArray.length; j ++){

        if ( keyWordsArray[j].toUpperCase() == text.toUpperCase() ){
            //alert("found an ambiguous city name" + text + " ");
            matchAmbiArray = true;
            return new Array(true, new Array("???", text));
        }
        }

        for (i=0; i<Cities.length; i++) {
            if (Cities[i][1].replace(/\(/g, "\ ").replace(/\)/g, "\ ").match(rExp)) {
                if (found) {
                    ambiguous = true;
                    break;
                }
                else {
                    found = Cities[i];
                }
            }
        }
    }
    if (found) {
        return new Array(ambiguous, found);
    }
    else {
        return new Array(true, new Array("???", text));
    }
}


//------------------------------------------------------------------------------
function getDaysInMonth( month, year ) {
    daysOfMonth = new Array( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );
    daysOfMonth["Jan"] = "31";
    daysOfMonth["Feb"] = "28";
    daysOfMonth["Mar"] = "31";
    daysOfMonth["Apr"] = "30";
    daysOfMonth["May"] = "31";
    daysOfMonth["Jun"] = "30";
    daysOfMonth["Jul"] = "31";
    daysOfMonth["Aug"] = "31";
    daysOfMonth["Sep"] = "30";
    daysOfMonth["Oct"] = "31";
    daysOfMonth["Nov"] = "30";
    daysOfMonth["Dec"] = "31";

    if( year % 4 == 0 )
    {
        daysOfMonth["Feb"] = "29";
    };
    return daysOfMonth[month];
}


//------------------------------------------------------------------------------
function getMonthOfYear( month ) {
    monthOfYear = new Array( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );
    monthOfYear["Jan"] = "01";
    monthOfYear["Feb"] = "02";
    monthOfYear["Mar"] = "03";
    monthOfYear["Apr"] = "04";
    monthOfYear["May"] = "05";
    monthOfYear["Jun"] = "06";
    monthOfYear["Jul"] = "07";
    monthOfYear["Aug"] = "08";
    monthOfYear["Sep"] = "09";
    monthOfYear["Oct"] = "10";
    monthOfYear["Nov"] = "11";
    monthOfYear["Dec"] = "12";

    return monthOfYear[month];
}


//------------------------------------------------------------------------------
function getMonth( monthYear ) {
    return monthYear.substring( 0, 3 );
}


//------------------------------------------------------------------------------
function getYear( monthYear ) {
    return monthYear.substring( 3, 7 );
}


//------------------------------------------------------------------------------
function getDateNumber( type ) {
    inputDepDay = document.flights.departDay1.options[document.flights.departDay1.selectedIndex].text
    inputDepMonth = getMonth( document.flights.departMonthYear1.options[document.flights.departMonthYear1.selectedIndex].value );
    inputDepYear = getYear( document.flights.departMonthYear1.options[document.flights.departMonthYear1.selectedIndex].value );

    inputRetDay = document.flights.departDay2.options[document.flights.departDay2.selectedIndex].text
    inputRetMonth = getMonth( document.flights.departMonthYear2.options[document.flights.departMonthYear2.selectedIndex].value );
    inputRetYear = getYear( document.flights.departMonthYear2.options[document.flights.departMonthYear2.selectedIndex].value );

    depDateString = inputDepYear + getMonthOfYear( inputDepMonth ) + inputDepDay;
    retDateString = inputRetYear + getMonthOfYear( inputRetMonth ) + inputRetDay;

    if( type == "Ret" )
    {
        return retDateString;
    }
    else
    {
        return depDateString;
    };
}


//------------------------------------------------------------------------------
function getZeroPadded( input, len ) {
    retString = "";
    for( c = 0; c < len-input.length; c++ )
    {
        retString += "0";
    };
    return retString + input;
}


//------------------------------------------------------------------------------
function getCurrentDateAsNumber() {
    retString = document.flights.currentyear.value;
    retString += getZeroPadded( document.flights.currentmonth.value, 2 );
    retString += getZeroPadded( document.flights.currentday.value, 2 );
    return new Number(retString);
}


//------------------------------------------------------------------------------
function assertValidDate( dayOption, monthYearOption ) {
	

    checkNeeded = false;
    if( document.flights.tripType[0].checked == true )
    {
        checkNeeded = true;
    }
    inputMonth = getMonth( monthYearOption.options[monthYearOption.selectedIndex].value );
    inputYear = getYear( monthYearOption.options[monthYearOption.selectedIndex].value );

    //non-existent departure or return date
    if( dayOption.options[dayOption.selectedIndex].text > getDaysInMonth( inputMonth, inputYear ) )
    {
        dayOption.selectedIndex = getDaysInMonth( inputMonth, inputYear ) - 1;
    };
    
    
    //departure date later than return date
    deptdate=getDateNumber( "Dep" );
    returndate=getDateNumber( "Ret" );
        
    if( ( checkNeeded == true ) && ( getDateNumber( "Dep" ) > getDateNumber( "Ret" ) ) )
    {
        if( dayOption == document.flights.departDay2 ) //return date/month has been selected
        {
    
    //*********** LOGIC ADDED FOR FUTURE DATE BOOKING
    
    // CHECK FOR DEPT AND RET years for resetting dept date
        	
           if(parseInt(deptdate.substring(0,4))==parseInt(returndate.substring(0,4)))
           	{
           		
            document.flights.departDay1.selectedIndex = document.flights.departDay2.selectedIndex;
            document.flights.departMonthYear1.selectedIndex = document.flights.departMonthYear2.selectedIndex;
        	}
        
        
        }
        else //depart month/day has changed
        {
            document.flights.departDay2.selectedIndex = document.flights.departDay1.selectedIndex;
            document.flights.departMonthYear2.selectedIndex = document.flights.departMonthYear1.selectedIndex;
        };
    };
    //departure date in the past
    
    if( getDateNumber( "Dep" ) <  getCurrentDateAsNumber())
	
    {
    	
      	
    	 //*********** LOGIC ADDED FOR FUTURE DATE BOOKING
    	 
    	 // departure date check for 365 days from current date
    	if(getZeroPadded( document.flights.currentday.value, 2 )-document.flights.departDay1.options[document.flights.departDay1.selectedIndex].text<11)
    	{
    	
    	document.flights.departDay1.selectedIndex =  document.flights.currentday.value -1;
     	document.flights.departMonthYear1.selectedIndex = 0;                              
    	//alert(" The departure date must not exceed 356 days from today.Please enter an earlier departure date");   
    	if (Language == "english" || Language == "us") {

    	alert("The departure date must not exceed 356 days from today. \n Please enter an earlier departure date.");   
							}
			else
			{
		alert("La date de départ ne peut se situer au-delà de 356 jours à compter de la date d'aujourd'hui. \n Veuillez indiquer une date de départ se situant plus tôt.");
			}							
    	}
    
    }
    
else
{

 //*********** LOGIC ADDED FOR FUTURE DATE BOOKING
 // checking last for 356 days below 10th of every month
 
	if(document.flights.departMonthYear1.selectedIndex==11)
	{
		if(getDaysInMonth( inputMonth, inputYear )- document.flights.departDay1.value +parseInt(getZeroPadded(document.flights.currentday.value))<11)
		{
		document.flights.departDay1.selectedIndex =  document.flights.currentday.value -1;
     		document.flights.departMonthYear1.selectedIndex = 0;                              
     		document.flights.departDay2.selectedIndex =  document.flights.currentday.value -1;
     		document.flights.departMonthYear2.selectedIndex = 0;                              
    		//alert(" The departure date must not exceed 356 days from today.Please enter an earlier departure date");   
    	if (Language == "english" || Language == "us") {	
    		alert("The departure date must not exceed 356 days from today. \n Please enter an earlier departure date.");
    							}
    						else
    							{
    								alert("La date de départ ne peut se situer au-delà de 356 jours à compter de la date d'aujourd'hui. \n Veuillez indiquer une date de départ se situant plus tôt.");
    							}
    	
    	
    	
    	
    	
		};
	
	};
		
		
};
    
    
    
    
    
    //return date in the past


    if( getDateNumber( "Ret" ) <  getCurrentDateAsNumber()  )

    {
    	   	
    	 //*********** LOGIC ADDED FOR FUTURE DATE BOOKING
    	 
    	 // return  date check for 365 days from current date
    	
        if(getZeroPadded( document.flights.currentday.value, 2 )-document.flights. departDay2.options[document.flights.departDay2.selectedIndex].text<11)
    	{
    	
    	document.flights.departDay2.selectedIndex =  document.flights.currentday.value -1;
     	document.flights.departMonthYear2.selectedIndex = 0;   
     	document.flights.departDay1.selectedIndex =  document.flights.currentday.value -1;
     	document.flights.departMonthYear1.selectedIndex = 0;   
     	       
     	                               
    	//alert("The return date must not exceed 356 days from today.Please enter an earlier departure date");   
    	if (Language == "english" || Language == "us") {	
    	alert("The return date must not exceed 356 days from today. \n Please enter an earlier return date.");
							}
						else
							{
	alert("La date de retour ne peut se situer au-delà de 356 jours à compter de la date d'aujourd'hui. \n Veuillez indiquer une date de retour se situant plus tôt.");	
							}
    	}       
    	   	       
}       
        
 else   
{       
		
	
 //*********** LOGIC ADDED FOR FUTURE DATE BOOKING
 // checking last for 356 days below 10th of every month	
	if(document.flights.departMonthYear2.selectedIndex==11)
	{
	
		if(getDaysInMonth( inputMonth, inputYear )- document.flights.departDay2.value + parseInt(getZeroPadded(document.flights.currentday.value))<11)
		{
		document.flights.departDay2.selectedIndex = document.flights.departDay1.selectedIndex;
        	document.flights.departMonthYear2.selectedIndex = document.flights.departMonthYear1.selectedIndex;
    		//alert("The return date must not exceed 356 days from today.Please enter an earlier departure date");
    		if (Language == "english" || Language == "us") {	
    	alert("The return date must not exceed 356 days from today. \n Please enter an earlier return date.");
							}
						else
							{
	alert("La date de retour ne peut se situer au-delà de 356 jours à compter de la date d'aujourd'hui. \n Veuillez indiquer une date de retour se situant plus tôt.");	
							}
		};
	
	};
		
		
};
        
    
    if((getDateNumber( "Dept" )< getCurrentDateAsNumber()) && (getDateNumber( "Ret" )>=getCurrentDateAsNumber()) )
    	{
   		
    	 document.flights.departDay2.selectedIndex = document.flights.departDay1.selectedIndex;
         document.flights.departMonthYear2.selectedIndex = document.flights.departMonthYear1.selectedIndex;	
};




    //total number of passengers cannot exceed 9
    if( (Number(document.flights.numberOfAdults.options[document.flights.numberOfAdults.selectedIndex].value) + Number(document.flights.numberOfChildren.options[document.flights.numberOfChildren.selectedIndex].value)) > 9 )
    {
        //alert(TOO_MANY_PASSENGERS);
        if (Language == "english" || Language == "us") url = "/cto5/errorPopupOKE.html";
        else url = "/cto5/errorPopupOKF.html";

        features = 'scrollbars=yes,width=300,height=200,resizeable=yes';
        popup = window.open(url, 'Error', features);

        document.flights.numberOfChildren.selectedIndex = 9 - document.flights.numberOfAdults.options[document.flights.numberOfAdults.selectedIndex].value;
    };
    //if departure and return flight on same day, ensure arrival time not before departure time
    if( ( checkNeeded == true ) && ( getDateNumber( "Dep" ) == getDateNumber( "Ret" ) ) && ( document.flights.departTime1.options[document.flights.departTime1.selectedIndex].value >= document.flights.departTime2.options[document.flights.departTime2.selectedIndex].value ) )
    {
        departTime1 = document.flights.departTime1.options[document.flights.departTime1.selectedIndex].value;
        //search for fist available return time greater than depart time
        //if not found, select latest possible return time
        for( c = 0; c < document.flights.departTime2.length; c++ )
        {
            if( document.flights.departTime2.options[c].value == departTime1 )
            {
                document.flights.departTime2.selectedIndex = c;
                return;
            };
        };
        document.flights.departTime2.selectedIndex = c - 1;
    };
}


//------------------------------------------------------------------------------
function changeDropDownTo( dropDown, inValue ) {
    for( c = 0; c < dropDown.length; c++ )
    {
        if( dropDown.options[c].value == inValue )
        {
            dropDown.selectedIndex = c;
            return;
        };
    };
}


//------------------------------------------------------------------------------
function checkCity(cityField, hiddenField) {
    if (cityField.value.length < 3) {
        return false;
    }
    else {
        res = findMatch(cityField.value);
        if (matchAmbiArray){
            return false;
        }
        if (res) {
            if (res[0]) {
                // alert("The entry \"" + document.flights.city0.value + "\" is ambiguous.");
                return false;
            }
            else {
                // alert(res[1][0] + "  -  " + res[1][1]);
                hiddenField.value = res[1][0];
                cityField.value = res[1][1];
                return true;
            }
        }
    }
    return false;
}


//------------------------------------------------------------------------------
// function to convert Month to YearMonth
function getMonthYear(){
    var curmonth = document.forms["dataForm"].currentmonth.value;
    var curyear = document.forms["dataForm"].currentyear.value;
    var curday = document.forms["dataForm"].currentday.value;
    seldepMonth = document.flights.departMonth1.selectedIndex;
    selretMonth = document.flights.departMonth2.selectedIndex;
    var depcuryear = curyear ;
    var retcuryear = curyear;
    if ((seldepMonth < (parseInt(curmonth)-1)) || ((seldepMonth == (parseInt(curmonth)-1)) && (document.flights.departDay1.selectedIndex < (parseInt(curday)-1))))
    {
        depcuryear = parseInt(curyear)+1;
    }
    if ((selretMonth < (parseInt(curmonth)-1)) || ((selretMonth == (parseInt(curmonth)-1)) && (document.flights.departDay2.selectedIndex < (parseInt(curday)-1))))
    {
        retcuryear = parseInt(curyear)+1;
    }
    document.flights.departMonthYear1.value = document.flights.departMonth1.options[document.flights.departMonth1.selectedIndex].value + depcuryear;
    document.flights.departMonthYear2.value = document.flights.departMonth2.options[document.flights.departMonth2.selectedIndex].value + retcuryear;
    return true;
}


//------------------------------------------------------------------------------
reservationResult = false;
function reservationValidate(event) {
    rExp = /[ ]/;
    str1 = document.reservation.CustomerNumber1.value;
    str2 = document.reservation.CustomerNumber2.value;
    str3 = document.reservation.CustomerNumber3.value;
    if ((str1.length == 0) || str1.match(rExp) ||
            (str2.length == 0) || str2.match(rExp) ||
            (str3.length == 0) || str3.match(rExp)) {
        alert("Invalid Customer Number");
        document.reservation.CustomerNumber1.focus();
        return;
    }
    pStr = document.reservation.PIN.value;
    if ((pStr.length == 0) || pStr.match(rExp)) {
        alert("Invalid PIN");
        document.reservation.PIN.focus();
        return;
    }
    reservationResult = true;
}
function onReservationSubmit() {
    return reservationResult;
}


//------------------------------------------------------------------------------
function setListToNumValue(listObj, valueToSet) {
	if (valueToSet != null && valueToSet != "") {
		for (i = 0; i < listObj.length; i ++) {
			if (listObj.options[i].value == valueToSet) {
				listObj.selectedIndex = i;
				break;
			}
		}
	}
}


//------------------------------------------------------------------------------
function setListToStrValue(listObj, valueToSet) {
	valueToSet = new String(valueToSet);
	if (valueToSet != null && valueToSet != "") {
		for (i = 0; i < listObj.length; i ++) {
			var currOpt = new String(listObj.options[i].value);
			if (currOpt.indexOf(valueToSet) == 0 && currOpt.length == valueToSet.length) {
				listObj.selectedIndex = i;
				break;
			}
		}
	}
}

function setRadioToStrValue(RadioObj, valueToSet) {
	valueToSet = new String(valueToSet);
	if (valueToSet != null && valueToSet != "") {
		for (i = 0; i < RadioObj.length; i ++) {
			if (RadioObj[i].value == valueToSet) {
				RadioObj[i].checked = true;
				break;
			}
		}
	}
}


//Prj 480B - add animated waiting popup
function popCenterWindow( url, title, winWidth, winHeight ) {
  var left = (screen.width - winWidth)/2;
  var top = (screen.height - winHeight)/2;
  return window.open( url, title, "width=" + winWidth + ",height=" + winHeight + ",menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=yes,top=" + top + ",left=" + left);
}

var waitingscreen;

function searchAcol() {
	saveDepAndRetDatesToCookies();

	//Prj 480B - add animated waiting popup
	if (document.dataForm.language.value == "us"){
		document.flights.searchPageURL.value = "http://www.aircanada.com/us-home.html";
		waitingscreen = popCenterWindow('/cto5/waitingPopup1E.html', 'waitingscreen', 368, 250);
	}
	else if(document.dataForm.language.value == "english"){
		document.flights.searchPageURL.value = "http://www.aircanada.ca/e-home.html";
		waitingscreen = popCenterWindow('/cto5/waitingPopup1E.html', 'waitingscreen', 368, 250);
	}
	else{
		document.flights.searchPageURL.value = "http://www.aircanada.ca/f-home.html";
		waitingscreen = popCenterWindow('/cto5/waitingPopup1F.html', 'waitingscreen', 368, 250);
	}
	waitingscreen.focus();

	if (scheduleValidate()) {
		submitsearch();
	}
	else {
		waitingscreen.close();
		return;
	}
}


//------------------------------------------------------------------------------
scheduleResult = false;
function scheduleValidate() {
    if (!checkCity(document.flights.org1, document.flights.origin1)) {
        if (!matchAmbiArray) {
            //alert(ORIG_IS_AMBIGUOUS);
            if (Language == "english" || Language == "us")
                window.open('/includes/home/en/resCity/org_errorPopupOKCancelCityListE.html','city__flights_org1__flights_origin1','width=390,height=220');
            else
                window.open('/includes/home/fr/resCity/org_errorPopupOKCancelCityListF.html','city__flights_org1__flights_origin1','width=390,height=220');

            return false;
        }
        else {
            var word = document.flights.org1.value;
            if (word.toUpperCase() == "NEW YORK") {
                word = "NEW+YORK";
            }

            if (Language == "english" || Language == "us")
                window.open('/includes/home/en/resCity/org_ambiCityE.html','ambiCity1__flights_org1__flights_origin1','width=400,height=200');
            else
                window.open('/includes/home/fr/resCity/org_ambiCityF.html','ambiCity1__flights_org1__flights_origin1','width=400,height=200');

            matchAmbiArray = false;
            return false;
        }
    }

    if (!checkCity(document.flights.dest1, document.flights.destination1)) {
        if (!matchAmbiArray) {
            //alert(DEST_IS_AMBIGUOUS);
            if (Language == "english" || Language == "us")
                window.open('/includes/home/en/resCity/dest_errorPopupOKCancelCityListE.html','city__flights_dest1__flights_destination1','width=390,height=220');
            else
                window.open('/includes/home/fr/resCity/dest_errorPopupOKCancelCityListF.html','city__flights_dest1__flights_destination1','width=390,height=220');

            return false;
        }
        else{
            var word = document.flights.dest1.value;
            if (word.toUpperCase() == "NEW YORK") {
                word = "NEW+YORK";
            }

            if (Language == "english" || Language == "us")
                window.open('/includes/home/en/resCity/dest_ambiCityE.html','ambiCity2__flights_dest1__flights_destination1','width=400,height=200');
            else
                window.open('/includes/home/fr/resCity/dest_ambiCityF.html','ambiCity2__flights_dest1__flights_destination1','width=400,height=200');

            matchAmbiArray = false;
            return false;
        }
    }

    if( isInvalidCityPair( document.flights.origin1.value, document.flights.destination1.value ) )
    {
        if (Language == "english" || Language == "us") url = "/cto5/errorPopupInvalidCityE.html";
        else url = "/cto5/errorPopupInvalidCityF.html";
        features = 'scrollbars=yes,width=300,height=200,resizeable=yes';
        popup = window.open(url, 'Error', features);
        return false;
    };

    return true;
}


//------------------------------------------------------------------------------
flightResult = false;
function submitsearch() {
    flightResult = true;
    checkSessCookie();
    if (_token != null && _token != "") document.flights.TOKN.value = _token;
    if (_custid != null && _custid != "") document.flights.CUST.value = _custid;
    if (_session != null && _session != "") document.flights.SESS.value = _session;
    if (_sellCountryCode != null && _sellCountryCode != "") document.flights.sellingCountryCode.value = _sellCountryCode;

    // PRJ462 Web Re-launch
	// New select page to be displayed if domestic flight search
    if (checkForDomestic()) {
    	document.flights.action = "https://w4.aircanada.ca/servlet/CTO5SearchServlet/select_rel";    
    }
    else if (checkForTransborder()){
//    alert("transborber ITA");
    	document.flights.action = "https://w4.aircanada.ca/servlet/CTO5SearchServlet/select_tb_rel";
    }
    else if (document.flights.searchType[0].checked) {
        // shop by fare
        //document.flights.action = "http://32.69.3.137:6443/cgi-bin/res/flightsByFare.cgi";
        //document.flights.action = "http://159.206.52.73/cgi-bin/res/flightsByFare.cgi";
        document.flights.origin.value = document.flights.origin1.value;
	  	document.flights.destination.value = document.flights.destination1.value;
	
	  	document.flights.departMonthYear.value = document.flights.departMonthYear1.options[document.flights.departMonthYear1.selectedIndex].value;
	  	document.flights.departDay.value = document.flights.departDay1.options[document.flights.departDay1.selectedIndex].value;
	  	document.flights.departTime.value = document.flights.departTime1.options[document.flights.departTime1.selectedIndex].value;
	  	if (document.flights.tripType[0].checked) {
	  		document.flights.returnMonthYear.value = document.flights.departMonthYear2.options[document.flights.departMonthYear2.selectedIndex].value;
	   		document.flights.returnDay.value = document.flights.departDay2.options[document.flights.departDay2.selectedIndex].value;
	   		document.flights.returnTime.value = document.flights.departTime2.options[document.flights.departTime2.selectedIndex].value;
	   	}
        document.flights.action = "https://w4.aircanada.ca/cgi-bin/res/flightsByFare.cgi";
        
  }
    else if (document.flights.searchType[1].checked) {
        // shop by schedule
        //document.flights.action = "http://32.69.3.137:6443/servlet/CTO5SearchServlet/outside_select";
        //document.flights.action = "http://159.206.52.73/servlet/CTO5SearchServlet/outside_select";
        document.flights.action = "https://w4.aircanada.ca/servlet/CTO5SearchServlet/outside_select";
    }
    
    
    //*********** LOGIC ADDED FOR FUTURE DATE BOOKING
// Increment departure year incase of same month and departure day lesser than current day

    	inputDepMonth = getMonth(document.flights.departMonthYear1.options[document.flights.departMonthYear1.selectedIndex].value);
    	
    	if((getMonthOfYear(inputDepMonth)==getZeroPadded( document.flights.currentmonth.value, 2 ))&&(getZeroPadded( document.flights.currentday.value, 2 )-document.flights.departDay1.options[document.flights.departDay1.selectedIndex].text>0))
    	{
     		inputYear=getCurrentDateAsNumber().toString().substring(0,4);
    		inputYear= parseInt(inputYear)+1;
    		document.flights.departMonthYear1.options[document.flights.departMonthYear1.selectedIndex].value=inputDepMonth+inputYear;
     		
    	}
    
    
// Increment return year incase of same month and return day lesser than current day

		inputRetMonth = getMonth(document.flights.departMonthYear2.options[document.flights.departMonthYear2.selectedIndex].value);
    	
    		if((getMonthOfYear(inputRetMonth)==getZeroPadded( document.flights.currentmonth.value, 2 ))&&(getZeroPadded( document.flights.currentday.value, 2 )-document.flights.departDay2.options[document.flights.departDay2.selectedIndex].text>0))
    		{
    		inputYear=getCurrentDateAsNumber().toString().substring(0,4);
     		inputYear= parseInt(inputYear)+1;
    		document.flights.departMonthYear2.options[document.flights.departMonthYear2.selectedIndex].value=inputRetMonth+inputYear;
    			}


//***************

    
    
    

    document.flights.submit();
    //SR 97501220 Prompt for "Op by Austrian/Lauda/Tyrolean"
    checkforTyrolean();        
}


//------------------------------------------------------------------------------
function onScheduleSubmit() {
    // alert("I will " + ((scheduleResult) ? "Pass" : "Fail"));
    return scheduleResult;
}


//------------------------------------------------------------------------------
function flightDateSelected(dateStr) {
    // alert("changing Flight Date");
    spaceIndex1 = dateStr.indexOf(" ");
    spaceIndex2 = dateStr.indexOf(" ", spaceIndex1 + 1);
    //alert(dateStr.substring(0, spaceIndex1).toUpperCase() + "  " + dateStr.substring(spaceIndex1 + 1, spaceIndex2) + "  " + dateStr.substring(spaceIndex2 + 1));
    document.flifo.flightMonth.value = dateStr.substring(0, spaceIndex1).toUpperCase();
    document.flifo.flightDay.value = dateStr.substring(spaceIndex1 + 1, spaceIndex2);
    // alert(dateStr.substring(spaceIndex2 + 1 + 2));
    document.flifo.flightYear.value = dateStr.substring(spaceIndex2 + 1 + 2);
}


//------------------------------------------------------------------------------
flifoResult = false;
function flifoValidate() {
    if (document.flifo.flightNumber.value == "") {
        alert('Debe ingresar un N° valido de vuelo');
        document.flifo.flightNumber.focus();
        return;
    }
    flightDateSelected(document.flifo.flightDate.options[document.flifo.flightDate.selectedIndex].value);
    flifoResult = true;
    document.flifo.submit();
}


//------------------------------------------------------------------------------
function onFlifoSubmit() {
    // alert("flifoResult: " + flifoResult);
    // alert("I will " + ((scheduleResult) ? "Pass" : "Fail"));
    return flifoResult;
}


//------------------------------------------------------------------------------
var _sessionInfo = "";
var _session = "";
var _sellCountryCode = "";
var _token = "";
var _lang = "";
var _custid = "";
var _balance = "";
function checkSessCookie() {
        var CookieString = document.cookie;
        var CookieSet = CookieString.split (';');
        var SetSize = CookieSet.length;
        var CookiePieces;
        var x = 0;
        _sessionInfo = "";
        //alert(document.cookie);
        for (x = 0; ((x < SetSize) && ( _sessionInfo == "")); x++)
        {
            CookiePieces = CookieSet[x].split ('=');
            if (CookiePieces[0].substring (0,1) == ' ') {
                CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
            }
            if (CookiePieces[0] == "sessionInfo")
            {
                 _sessionInfo = CookiePieces[1];
            }
        }
        //alert(_sessionInfo);
         if (  (_sessionInfo != null) && (_sessionInfo != "")  )
        {
            var a = _sessionInfo.split('&');

            for (x = 0; x < a.length; x++)
            {
                CookiePieces = a[x].split(':');
                                if (CookiePieces[0].substring (0,1) == ' ') {
                        CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
                }
                if (CookiePieces[0] == "session")
                {
                        _session = CookiePieces[1];
                }
                if (CookiePieces[0] == "sellCountryCode")
                {
                        _sellCountryCode = CookiePieces[1];
                }
                if (CookiePieces[0] == "token")
                {
                        _token = CookiePieces[1];
                }
                if (CookiePieces[0] == "lang")
                {
                        _lang = CookiePieces[1];
                }
                 if (CookiePieces[0] == "custid")
                {
                        _custid = CookiePieces[1];
                }
                if (CookiePieces[0] == "balance")
                {
                        _balance = CookiePieces[1];
                }
            }
               return true;
        }
        return false;
}


//------------------------------------------------------------------------------
function checkCookiePref(CookieName) {
    var CookieString = document.cookie;
    var CookieSet = CookieString.split (';');
    var SetSize = CookieSet.length;
    var CookiePieces;
    var ReturnValue = "";
    var x = 0;

    for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) {
        CookiePieces = CookieSet[x].split ('=');

        if (CookiePieces[0].substring (0,1) == ' ')
            CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
        if (CookiePieces[0] == CookieName)
            ReturnValue = CookiePieces[1];
    }

    if (ReturnValue != Language) resetCookie2('new_lang_pref', Language, '/');
}


//------------------------------------------------------------------------------
function resetCookie2(cookieName, cookieValue, cookiePath ) {
	var expDate = new Date();
	var domain=location.hostname;
	var domain1=".aircanada.ca";
	var domain2=".aircanada.com";
	expiry = langCookieLifetime * 1000 * 60 * 60 * 24;
	expDate.setTime (expDate.getTime() + expiry);

	if (cookieValue == "french"){
               if (domain.search("aircanada.com") != -1) {
                document.cookie = cookieName + "=" + escape (cookieValue)
                + "; path=" + cookiePath
                + "; expires=" + expDate.toGMTString()
                + "; domain=" + domain2;
        //alert("french write on com");
                location.replace('http://www.aircanada.ca/setcookie_fr.html');

          }
        else    {
                document.cookie = cookieName + "=" + escape (cookieValue)
                + "; path=" + cookiePath
                + "; expires=" + expDate.toGMTString()
                + "; domain=" + domain1;
        //alert("french write on ca");
        location.replace('http://www.aircanada.com/setcookie_fr.html');
            }
	}

	if (cookieValue == "us"){
               if (domain.search("aircanada.com") != -1) {
                document.cookie = cookieName + "=" + escape (cookieValue)
                + "; path=" + cookiePath
                + "; expires=" + expDate.toGMTString()
                + "; domain=" + domain2;
        //alert("us write on com");
                location.replace('http://www.aircanada.ca/setcookie_us.html');
          }
        else    {
                document.cookie = cookieName + "=" + escape (cookieValue)
                + "; path=" + cookiePath
                + "; expires=" + expDate.toGMTString()
                + "; domain=" + domain1;
        //alert("us write on ca");
        location.replace('http://www.aircanada.com/setcookie_us.html');
            }
	}

	if (cookieValue == "english"){
               if (domain.search("aircanada.com") != -1) {
                document.cookie = cookieName + "=" + escape (cookieValue)
                + "; path=" + cookiePath
                + "; expires=" + expDate.toGMTString()
                + "; domain=" + domain2;
                location.replace('http://www.aircanada.ca/setcookie_eng.html');
          }
        else    {
                document.cookie = cookieName + "=" + escape (cookieValue)
                + "; path=" + cookiePath
                + "; expires=" + expDate.toGMTString()
                + "; domain=" + domain1;
        location.replace('http://www.aircanada.com/setcookie_eng.html');
            }
	}
}


//------------------------------------------------------------------------------
function closewaitwindow() {
     if(waitingscreen != null){
          waitingscreen.close();
     }
}


//------------------------------------------------------------------------------
function removeLeadingZeroes(origStr) {
    var returnStr = new String(origStr);
    return returnStr.replace(/^0*/, "");
}


//------------------------------------------------------------------------------
function init1() {
    // set language cookie
    if (cookieEnable()) checkCookiePref('new_lang_pref');

    // because both the english and US home pages use the same english res_tab-ac,
    // the sellingCountryCode is statically coded as "CA". here, we make sure
    // when the US page is loaded, we set the US sellingCountryCode
    if (Language == "us") {
        document.flights.sellingCountryCode.value = "US";
        document.flights.ticketingCountryCode.value = "US";
    }

    init();
    checkcampaigncookie();
}


//------------------------------------------------------------------------------
function init() {
    loaded = true;
    //closewaitwindow();

  //reset to round trip
  document.flights.tripType[0].checked = true;

  //reset to no origin nor destination selected
  //document.flights.origin1.value = "";
  //document.flights.org1.value = "";
  //document.flights.destination1.value = "";
  //document.flights.dest1.value = "";

  //reset to today's date
    popMonth(document.flights.departMonthYear1, 0,
        document.flights.currentmonth.value,
        document.flights.currentyear.value,
        POSITIVE_INFINITY,
        POSITIVE_INFINITY);

    popMonth(document.flights.departMonthYear2, 0,
        document.flights.currentmonth.value,
        document.flights.currentyear.value,
        POSITIVE_INFINITY,
        POSITIVE_INFINITY);

  document.flights.departMonthYear1.selectedIndex = 0;
  document.flights.departMonthYear2.selectedIndex = 0;

  for (i = 0; i < document.flights.departDay1.length; i ++) {
    if (parseInt(removeLeadingZeroes(document.flights.departDay1.options[i].value)) == parseInt(removeLeadingZeroes(document.flights.currentday.value))) {
            document.flights.departDay1.selectedIndex = i;
            break;
        }
  }

  for (i = 0; i < document.flights.departDay2.length; i ++) {
    if (parseInt(removeLeadingZeroes(document.flights.departDay2.options[i].value)) == parseInt(removeLeadingZeroes(document.flights.currentday.value))) {
      document.flights.departDay2.selectedIndex = i;
            break;
        }
  }
  
  //alert("new_session="+new_session);
//SR97500911 - when the user click Home button  
	if(new_session!="clean"){
//restore the booking values from cookie
		restoreDepAndRetDatesFromCookies();
	} else {
		setCookie("newSession", 'dirty', null, "/");
	}
//SR97500911 - END					
}


//------------------------------------------------------------------------------
function popMonth(monthYearList, listIndex, startMonth, startYear, endMonth, endYear) {
    // if there is no end date (end month and year), the calling function should
    // pass "POSITIVE_INFINITY" as the values for the endMonth and endYear params

    //alert("popMonth: got sm = " + startMonth + ", sy = " + startYear + ", em = " + endMonth + ", ey = " + endYear);

    var month = new Number(startMonth);
    var year = new Number(startYear);

    // check month and year numbers
    if ((month.toString() == "NaN") || (year.toString() == "NaN")
        || (endMonth.toString() == "NaN") || (endYear.toString() == "NaN")
        || (endYear < year) || (endYear == year && endMonth < month) ) {
        return;
    }
    else {
        monthYearList.selectedIndex = listIndex;
        for (; listIndex < monthYearList.length; listIndex ++) {
            // add proper entry to list
            if (year < endYear || ((year == endYear) && (month <= endMonth))) {
                //alert("SHOW m" + month + " y" + year);
                // month is before or on end date month, show month and year
                monthYearList.options[listIndex].text = months[month - 1][0] ;   // Set text to full month name and year
                monthYearList.options[listIndex].value = months[month - 1][1] + year;        // Set value to abbrviated month name and year

            }
            else {
                //alert("BLANK m" + month + " y" + year);
                // month is after end date month, show blank
                monthYearList.options[listIndex].text = "";   // Set text to full month name and year
                monthYearList.options[listIndex].value = "";        // Set value to abbrviated month name and year
            }

            // increment month and year while checking for month roll over
            if (++month > 12) {
                month = 1;
                year ++;
            }
        }
    }
}


//------------------------------------------------------------------------------
/* browser check */
function IsBrowser() {
    var AppString = navigator.appName;
    var isNS = (AppString == "Netscape" );
    if (isNS )
         result = 'ns';
    else
    if (AppString.indexOf('Explorer') != -1)
            result = 'ie';

    return result;
}


//------------------------------------------------------------------------------
var signon = null;
function onLoginSubmit (form) {
    var aeronum = form.CustomerNumber1.value + form.CustomerNumber2.value + form.CustomerNumber3.value;
    for (i = 0; i < 9; i++) {
        if (aeronum.charAt(i) < "0" || aeronum.charAt(i) > "9") {
            alert(INVALID_AEROPLANNO);
            form.CustomerNumber1.focus();
            form.CustomerNumber1.select();
            return false;
        }
    }
    if (form.PIN.value == "") {
        alert(INVALID_PIN);
        form.PIN.focus();
        form.PIN.select();
        return false;
    }

    //popup window for authenticated session
    self.name="Logon";
    if (signon == null || signon.closed) {
       signon = window.open("","signon");
       signon.window.moveTo(0, 0);
       signon.window.resizeTo(screen.availWidth, screen.availHeight);
    }
    else {
       signon.focus();
    }
    return true;
}


//------------------------------------------------------------------------------
function closeDep() {
    if (signon && signon.open && !signon.closed) {
           document.login.CustomerNumber1.value = '';
           document.login.CustomerNumber2.value = '';
           document.login.CustomerNumber3.value = '';
           document.login.PIN.value = '';
           signon.close();
    }
}


//------------------------------------------------------------------------------
function aeroplandisplay(){
    var address = location.hostname;
    if (address.search(".aircanada.com") != -1) {
        if (Language == "english" || Language == "us")
            location.replace("http://www.aircanada.ca/newaeroplan/toar.html");
        else
            location.replace("http://www.aircanada.ca/francais/newaeroplan/toar.html");

        return;
    }
    checkSessCookie();
    toStartBooking();
}


//------------------------------------------------------------------------------
function toStartBooking(){
    if ( _custid == "" ) {
            document.forms.guest_startbooking.CustomerId.value = "GUEST";
            document.forms.guest_startbooking.submit();
    }
    else {

        document.forms.startbooking.SSO.value = "true";
        document.forms.startbooking.CustomerId.value = _custid;
        document.forms.startbooking.SessionId.value = _session;
        //alert("sessionid=" + document.forms.startbooking.SessionId.value + "aeroplan number=" + document.forms.startbooking.CustomerId.value );
        document.forms.startbooking.submit();

    }
}


//------------------------------------------------------------------------------
function removecookie() {
    var address = location.href;
    if ( !cookieEnable() ) return;

    checkSessCookie();
    if ( _custid == "GUEST" ) { // GUEST
        writeCookie("sessionInfo", "" );
    }
}


//------------------------------------------------------------------------------
function classType_onChange() {
    if (document.flights.classType.selectedIndex > 0)
        document.flights.searchType[1].checked = true;
    else
        document.flights.searchType[0].checked = true;
}


//------------------------------------------------------------------------------
function searchType_onChange() {
    if (document.flights.classType.selectedIndex > 0)
        document.flights.searchType[1].checked = true;
}

//------------------------------------------------------------------------------
// PRJ462 Web Re-launch
// New select page to be displayed if domestic economy flight search
originDomestic = false;
destinationDomestic = false;
function checkForDomesticEconomy() {
    airportOrgCode = document.flights.origin1.value.toUpperCase();
    airportDestCode = document.flights.destination1.value.toUpperCase();
    fareType = document.flights.classType.options[document.flights.classType.selectedIndex].value.toUpperCase();
  	for (i=0; i<Countries.length; i++) {
 		if (Countries[i][0] == airportOrgCode) {
			//alert("Org:"+Countries[i][1]);	
 			if (Countries[i][1].toUpperCase() == "CA")
	 			originDomestic = true;
 			break;
 		}
 	}
  	for (i=0; i<Countries.length; i++) {
 		if (Countries[i][0] == airportDestCode) {
 			//alert("Dest:"+Countries[i][1]);	
 			if (Countries[i][1].toUpperCase() == "CA")
	 			destinationDomestic = true;
 			break;
 		}
 	}
    if ( (originDomestic && destinationDomestic) && ((fareType == "E") || (fareType == "Y")) ) {
   		return true;	
    }
    else 
    	return false;
}

function checkForDomestic() {
    airportOrgCode = document.flights.origin1.value.toUpperCase();
    airportDestCode = document.flights.destination1.value.toUpperCase();
  	for (i=0; i<Countries.length; i++) {
 		if (Countries[i][0] == airportOrgCode) {
			//alert("Org:"+Countries[i][1]);	
 			if (Countries[i][1].toUpperCase() == "CA")
	 			originDomestic = true;
 			break;
 		}
 	}
  	for (i=0; i<Countries.length; i++) {
 		if (Countries[i][0] == airportDestCode) {
 			//alert("Dest:"+Countries[i][1]);	
 			if (Countries[i][1].toUpperCase() == "CA")
	 			destinationDomestic = true;
 			break;
 		}
 	}
    if ( originDomestic && destinationDomestic ) {
   		return true;	
    }
    else {
    	return false;
    }
}

originIsDomestic = false;
destinationIsDomestic = false;
originIsTransborder = false;
destinationIsTransborder = false;
function checkForTransborder() {

    airportOrgCode = document.flights.origin1.value.toUpperCase();
    airportDestCode = document.flights.destination1.value.toUpperCase();
  	for (i=0; i<Countries.length; i++) {
 		if (Countries[i][0] == airportOrgCode) {
			//alert("Org:"+Countries[i][1]);	
 			if (Countries[i][1].toUpperCase() == "CA"){
	 			originIsDomestic = true;
	 		}else if (Countries[i][1].toUpperCase() == "US"){
	 			originIsTransborder = true;
	 		}else {
	 			originIsDomestic = false;
				originIsTransborder = false;
	 		}
 			break;
 		}
 	}
  	for (i=0; i<Countries.length; i++) {
 		if (Countries[i][0] == airportDestCode) {
 			//alert("Dest:"+Countries[i][1]);	
 			if (Countries[i][1].toUpperCase() == "CA"){
	 			destinationIsDomestic = true;
	 		}else if (Countries[i][1].toUpperCase() == "US"){
	 			destinationIsTransborder = true;
	 		}else {
				destinationIsDomestic = false;
				destinationIsTransborder = false;	 		
	 		}	
 			break;
 		}
 	}
    if ( (originIsDomestic && destinationIsTransborder) || (originIsTransborder && destinationIsDomestic) || (originIsTransborder && destinationIsTransborder)) {
   		return true;	
    }
    else 
    	return false;
}


//------------------------------------------------------------------------------
// PRJ462 Web Re-launch
// for mouse over effects on res-tab-ac.html for home page
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//SR 97501220 Prompt for "Op by Austrian/Lauda/Tyrolean"
//display pop-up for flights after April 04, 2004 between YYZ/YUL and GRZ/INN/KLU/LNZ/SZG
function checkforTyrolean() {
    var airportOrgCode = document.flights.origin1.value.toUpperCase();
    var airportDestCode = document.flights.destination1.value.toUpperCase();
	var departDate = getDateNumber();  
	var returnDate = 0;
   	if (document.flights.tripType[0].checked) {
		returnDate = getDateNumber("Ret");
	}
    if ((departDate >= 20040404 || returnDate >= 20040404) && 
    	(airportDestCode=="GRZ" || airportDestCode=="INN" || airportDestCode=="KLU" || airportDestCode=="LNZ" || airportDestCode=="SZG" ||
        airportOrgCode=="GRZ" || airportOrgCode=="INN" || airportOrgCode=="KLU" || airportOrgCode=="LNZ" || airportOrgCode=="SZG")) {
		displayTyroleanPopup();        
    }
}

//SR 97501220 Prompt for "Op by Austrian/Lauda/Tyrolean"
var tyrolean_window = null;
function displayTyroleanPopup() {
	if (tyrolean_window == null) {
		if (Language == "english" || Language == "us") {
			tyrolean_window = _openWindow(true,'/cto5/popup_SearchFlightInfoE.html','Popup_SearchFlightInfo','368','150');
		} else {
			tyrolean_window = _openWindow(true,'/cto5/popup_SearchFlightInfoF.html','Popup_SearchFlightInfo','368','150');		
		}
	}
}


//SR 97501339 display a popup window if the Campaign cookie not equals to current campaign
function checkcampaigncookie() {
var campaignscreen;
  if (document.dataForm.language.value == "us") {
     if (current_USCampaignName != "999") {
        //check the USCampaign cookie
        var UScampaignN = getCookie("USCampaign");
	if (UScampaignN != current_USCampaignName) {
	  campaignscreen = popCenterWindow('/includes/home/en/popup_uscampaign.html', 'campaign', 440, 220);
	  campaignscreen.focus();
	}
     }
  }else {
     if (currentCampaignName != "999") {
	//check the Campaign cookie 
	var campaignN = getCookie("Campaign");
	if (campaignN != currentCampaignName) {
	   if (document.dataForm.language.value == "french") {
		campaignscreen = popCenterWindow('/includes/home/fr/popup_campaign.html', 'campaign', 440, 220);
		}else {
		campaignscreen = popCenterWindow('/includes/home/en/popup_campaign.html', 'campaign', 440, 220);
           }
           campaignscreen.focus();
	}
    }
  }
}
