/* Minification failed. Returning unminified contents.
(1,17): run-time error CSS1031: Expected selector, found '='
(1,17): run-time error CSS1025: Expected comma or open brace, found '='
(2,16): run-time error CSS1031: Expected selector, found ';'
(2,16): run-time error CSS1025: Expected comma or open brace, found ';'
(3,10): run-time error CSS1031: Expected selector, found 'APICallForJSON('
(3,10): run-time error CSS1025: Expected comma or open brace, found 'APICallForJSON('
(479,10): run-time error CSS1031: Expected selector, found 'SiteMapRgex('
(479,10): run-time error CSS1025: Expected comma or open brace, found 'SiteMapRgex('
(485,15): run-time error CSS1031: Expected selector, found '='
(485,15): run-time error CSS1025: Expected comma or open brace, found '='
(486,15): run-time error CSS1031: Expected selector, found '='
(486,15): run-time error CSS1025: Expected comma or open brace, found '='
(487,10): run-time error CSS1031: Expected selector, found 'WebsiteSearch('
(487,10): run-time error CSS1025: Expected comma or open brace, found 'WebsiteSearch('
(548,10): run-time error CSS1031: Expected selector, found 'supports_storage('
(548,10): run-time error CSS1025: Expected comma or open brace, found 'supports_storage('
(556,10): run-time error CSS1031: Expected selector, found 'autocompleteCPList('
(556,10): run-time error CSS1025: Expected comma or open brace, found 'autocompleteCPList('
(616,10): run-time error CSS1031: Expected selector, found 'smreturnlogo('
(616,10): run-time error CSS1025: Expected comma or open brace, found 'smreturnlogo('
(670,1): run-time error CSS1019: Unexpected token, found '('
(670,11): run-time error CSS1031: Expected selector, found '('
(670,11): run-time error CSS1025: Expected comma or open brace, found '('
(765,2): run-time error CSS1019: Unexpected token, found ')'
(765,3): run-time error CSS1019: Unexpected token, found '('
(765,10): run-time error CSS1031: Expected selector, found ')'
(765,10): run-time error CSS1025: Expected comma or open brace, found ')'
(766,1): run-time error CSS1019: Unexpected token, found '('
(766,11): run-time error CSS1031: Expected selector, found '('
(766,11): run-time error CSS1025: Expected comma or open brace, found '('
(1466,2): run-time error CSS1019: Unexpected token, found ')'
(1466,3): run-time error CSS1019: Unexpected token, found '('
(1466,10): run-time error CSS1031: Expected selector, found ')'
(1466,10): run-time error CSS1025: Expected comma or open brace, found ')'
(1468,1): run-time error CSS1019: Unexpected token, found '/'
(1468,2): run-time error CSS1019: Unexpected token, found '/'
(1468,3): run-time error CSS1019: Unexpected token, found '31'
(1468,15): run-time error CSS1031: Expected selector, found '-'
(1468,15): run-time error CSS1025: Expected comma or open brace, found '-'
(1619,23): run-time error CSS1031: Expected selector, found '='
(1619,23): run-time error CSS1025: Expected comma or open brace, found '='
(1640,2): run-time error CSS1019: Unexpected token, found ';'
(1641,10): run-time error CSS1031: Expected selector, found 'returnlogo('
(1641,10): run-time error CSS1025: Expected comma or open brace, found 'returnlogo('
(1646,1): run-time error CSS1019: Unexpected token, found '/'
(1646,2): run-time error CSS1019: Unexpected token, found '/'
(1646,25): run-time error CSS1031: Expected selector, found '-'
(1646,25): run-time error CSS1025: Expected comma or open brace, found '-'
(1653,10): run-time error CSS1031: Expected selector, found 'airportLanding('
(1653,10): run-time error CSS1025: Expected comma or open brace, found 'airportLanding('
(1693,10): run-time error CSS1031: Expected selector, found 'createSkipLinks('
(1693,10): run-time error CSS1025: Expected comma or open brace, found 'createSkipLinks('
(1747,10): run-time error CSS1031: Expected selector, found 'compareStrings('
(1747,10): run-time error CSS1025: Expected comma or open brace, found 'compareStrings('
(1754,10): run-time error CSS1031: Expected selector, found 'loungeAccessData('
(1754,10): run-time error CSS1025: Expected comma or open brace, found 'loungeAccessData('
(1827,10): run-time error CSS1031: Expected selector, found 'SetLinkTargets('
(1827,10): run-time error CSS1025: Expected comma or open brace, found 'SetLinkTargets('
(1844,10): run-time error CSS1031: Expected selector, found 'validateMaxLength('
(1844,10): run-time error CSS1025: Expected comma or open brace, found 'validateMaxLength('
(1854,10): run-time error CSS1031: Expected selector, found 'getUrlVars('
(1854,10): run-time error CSS1025: Expected comma or open brace, found 'getUrlVars('
(1865,10): run-time error CSS1031: Expected selector, found 'setCookie('
(1865,10): run-time error CSS1025: Expected comma or open brace, found 'setCookie('
(1871,10): run-time error CSS1031: Expected selector, found 'getCookie('
(1871,10): run-time error CSS1025: Expected comma or open brace, found 'getCookie('
(1876,10): run-time error CSS1031: Expected selector, found 'eraseCookie('
(1876,10): run-time error CSS1025: Expected comma or open brace, found 'eraseCookie('
(1880,10): run-time error CSS1031: Expected selector, found 'MaintainenceAction('
(1880,10): run-time error CSS1025: Expected comma or open brace, found 'MaintainenceAction('
(1894,10): run-time error CSS1031: Expected selector, found 'contactUsFormValidation('
(1894,10): run-time error CSS1025: Expected comma or open brace, found 'contactUsFormValidation('
(1908,10): run-time error CSS1031: Expected selector, found 'ClearInputMask('
(1908,10): run-time error CSS1025: Expected comma or open brace, found 'ClearInputMask('
(1931,10): run-time error CSS1031: Expected selector, found 'buttonUp('
(1931,10): run-time error CSS1025: Expected comma or open brace, found 'buttonUp('
(1942,1): run-time error CSS1019: Unexpected token, found '$'
(1942,2): run-time error CSS1019: Unexpected token, found '('
(1942,11): run-time error CSS1031: Expected selector, found ')'
(1942,11): run-time error CSS1025: Expected comma or open brace, found ')'
(2502,2): run-time error CSS1019: Unexpected token, found ')'
(2502,3): run-time error CSS1019: Unexpected token, found ';'
(2506,1): run-time error CSS1019: Unexpected token, found '$'
(2506,2): run-time error CSS1019: Unexpected token, found '('
(2506,9): run-time error CSS1031: Expected selector, found ')'
(2506,9): run-time error CSS1025: Expected comma or open brace, found ')'
(2528,2): run-time error CSS1019: Unexpected token, found ')'
(2528,3): run-time error CSS1019: Unexpected token, found ';'
(2531,1): run-time error CSS1019: Unexpected token, found '$'
(2531,2): run-time error CSS1019: Unexpected token, found '('
(2531,11): run-time error CSS1031: Expected selector, found ')'
(2531,11): run-time error CSS1025: Expected comma or open brace, found ')'
(2535,2): run-time error CSS1019: Unexpected token, found ')'
(2535,3): run-time error CSS1019: Unexpected token, found ';'
(2537,1): run-time error CSS1019: Unexpected token, found '/'
(2537,2): run-time error CSS1019: Unexpected token, found '/'
(2538,10): run-time error CSS1031: Expected selector, found 'airlineCall('
(2538,10): run-time error CSS1025: Expected comma or open brace, found 'airlineCall('
(2544,1): run-time error CSS1019: Unexpected token, found '/'
(2544,2): run-time error CSS1019: Unexpected token, found '/'
(2545,10): run-time error CSS1031: Expected selector, found 'getAirlineList('
(2545,10): run-time error CSS1025: Expected comma or open brace, found 'getAirlineList('
(2640,71): run-time error CSS1002: Unterminated string: 't submit form on keypress
 */
var DepArrArray = [, ];
var theLanguage;
function APICallForJSON(Url, apiKey, type, airlineCtrl) {
    $(".sk-modal").removeClass("hidden");
    $("#sp-error-api").hide();
    theLanguage = $('html').attr('lang');
    //Language Filter and exclusion - 29-Feb-2016
    //if (theLanguage.toLowerCase() == 'nl' || theLanguage.toLowerCase() == 'cs') {
    //    theLanguage = 'en';
    //}
    if (theLanguage.toLowerCase() == 'pt-br') {
        theLanguage = 'pt';
    }
    if (theLanguage.toLowerCase() == 'zh') {
        theLanguage = 'zh-Hans';
    }
    if (theLanguage.toLowerCase() == 'zh-tw') {
        theLanguage = 'zh-Hant';
    }
 $.support.cors = true;
    
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var rv = 0;
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }

    
    if (rv < 10) {
        
        var skylinkapi = $("#api-action").val();

        $.get(skylinkapi, { apiBaseURL: Url, Key: apiKey }, function (data) {
            data = $.parseJSON(data);
            $(".sk-modal").addClass("hidden");
            if (type == "autocomplete") {
                autocompleteCPList(data);
                if (data != null && data != 'undefined') {
                    if (supports_storage() == true) {
                        var tmpData = JSON.stringify(data);
                        sessionStorage.autoCompleteResults = tmpData;
                    }
                }
            }

            else if (type == "flightreturn") {

                if (data != null && data != 'undefined' && data.Schedules != null && data.Schedules != 'undefined') {
                    DepArrArray = onward_return_parse("Onward_Schedules", data);
                    dynresults(DepArrArray, 'showresults', '#slider', '#slider1');
                    totalNoofstops(DepArrArray);
                    //                    noofstops(DepArrArray);
                    //                    noofairlins(DepArrArray);
                    //                    nooftrsferfunction();


                    RetArrArray = onward_return_parse("", data);
                    dynresults(RetArrArray, 'returnresults', '#sliderReturn', '#sliderReturn1');
                    noofstops(RetArrArray);
                    noofairlins(RetArrArray);
                    nooftrsferfunction();
                    /* Error msg display �30-Oct-2015�Justin (script.js)
    */
                    if (DepArrArray.length == 0) {
                        $(".onwardres .result-count").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    }

                    if (RetArrArray.length == 0) {
                        $(".daterange .result-count-ret").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    }



                    ////Changes Deployed - 16-Oct-2015
                    $('#arrowchange').removeClass('icon-datepickerforward');
                    $('#arrowchange').addClass('icon-twoheadarrow');
                }
                else {

                    $(".result-count").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    $(".result-count .result-count-ret").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    $('.return-more-options').css('display', 'none');
                    $('.more-options').css('display', 'none');
                }
            }
            else if (type == 'ffp_status') {

                //29-Oct-2015 - RR - FFP status results
                $("#ffp-img").attr("src", data.loyaltyDetails.airlineFrequentFlyerProgramDetails.logo + "?api_key=5m49bjnak3nsrv5hdkf4aab6");
                $("#ff-status-icon").attr("src", data.loyaltyDetails.skyTeamLoyaltyStatus.logo + "?api_key=5m49bjnak3nsrv5hdkf4aab6");
                $("#ffp-status-info").html(data.loyaltyDetails.skyTeamLoyaltyStatus.loyaltyStatus);
                $("#ffp-img").css("display", "block");
                $('.ffp-results').css("display", "block");
                $(".ffp-results-error").css("display", "none");

            }
            else if (type == 'ffp_tirlevels') {
                var tierData = '<option value="Select Your Tier Level" selected="">Select Your Tier Level</option>';
                for (k = 0; k < data.loyaltyDetails.airlineFrequentFlyerProgramDetails.tiers.length; k++) {
                    tierData = tierData + '<option value="' + data.loyaltyDetails.airlineFrequentFlyerProgramDetails.tiers[k].tier + '">' + data.loyaltyDetails.airlineFrequentFlyerProgramDetails.tiers[k].tier + '</option>';
                }
                $("#ffp-tierlevel-dropdown").removeClass("hidden");
                $("#ffp_tirelevel").html(tierData).selectmenu('refresh', true);
            }

            else if (type == "flightresults") {
                if (data != null && data != 'undefined' && data.Schedules != null && data.Schedules != 'undefined') {

                    DepArrArray = onward_return_parse("Onward_Schedules", data);
                    dynresults(DepArrArray, 'showresults', '#slider', '#slider1');
                    totalNoofstops(DepArrArray);
                    noofstops(DepArrArray);
                    noofairlins(DepArrArray);
                    nooftrsferfunction();

                } else {
                    $(".result-count").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    $('.more-options').css('display', 'none');
                }
            }
            else if (type == "loungefinder") {
                if (data.hasOwnProperty("Errors")) {
                    $('#loungeheader').html("<h3>" + data.Errors[0].Business_Error_Description + "<h3>");
                    $('html, body').animate({
                        scrollTop: $(".airport-details-lounges").offset().top - 100
                    }, 1000)
                }

                else if (data != null && data != 'undefined') {
                    loungeFinderResults(data);
                    // if (supports_storage() == true) {

                    //    var laungResults = JSON.stringify(data);
                    //    localStorage.setItem('loungeResults', laungResults);
                    // }
                }
            }
            else if (type == "loungeaccess") {
                if (data != null && data != 'undefined') {
                    loungeAccessData(data);
                }
            }

            else if (type == "flightStatus") {
                if (data != null && data != 'undefined') {
                    dynhtmlloadingh(data);
                }
            }
            else if (type == "SkyBasic") {
                if (data != null && data != 'undefined') {
                    skyPriority(data);
                }
            }
            else if (type == "SkyAdvance") {
                if (data != null && data != 'undefined') {
                    advskyPriority(data);
                }
            }
            else if (type == "flightStatus-OD") {

                if (data != null && data != 'undefined') {
                    o_d_Search(data);
                }
            }
            else if (type == "AirlineAPI") {
                if (data != null && data != 'undefined') {
                    $("#sp-error-api").hide();
                    $('#sp-airline-button').show();
                    $('.newtransfer-sp').show();
                    $('#btn-search-sky-flights').show();
                    $('.returninput-skypriority').show();
                    getAirlineList(data, airlineCtrl);
                }
            }
 		else if (type == "AirportMap") {
                if (data != null && data != 'undefined') {
                    getAirportMap(data, airlineCtrl);
                }
            }
            else if (type == "travelinfo") {

                if (data != null && data != 'undefined') {
                    travelguides(data);
                    //console.log(data);

                }
            }
            else if (type == "cityguide") {

                if (data != null && data != 'undefined') {
                    cityguides(data);

                }
            } else if (type == "events") {

                if (data != null && data != 'undefined') {
                    events(data);

                }
            } else if (type == "lounge") {

                if (data != null && data != 'undefined') {

                    loungeFinderResults(data);

                }
            }
            else if (type == "CargoTrack") {

                if (data != null && data != 'undefined') {
                    cargoresults(data);
                }
            }
        });
    }


    else {


    $.ajax({
        url: Url,
        dataType: "json",
        headers: {
            'api_key': apiKey,
            'accept-language': theLanguage,
            'Cache-Contol': 'no-cache, no-store',
        },
        success: function (data) {
            $(".sk-modal").addClass("hidden");
            if (type == "autocomplete") {
                autocompleteCPList(data);
                if (data != null && data != 'undefined') {
                    if (supports_storage() == true) {
                        var tmpData = JSON.stringify(data);
                        sessionStorage.autoCompleteResults = tmpData;
                    }
                }
            }
            else if (type == "flightreturn") {

                if (data != null && data != 'undefined' && data.Schedules != null && data.Schedules != 'undefined') {
                    DepArrArray = onward_return_parse("Onward_Schedules", data);
                    dynresults(DepArrArray, 'showresults', '#slider', '#slider1');
                    totalNoofstops(DepArrArray);
                    //                    noofstops(DepArrArray);
                    //                    noofairlins(DepArrArray);
                    //                    nooftrsferfunction();


                    RetArrArray = onward_return_parse("", data);
                    dynresults(RetArrArray, 'returnresults', '#sliderReturn', '#sliderReturn1');
                    noofstops(RetArrArray);
                    noofairlins(RetArrArray);
                    nooftrsferfunction();
                    /* Error msg display �30-Oct-2015�Justin (script.js)
*/
                    if (DepArrArray.length == 0) {
                        $(".onwardres .result-count").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    }

                    if (RetArrArray.length == 0) {
                        $(".daterange .result-count-ret").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    }



                    ////Changes Deployed - 16-Oct-2015
                    $('#arrowchange').removeClass('icon-datepickerforward');
                    $('#arrowchange').addClass('icon-twoheadarrow');
                }
                else {

                    $(".result-count").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    $(".result-count .result-count-ret").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    $('.return-more-options').css('display', 'none');
                    $('.more-options').css('display', 'none');
                }
            }
            else if (type == 'ffp_status') {

                //29-Oct-2015 - RR - FFP status results
                $("#ffp-img").attr("src", data.loyaltyDetails.airlineFrequentFlyerProgramDetails.logo + "?api_key=yfunvneadwz62wywjvtgqc8a");
                $("#ff-status-icon").attr("src", data.loyaltyDetails.skyTeamLoyaltyStatus.logo + "?api_key=yfunvneadwz62wywjvtgqc8a");
                $("#ffp-status-info").html(data.loyaltyDetails.skyTeamLoyaltyStatus.loyaltyStatus);
                $("#ffp-img").css("display", "block");
                $('.ffp-results').css("display", "block");
                $(".ffp-results-error").css("display", "none");

            }
            else if (type == 'ffp_tirlevels') {
                var tierData = '<option value="Select Your Tier Level" selected="">Select Your Tier Level</option>';
                for (k = 0; k < data.loyaltyDetails.airlineFrequentFlyerProgramDetails.tiers.length; k++) {
                    tierData = tierData + '<option value="' + data.loyaltyDetails.airlineFrequentFlyerProgramDetails.tiers[k].tier + '">' + data.loyaltyDetails.airlineFrequentFlyerProgramDetails.tiers[k].tier + '</option>';                    
                }
                $("#ffp-tierlevel-dropdown").removeClass("hidden");
                $("#ffp_tirelevel").html(tierData).selectmenu('refresh', true);
            }

            else if (type == "flightresults") {
                if (data != null && data != 'undefined' && data.Schedules != null && data.Schedules != 'undefined') {

                    DepArrArray = onward_return_parse("Onward_Schedules", data);
                    dynresults(DepArrArray, 'showresults', '#slider', '#slider1');
                    totalNoofstops(DepArrArray);
                    noofstops(DepArrArray);
                    noofairlins(DepArrArray);
                    nooftrsferfunction();

                } else {
                    $(".result-count").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                    $('.more-options').css('display', 'none');
                }
            }
            else if (type == "loungefinder") {

                if (data != null && data != 'undefined') {
                    loungeFinderResults(data);
                    // if (supports_storage() == true) {

                    //    var laungResults = JSON.stringify(data);
                    //    localStorage.setItem('loungeResults', laungResults);
                    // }
                }
            }
            else if (type == "loungeaccess") {
                if (data != null && data != 'undefined') {
                    loungeAccessData(data);
                }
            }

            else if (type == "flightStatus") {
                if (data != null && data != 'undefined') {
                    dynhtmlloadingh(data);
                }
            }
            else if (type == "SkyBasic") {
                if (data != null && data != 'undefined') {
                    skyPriority(data);                   
                }
            }
            else if (type == "SkyAdvance") {
                if (data != null && data != 'undefined') {
                    advskyPriority(data);
                }
            }
            else if (type == "flightStatus-OD") {

                if (data != null && data != 'undefined') {
                    o_d_Search(data);
                }
            }
            else if (type == "AirlineAPI") {
                if (data != null && data != 'undefined') {
                    $("#sp-error-api").hide();
                    $('#sp-airline-button').show();
                    $('.newtransfer-sp').show();
                    $('#btn-search-sky-flights').show();
                    $('.returninput-skypriority').show();
                    getAirlineList(data, airlineCtrl);
                }
            }
            else if (type == "travelinfo") {

                if (data != null && data != 'undefined') {
                    travelguides(data);
                    //console.log(data);

                }
            }
		else if (type == "AirportMap") {
                if (data != null && data != 'undefined') {
                    getAirportMap(data, airlineCtrl);
                }
            }
            else if (type == "cityguide") {

                if (data != null && data != 'undefined') {
                    cityguides(data);

                }
            } else if (type == "events") {

                if (data != null && data != 'undefined') {
                    events(data);

                }
            } else if (type == "lounge") {

                if (data != null && data != 'undefined') {

                    loungeFinderResults(data);

                }
            }
            else if (type == "CargoTrack") {

                if (data != null && data != 'undefined') {
                    cargoresults(data);
                }
            }
        },
        error: function (xhr, textStatus, errorThrown) {
       
            $(".sk-modal").addClass("hidden");
            if (type == "flightStatus") {  //NoResultsMessage 
                console.log(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                // $("#directFlighLabel").html(cmsStatus.NoResultsMessage);
                $("#directFlighLabel").html(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                $('#directFlighLabel').css('display', 'block');
                $('html, body').animate({
                    scrollTop: $("#dynFlightStatus").offset().top - 200
                }, 1000);
            } else if (type == "flightStatus-OD") {
                console.log(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                //$("#directFlighLabel").html(cmsStatus.NoResultsMessage);
                $("#directFlighLabel").html(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                $('#directFlighLabel').css('display', 'block');
                $('html, body').animate({
                    scrollTop: $("#dynFlightStatus").offset().top
                }, 1000);
                //28-Oct-2015 - JRS - Error Msg Lounge Finder
            } else if (type == "loungefinder") {
                console.log(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                // $('#loungeheader').html("<h3>" + jsonloungeCMS.NoResultsMessage + "<h3>");
                $('#loungeheader').html("<h3>" + jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description + "<h3>");
                $('html, body').animate({
                    scrollTop: $(".airport-details-lounges").offset().top - 100
                }, 1000)
            } else if (type == "SkyBasic") {
                //$("#depRecords").html("<h2>No results</h2>");
                $("#depRecords").html("<h2>"+jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description+"</h2>")
                $("#borderarrow-true").css("display", "none")
                $(".alert").css("display", "none")
                $("#skypriheader").text("No facilities are available")
            } else if (type == "SkyAdvance") {
                $("#depRecords").html("<h2>No results</h2>")
                $("#borderarrow-true").css("display", "none")
                $(".alert").css("display", "none")
                $("#skypriheader").text("No facilities are available")

            } else if (type == "flightreturn") {
                console.log(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                // $(".result-count").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                $(".result-count").html("<h1>" + jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description + "</h1>")
                //  $(".result-count .result-count-ret").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                $(".result-count .result-count-ret").html("<h1>" +jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description + "</h1>")
                $('.return-more-options').css('display', 'none');
                $('.more-options').css('display', 'none');
            } else if (type == "flightresults") {
                console.log(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                //$(".result-count").html("<h1>" + jsonobj.NoResultsMessage + "</h1>");
                $(".result-count").html("<h1>" + jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description + "</h1>")
                $('.more-options').css('display', 'none');
            }
                //29-Oct-2015 - RR - FFP Status Results Error
            else if (type == "ffp_status") {
                console.log(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                $("#ffp-img").css("display", "none");
                $(".ffp-results-error").html("Invalid tier level");
                $('.ffp-results').css("display", "none");
                $(".ffp-results-error").css("display", "block");
            }
            else if (type == 'AirlineAPI') {
                console.log(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                // $("#sp-error-api").show().html("Sorry, No SkyPriority services are available at selected airport");
                $("#sp-error-api").show().html(jQuery.parseJSON(xhr.responseText).Errors[0].Business_Error_Description);
                $('#sp-airline-button').hide();
            }
            else if (type == "travelinfo") {
                $("#skiplinkcomp-skypriorityform").before("<p class='airportdetails-errormsg'>No Results found.</p>");
            }
        }
    });
}
}
function SiteMapRgex(virtualLinkRe) {
    $("#Sitemap").find("li").each(function () {
        $(this).addClass($(this).find("A").attr("href").replace(virtualLinkRe, "").replace(/\//gi, "").toLowerCase());
    });
    $("#Sitemap").css("visibility", "visible");
}
var fromCount = 10;
var isWorking = 0;
function WebsiteSearch(pageLoad, fromC) {
    
    var searchPage = localStorage.getItem("searchPageKeyword");    
    if ($("#searchQuery").length > 0) {
        searchPage = $("#searchQuery").val();
    }
    //var searchapi = "http://160.123.1.23:8080/solr/skyweb/select?q=" + searchPage + "&fq=lang:en&wt=json&indent=true";
    var searchculture = "en";
    if ($("html").attr("lang") != null && $("html").attr("lang") != undefined) {
        searchculture = $("html").attr("lang");
    }
    var searchapi = "http://prod-websearch-elb-1744332091.eu-west-1.elb.amazonaws.com:8080/solr/skyweb/select?q=" + searchPage + "&fq=lang:" + searchculture + "&wt=json&indent=true";
    if (fromC != null && fromC != 'undefined') {
        searchapi = searchapi + "&start=" + fromC + "&rows=10";
    }
    $('#lastPostsLoader').css("display", "block");
    $.ajax({
        url: searchapi,
        jsonp: 'json.wrf',
        dataType: 'jsonp',
        success: function (data) {

            if (data != null && data != 'undefined') {
                loadSearchResults(data);
                $('#lastPostsLoader').css("display", "none");
                if (!pageLoad) {
                    isWorking = 0;
                    fromCount += 10;
                   // console.log(fromCount);
                    if (fromCount >= data.response.numFound) {
                        $("#search-more-results").addClass("hidden");
                    } 

                }
                else {                    
                    $("#search-count").text(data.response.numFound);
                    if (data.response.numFound > 10) {
                        $("#search-more-results").removeClass("hidden");
                        
                    }
                    
                }
                if (data.response.numFound == 0) {
                    $('#searchResults').hide();
                }
            }
        },
        error: function (xhr, textStatus, errorThrown) {
            
            if (!pageLoad) {
                isWorking = 0;
            }
            $('#lastPostsLoader').css("display", "none");
        },
        complete: function () {
            $('#lastPostsLoader').css("display", "none");
        },
	timeout: 3000
    });
}

function supports_storage() {
    try {
        return 'localStorage' in window && window['localStorage'] !== null;
    } catch (e) {
        return false;
    }
}

function autocompleteCPList(soureData) {
    var labels = [];

    if (soureData != null && soureData.Locations != null) {
        // alert(soureData + "after getting json data");
        $.each(soureData.Locations, function () {
            labels.push(this.Airport_Code + "####" + this.Airport_Name + "####" + this.City_Name + "####" + this.Country_Name);
        });
    }

    var selector = $(".autocompletedctrl");
    if (labels != null && labels.length > 0) {
        $.each(selector, function (i) {

            var $thisObj = $("#" + $(selector[i]).attr("id"));
            // alert($thisObj.length);
            //alert($thisObj.attr("id"));
            $($thisObj).autocomplete({
                minLength: 3,
                source: labels,
                select: function (event, ui) {
                    $($thisObj).val(ui.item.value.split("####")[1] + ' (' + ui.item.value.split("####")[0] + ')');

                    return false;
                },
                focus: function (event, ui) {
                    $($thisObj).val(ui.item.value.split("####")[1] + ' (' + ui.item.value.split("####")[0] + ')');
                    $("UL.ui-autocomplete.ui-widget-content").css("overflow-x", "hidden");
                    return false;
                },
                open: function (event, ui) {
                    var firstDisplayHeight = 0;
                    $("#ui-id-1 > li:lt(5)").addClass("firstDisplay");
                    $('.firstDisplay').each(function () {
                        firstDisplayHeight = firstDisplayHeight + (Math.round($(this).height()) + 20);
                    });
                    finalDisplayHeight = firstDisplayHeight;
                    $('ul#ui-id-1').css('height', finalDisplayHeight);
                    $('ul#ui-id-1').css('overflow-y', 'auto');

                    $("#ui-id-2 > li:lt(5)").addClass("firstDisplay");
                    $('.firstDisplay').each(function () {
                        firstDisplayHeight = firstDisplayHeight + (Math.round($(this).height()) + 20);
                    });
                    finalDisplayHeight = firstDisplayHeight;
                    $('ul#ui-id-2').css('height', finalDisplayHeight);
                    $('ul#ui-id-2').css('overflow-y', 'auto');
                }
            }).data("ui-autocomplete")._renderItem = function (ul, item) {
                return $("<li></li>")
                    .data("item.autocomplete", item)
                    .append('<a><label class="airport_name">' + item.value.split("####")[2] + ' - ' + item.value.split("####")[1] + ' </label><span class="auto_airport_code">' + item.value.split("####")[0] + '</span><span class="auto_country">' + item.value.split("####")[3] + '</span></a>')
                    .appendTo(ul);
            };

        });

    }
}

function smreturnlogo(operatorcode) {
    //alert(operatorcode);
    var returnvalue;
    if (operatorcode == 'AM') {
        returnvalue = "aeromexico";
    } else if (operatorcode == 'KQ') {
        returnvalue = "kenyaairways";
    } else if (operatorcode == 'AZ') {
        returnvalue = "alitalia";
    } else if (operatorcode == 'CZ') {
        returnvalue = "chinasouthern";
    } else if (operatorcode == 'KE') {
        returnvalue = "koreanair";
    } else if (operatorcode == 'ME') {
        returnvalue = "mea";
    } else if (operatorcode == 'KL') {
        returnvalue = "klm";
    } else if (operatorcode == 'MU') {
        returnvalue = "chinaeastern";
    } else if (operatorcode == 'OK') {
        returnvalue = "czechairlines";
    } else if (operatorcode == 'RO') {
        returnvalue = "tarom";
    } else if (operatorcode == 'UX') {
        returnvalue = "aireuropa";
    } else if (operatorcode == 'DL') {
        returnvalue = "delta";
    } else if (operatorcode == 'VN') {
        returnvalue = "vietnamairlines";
    } else if (operatorcode == 'AF') {
        returnvalue = "airfrance";
    } else if (operatorcode == 'SU') {
        returnvalue = "aeroflot";
    } else if (operatorcode == 'SV') {
        returnvalue = "saudia";
    }
    else if (operatorcode == 'MF') {
        returnvalue = "xiamenair";
    }
    else if (operatorcode == 'GA') {
        returnvalue = "garudaindonesia";
    }
    else if (operatorcode == 'AR') {
        returnvalue = "aerolineasargentinas";
    }
    else if (operatorcode == 'CI') {
        returnvalue = "chinaairlines";
    }

    return returnvalue;
}


/** Responsive mobile view menu slider **/
(function ($) {

    $.fn.jPushMenu = function (customOptions) {
        var o = $.extend({}, $.fn.jPushMenu.defaultOptions, customOptions);

        /* add class to the body.*/

        $('body').addClass(o.bodyClass);
        $(this).addClass('jPushMenuBtn');
        $(this).click(function () {
            var target = '',
			push_direction = '';


            if ($(this).is('.' + o.showLeftClass)) {
                target = '.cbp-spmenu-left';
                push_direction = 'toright';
            }
            else if ($(this).is('.' + o.showRightClass)) {
                target = '.cbp-spmenu-right';
                push_direction = 'toleft';
            }
            else if ($(this).is('.' + o.showTopClass)) {
                target = '.cbp-spmenu-top';
            }
            else if ($(this).is('.' + o.showBottomClass)) {
                target = '.cbp-spmenu-bottom';
            }


            $(this).toggleClass(o.activeClass);
            $(target).toggleClass(o.menuOpenClass);

            if ($(this).is('.' + o.pushBodyClass)) {
                $('body').toggleClass('cbp-spmenu-push-' + push_direction);
            }

            $('.jPushMenuBtn').not($(this)).toggleClass('disabled');

            return false;
        });
        var jPushMenu = {
            close: function (o) {
                $('.jPushMenuBtn,body,.cbp-spmenu').removeClass('disabled active cbp-spmenu-open cbp-spmenu-push-toleft cbp-spmenu-push-toright');
            }
        }

        if (o.closeOnClickOutside) {
            $(document).click(function () {
                jPushMenu.close();
            });

            $(document).on('click touchstart', function () {
                jPushMenu.close();
            });

            $('.cbp-spmenu,.toggle-menu').click(function (e) {
                e.stopPropagation();
            });

            $('.cbp-spmenu,.toggle-menu').on('click touchstart', function (e) {
                e.stopPropagation();
            });
        }

        if (o.closeOnClickLink) {
            $('.cbp-spmenu a').on('click', function () {
                jPushMenu.close();
            });
        }
    };

    /**
	*  In case you want to customize class name,
    *  do not directly edit here, use function parameter when call jPushMenu.
    **/

    $.fn.jPushMenu.defaultOptions = {
        bodyClass: 'cbp-spmenu-push',
        activeClass: 'menu-active',
        showLeftClass: 'menu-left',
        showRightClass: 'menu-right',
        showTopClass: 'menu-top',
        showBottomClass: 'menu-bottom',
        menuOpenClass: 'cbp-spmenu-open',
        pushBodyClass: 'push-body',
        closeOnClickOutside: true,
        closeOnClickInside: true,
        closeOnClickLink: true
    };


    
 

})(jQuery);
(function ($) {

    $.fn.floatLabels = function (options) {

        // Settings
        var self = this;
        var settings = $.extend({}, options);

        // Event Handlers
        function registerEventHandlers() {
            self.on('input keyup change', 'input, textarea', function () {
                actions.swapLabels(this);
            });
        }

        // Actions
        var actions = {
            initialize: function () {
                self.each(function () {
                    var $this = $(this);
                    var $label = $this.children('label');
                    var $field = $this.find('input,textarea').first();

                    if ($this.children().first().is('label')) {
                        $this.children().first().remove();
                        $this.append($label);
                    }

                    var placeholderText = ($field.attr('placeholder') && $field.attr('placeholder') != $label.text()) ? $field.attr('placeholder') : $label.text();

                    $label.data('placeholder-text', placeholderText);
                    $label.data('original-text', $label.text());

                    if ($field.val() == '') {
                        $field.addClass('empty')
                    }
                    else {
                        $field.removeClass('empty')
                    }
                });
            },
            swapLabels: function (field) {

                var $field = $(field);
                var $label = $(field).siblings('label').first();
                var isEmpty = Boolean($field.val());

                if (isEmpty) {
                    $field.removeClass('empty');
                    $label.text($label.data('original-text'));
                } else {
                    $field.addClass('empty');
                    $label.text($label.data('placeholder-text'));
                }
            }
        }

        // Initialization
        function init() {
            registerEventHandlers();

            actions.initialize();
            self.each(function () {
                actions.swapLabels($(this).find('input,textarea').first());
            });
        }
        init();

        return this;
    };

    $(function () {
        $('.float-label-control').floatLabels();
    });

    $.extend({
        distinct: function (anArray) {           
            var uniqueMsg = [];
            var uniqueResults = [];
            $.each(anArray, function (i, v) {
                if ($.inArray(v.message, uniqueMsg) == -1) {
                    uniqueMsg.push(v.message);                   
                }
            });
            return uniqueMsg;
        }
    });




    $(function () {

        /*Contact Us Form Validation*/
        $("#contact-us-form").validate({
            onkeyup: false,
            onfocusout: false,
            errorLabelContainer: '#dialogpopup',
            wrapper: 'p',
            rules: {
                ContactName: {
                    required: true
                },
                ContactEmail: {
                    required: true,
                    email:true
                },
                EmailSubject: {
                    required: true
                },
                EmailMessage: {
                    required: true
                }
            },
            success: function () {
                $("#dialogpopup").hide();
            },
            messages: {
                ContactEmail: {
                    email: (error_messages != null ? error_messages.FORMERR_1 : "Sorry, something is missing. Please provide all information and try again.")
                }
            },
            showErrors: function (errorMap, errorList) {
                // alert(errorList.length);
                //debugger;
                if (errorList.length > 0) {
                    $('#contact-us-form').find('.error').removeClass("error");
                    $.each(errorList, function (i, v) {
                        $("#" + v.element.id).addClass("error");
                    });
                    $("#dialogpopup").find("p").remove().hide();
                    var finalErrorMsg = $.distinct(errorList);
                    //alert(finalErrorMsg.length);
                    for (var i = 0; i < finalErrorMsg.length; i++) {
                        $("#dialogpopup").append("<p>" + finalErrorMsg[i] + "</p>").show();
                    }
                } else {
                    $('#contact-us-form').find('.error').removeClass("error");
                    $("#dialogpopup").hide();
                }

            }
        });

        /*SkyPriority Form Validation*/
        $("#formskypriority").validate({            
            ignore: "",
            onkeyup: false,
            onfocusout: false,
            //onkeyup: function (element) { $(element).valid() },
            //onfocusout: function (element) { $(element).valid() },
            errorLabelContainer: '#dialogpopup',
            wrapper: 'p',
            rules: {
                fromautocomplete: {                  
                    required: true,
                    minlength: 3
                },
                toautocomplete: {                    
                    minlength: 3
                },
                "sp-airline": {
                    required: true
                }
            },
            messages: {
                "sp-airline": {
                    required: (error_messages != null ? error_messages.FORMERR_3 : "Please select an airline from the dropdown list and try again.")
                }
            },
            success: function () {
                $("#dialogpopup").hide();
            },
            showErrors: function (errorMap, errorList) {
                    // alert(errorList.length);
                    //debugger;
                    if (errorList.length > 0) {
                        $('#formskypriority').find('.error').removeClass("error");
                        $.each(errorList, function (i, v) {
                            $("#" + v.element.id).addClass("error");
                            if (v.element.id == "sp-airline") {
                                $("#sp-airline-button").addClass("error");
                            }
                        });
                        $("#dialogpopup").find("p").remove().hide();
                        var finalErrorMsg = $.distinct(errorList);
                        //alert(finalErrorMsg.length);
                        for (var i = 0; i < finalErrorMsg.length; i++) {
                            $("#dialogpopup").append("<p>" + finalErrorMsg[i] + "</p>").show();
                        }
                    } else {
                        $('#formskypriority').find('.error').removeClass("error");
                        $("#dialogpopup").hide();
                    }

                }
        });


        /*Cargo Form Validation*/
        $("#form-cargo").validate({
            onkeyup: false,
            onfocusout: false,
            //onkeyup: function (element) { $(element).valid() },
            //onfocusout: function (element) { $(element).valid() },
            errorLabelContainer: '#dialogpopup',
            wrapper: 'p',
            rules: {
                cargoInputOne: {
                    required: true                    
                },
                cargoInputTwo: {
                    required: true,
                    minlength: 8
                }
            },
            success: function () {
                $("#dialogpopup").hide();
            },
            showErrors: function (errorMap, errorList) {
                // alert(errorList.length);
                //debugger;
                if (errorList.length > 0) {
                    $('#form-cargo').find('.error').removeClass("error");
                    $.each(errorList, function (i, v) {
                        $("#" + v.element.id).addClass("error");
                    });
                    $("#dialogpopup").find("p").remove().hide();
                    var finalErrorMsg = $.distinct(errorList);
                    //alert(finalErrorMsg.length);
                    for (var i = 0; i < finalErrorMsg.length; i++) {
                        $("#dialogpopup").append("<p>" + finalErrorMsg[i] + "</p>").show();
                    }
                } else {
                    $('#form-cargo').find('.error').removeClass("error");
                    $("#dialogpopup").hide();
                }

            }
        });

        /*Airport Form Validation*/
        $("#form-airport").validate({
            onkeyup: false,
            onfocusout:false,
            //onkeyup: function (element) { $(element).valid() },
            //onfocusout: function (element) { $(element).valid() },
            errorLabelContainer: '#dialogpopup',
            wrapper: 'p',
            rules: {
                txtairportcode: {
                    required: true,
                    minlength: 3
                }
            },
            success: function () {
                $("#dialogpopup").hide();
            },
            showErrors: function (errorMap, errorList) {
                // alert(errorList.length);
                //debugger;
                if (errorList.length > 0) {
                    $('#form-airport').find('.error').removeClass("error");
                    $.each(errorList, function (i, v) {
                        $("#" + v.element.id).addClass("error");                        
                    });
                    $("#dialogpopup").find("p").remove().hide();
                    var finalErrorMsg = $.distinct(errorList);
                    //alert(finalErrorMsg.length);
                    for (var i = 0; i < finalErrorMsg.length; i++) {
                        $("#dialogpopup").append("<p>" + finalErrorMsg[i] + "</p>").show();
                    }
                } else {
                    $('#form-airport').find('.error').removeClass("error");
                    $("#dialogpopup").hide();
                }

            }
        });

        /*Flight Status Form Validation*/
        $("#flight-status-search-form").validate({
            onkeyup: false,
            onfocusout: false,
           // onkeyup: function (element) { $(element).valid() },
           // onfocusout: function (element) { $(element).valid() },
            errorLabelContainer: '#dialogpopup',
            wrapper: 'p',
            rules: {
                fromautocomplete: {
                    required: true,
                    minlength: 3
                },
                toautocomplete: {
                    required: true,
                    minlength: 3
                },
                airlinedropdown: {
                    required: true
                }
            },
            messages: {
                airlinedropdown: {
                    required: (error_messages != null ? error_messages.FORMERR_3 : "Please select an airline from the dropdown list and try again.")
                }
            },
            success: function () {
                $("#dialogpopup").hide();
            },
            showErrors: function (errorMap, errorList) {
                // alert(errorList.length);
               // debugger;
                if (errorList.length > 0) {
                    $('#flight-status-search-form').find('.error').removeClass("error");
                    $.each(errorList, function (i, v) {
                        $("#" + v.element.id).addClass("error");
                        if (v.element.id == "airline-dropdown") {
                            $("#airline-dropdown-button").addClass("error");
                        }
                    });
                    $("#dialogpopup").find("p").remove().hide();
                    var finalErrorMsg = $.distinct(errorList);
                    //alert(finalErrorMsg.length);
                    for (var i = 0; i < finalErrorMsg.length; i++) {
                        $("#dialogpopup").append("<p>" + finalErrorMsg[i] + "</p>").show();
                    }
                } else {
                    $('#flight-status-search-form').find('.error').removeClass("error");
                    $("#dialogpopup").hide();
                }

            }
        });

        /*Lounge  Form Validation*/
        $("#lounge-search-form").validate({
            //groups: {
            //    groupmsg: "fromautocomplete toautocomplete retdate depdate"
            //},
            onkeyup: false,
            onfocusout: false,
           // onkeyup: function (element) { $(element).valid() },
           // onfocusout: function (element) { $(element).valid() },
            errorLabelContainer: '#dialogpopup',
            wrapper: 'p',
            rules: {
                fromautocomplete: {
                    required: true,
                    minlength: 3
                }                
            },
            success: function () {
                $("#dialogpopup").hide();
            },
            showErrors: function (errorMap, errorList) {
                // alert(errorList.length);
               // debugger;
                if (errorList.length > 0) {
                    $('#lounge-search-form').find('.error').removeClass("error");
                    $.each(errorList, function (i, v) {
                        $("#" + v.element.id).addClass("error");
                    });
                    $("#dialogpopup").find("p").remove().hide();
                    var finalErrorMsg = $.distinct(errorList);
                    //alert(finalErrorMsg.length);
                    for (var i = 0; i < finalErrorMsg.length; i++) {
                        $("#dialogpopup").append("<p>" + finalErrorMsg[i] + "</p>").show();
                    }
                } else {
                    $('#lounge-search-form').find('.error').removeClass("error");
                    $("#dialogpopup").hide();
                }

            }
        });
       
        /*Flight Finder Form Validation*/
       $("#search-form").validate({
            //groups: {
            //    groupmsg: "fromautocomplete toautocomplete retdate depdate"
           //},
           onkeyup: false,
           onfocusout: false,

           //onkeyup: function (element) { $(element).valid() },
          // onfocusout: function (element) { $(element).valid() },
            errorLabelContainer: '#dialogpopup',
            wrapper: 'p',            
            rules: {
                fromautocomplete: {
                    required: true,
                    minlength: 3
                },
                toautocomplete: {
                    required: true,
                    minlength: 3
                },
                retdate: {
                    required: true,
                    minlength: 10
                   
                },
                depdate: {
                    required: true,
                    minlength: 10
                }
            },            
            success: function () {
                $("#dialogpopup").hide();
            },
            showErrors: function (errorMap, errorList) {
                // alert(errorList.length);
                //debugger;
                if (errorList.length > 0) {
                    $('#search-form').find('.error').removeClass("error");
                    $.each(errorList, function (i, v) {
                        $("#" + v.element.id).addClass("error");
                    });
                    $("#dialogpopup").find("p").remove().hide();
                    var finalErrorMsg = $.distinct(errorList);
                    //alert(finalErrorMsg.length);
                    for (var i = 0; i < finalErrorMsg.length; i++) {
                        $("#dialogpopup").append("<p>" + finalErrorMsg[i] + "</p>").show();
                    }
                } else {
                    $('#search-form').find('.error').removeClass("error");
                    $("#dialogpopup").hide();
                }
                   
            }            
        });

        if ($("#flightfinder-oneway").is(":checked") && $("#flightfinder-oneway").val() == "oneway") {
            $(".col-sm-6.twoway-con").addClass("twoway-con-class");
            $(".col-sm-6.oneway-con").addClass("oneway-con-class");
        } else {
            $(".col-sm-6.twoway-con").removeClass("twoway-con-class");
            $(".col-sm-6.oneway-con").removeClass("oneway-con-class");
        }

        $(".flight-options").click(function (ev) {

            //change

            $thisObj = $(this);
            if ($thisObj.is(":checked") && $thisObj.val() == "oneway") {
                //  $("#retdate").attr("disabled", "disabled");
                $(".col-sm-6.twoway-con").addClass("twoway-con-class");
                $(".col-sm-6.oneway-con").addClass("oneway-con-class");
            }
            else {

                $(".col-sm-6.twoway-con").removeClass("twoway-con-class");
                $(".col-sm-6.oneway-con").removeClass("oneway-con-class");
                //  $("#retdate").removeAttr("disabled");
            }

        });

        $("#btn-search-flights").on("click", function (ev) {          
            ev.preventDefault();
            if ($('#search-form').valid()) {
                $("#dialogpopup").hide();
                /* Add this script to save airports in session 03-Nov-2015�Justin*/
                sessionStorage.setItem("fromautocomplete", $("#fromautocomplete").val());
                sessionStorage.setItem("toautocomplete", $("#toautocomplete").val());
                sessionStorage.setItem("depdate", $("#depdate").val());
                sessionStorage.setItem("retdate", $("#retdate").val());

                localStorage.removeItem("FromAirportCode");
                localStorage.removeItem("ToAirportCode");
                localStorage.removeItem("FromAirportName");
                localStorage.removeItem("ToAirportName");
                localStorage.removeItem("FromDate");
                localStorage.removeItem("ToDate");
                localStorage.removeItem("headerFromCity");
                localStorage.removeItem("headerToCity");
                //  debugger;
                $thisObj = $(this);
                var oneway = false;
                if ($("#flightfinder-oneway").is(":checked")) {
                    oneway = true;
                }
                var depDate = $("#depdate").val();

                var retDate = "";
                if (!oneway) {
                    retDate = $("#retdate").val();
                }
                var airportCodeDep = $("#fromautocomplete").val().split("(")[1].replace(")", "");
                var airportCodeArr = $("#toautocomplete").val().split("(")[1].replace(")", "");
                var CityNameDep = $("#fromautocomplete").val().split("(")[0];
                var CityNameArr = $("#toautocomplete").val().split("(")[0];

                var CityName1 = $("#fromautocomplete").val().split("-")[0];
                var CityName2 = $("#toautocomplete").val().split("-")[0];


                localStorage.setItem("FromAirportCode", airportCodeDep);
                localStorage.setItem("ToAirportCode", airportCodeArr);
                localStorage.setItem("FromAirportName", CityNameDep);
                localStorage.setItem("ToAirportName", CityNameArr);
                localStorage.setItem("FromDate", depDate);
                localStorage.setItem("ToDate", retDate);

                localStorage.setItem("headerFromCity", CityName1);
                localStorage.setItem("headerToCity", CityName2);

                window.location.href = $("#btn-search-flights").parents("#search-form").attr("action");

            }
 
           
        });

        //$("#btn-search-flights").click(function (ev) {
        //    if (validateData('search-form') == true) {
                
        //        return false;
        //    } else {
        //        return false;
        //    }
        //});

        /** Find flights departure and return date selection  **/

        // Add jQuery Aftershow event // 
        $.datepicker._updateDatepicker_original = $.datepicker._updateDatepicker;
        $.datepicker._updateDatepicker = function (inst) {
            $.datepicker._updateDatepicker_original(inst);
            var afterShow = this._get(inst, 'afterShow');
            if (afterShow)
                afterShow.apply((inst.input ? inst.input[0] : null));
        }

        var windowWidth = $(window).width();
        $('.datepicker-title').css("display", "none");
        var displayMonths = 2;


        // Check window width for overlay display
        if (windowWidth <= 767) {
            displayMonths = 12;
        }
        var year = (new Date).getFullYear();
        
        $("#depdate").datepicker({
            numberOfMonths: displayMonths,
            minDate: '0',
            //minDate: new Date(year, 0, 1),
            maxDate: new Date(year + 1, 11, 31),
	   beforeShow:function()
            {
                $('#depdate').datepicker('setDate', null);
            },
            afterShow: function () {
                if (windowWidth <= 767) {
                    $('#ui-datepicker-div').prepend('<div class="datepicker-title"><span class="icon-departuredate cal-title"></span>Departure date<span class="icon-closecircle" onclick="$(' + "'#depdate'" + ').datepicker(' + "'hide'" + ');"></span></div>');
                    $('.datepicker-title').css("display", "block");
                    $('.datepicker-title').css("display", "block");
                    $('#ui-datepicker-div .ui-datepicker-prev').css("display", "none");
                    $('#ui-datepicker-div .ui-datepicker-next').css("display", "none");
                    $('body').css('overflow', 'visible');
                }
            },
            onSelect: function () {
                localStorage.setItem("depDate", $(this).datepicker('getDate'));

                $('#retdate').datepicker('option', {
                    minDate: $(this).datepicker('getDate')
                });
                $(this).removeClass('empty');
                $("form").validate().element(this);                
            }

        });

        $("#retdate").datepicker({
            numberOfMonths: displayMonths,
            minDate: '0',
            //minDate: new Date(year, 0, 1),
            maxDate: new Date(year + 1, 11, 31),
            afterShow: function () {
                if (windowWidth <= 767) {
                    //To fix return-date icon issue - 20-Oct-2015 - AB
                    //$('#ui-datepicker-div').prepend('<div class="datepicker-title"><span class="icon-departuredate cal-title"></span>Return date<span class="icon-closecircle" onclick="$(' + "'#retdate'" + ').datepicker(' + "'hide'" + ');"></span></div>');
                    $('#ui-datepicker-div').prepend('<div class="datepicker-title"><span class="icon-returndate cal-title"></span>Return date<span class="icon-closecircle" onclick="$(' + "'#retdate'" + ').datepicker(' + "'hide'" + ');"></span></div>');
                    $('.datepicker-title').css("display", "block");

                    $('#ui-datepicker-div .ui-datepicker-prev').css("display", "none");
                    $('#ui-datepicker-div .ui-datepicker-next').css("display", "none");
                }
            },
            onSelect: function () {
                $("form").validate().element(this);
            }
        });

        /** Search results page filter slider for return arrival and departure **/
        //change



        sliderloading();
        if ($("#flightfinder-oneway").is(":checked")) {
            $('#retdate').datepicker('option', {
                minDate: 0
            });
        } else {
            if (localStorage.getItem("depDate") != '') {
                $('#retdate').datepicker('option', {
                    minDate: new Date(localStorage.getItem("depDate"))
                });
            }
        }


    });


    /** Slider menu Initializing **/

    $('.toggle-menu').jPushMenu({ closeOnClickLink: false });
    $('.dropdown-toggle').dropdown();

    $('.icon-closecircle').click(function () {
        $('.cbp-spmenu').removeClass('cbp-spmenu-open');
    });


    /** Validation start **/

    var validateData = function (formId) {
        var validateFields = [];
        var formData = true;
        var formLogic = false;
        var formValid = false;
        $('form#' + formId + ' :input').each(function (index, elm) {
            if (elm.type == 'text') {

                if ($("#flightfinder-oneway").is(":checked")) {
                    if (elm.id != 'retdate') {
                        validateFields.push(elm.id)
                    }
                } else {

                    validateFields.push(elm.id)

                }


            }
        });

        $.each(validateFields, function (key, field) {

            if ($('#' + field).val() == '') {

                $('#' + field).removeClass('input-success');
                $('#' + field).addClass('input-error');
                formData = false;
            } else {
                $('#' + field).removeClass('input-error');
                $('#' + field).addClass('input-success');
            }
        });

        var origin = $('#fromautocomplete').val();
        var destination = $('#toautocomplete').val()
        if ((origin == destination) && (origin != '') && (destination != '')) {
            $('.commonErrors').html('Origin and desitination should be different.');
            $('.commonErrors').css('display', 'block');
            formLogic = false;
        } else {
            $('.commonErrors').html('');
            $('.commonErrors').css('display', 'none');
            formLogic = true;
        }
        if (formData == true && formLogic == true) {
            return true;
        } else {
            return false;
        }
    };

    /** Validation End **/


    /** Filter overlay **/

    $('.filterbtn').click(function () {
        $('.filter-con').addClass('filter-con-open');
    });

    $('.close-filter').click(function () {
        $('.filter-con').removeClass('filter-con-open');
    });



})(jQuery);

//31-Oct-2015 - JRS - slider time issue
function sliderloading() {

    if (localStorage.getItem("ToDate") != '') {

        if ($("#sliderReturn").length > 0) {

            $("#sliderReturn").slider({
                range: true,
                min: 0,
                max: 24,
                step: 1,
                values: [0, 24],
                slide: function (event, ui) {
                    $('#sliderReturn .ui-slider-handle:first').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[0] + ":00" + '</div>');
                    $('#sliderReturn .ui-slider-handle:last').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[1] + ":00" + '</div>');
                },
                change: function (event, ui) {
                    var delay = function () {
                        var handleIndex = $(ui.handle).data('index.uiSliderHandle');
                        var label = handleIndex == 0 ? '#min' : '#max';
                        $('#sliderReturn .ui-slider-handle:first').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[0] + ":00" + '</div>');
                        $('#sliderReturn .ui-slider-handle:last').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[1] + ":00" + '</div>');

                    };
                    retappendedResults = 0;
                    $('#returnresults').empty();

                    dynresults(RetArrArray, 'returnresults', '#sliderReturn', '#sliderReturn1');

                    filterResults('#returnresults');
                    setTimeout(delay, 10);
                }
            });

        }


        if ($("#sliderReturn1").length > 0) {

            $("#sliderReturn1").slider({
                range: true,
                min: 0,
                max: 24,
                step: 1,
                values: [0, 24],
                slide: function (event, ui) {
                    $('#sliderReturn1 .ui-slider-handle:first').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[0] + ":00" + '</div>');
                    $('#sliderReturn1 .ui-slider-handle:last').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[1] + ":00" + '</div>');
                },
                change: function (event, ui) {
                    var delay = function () {
                        var handleIndex = $(ui.handle).data('index.uiSliderHandle1');
                        var label = handleIndex == 0 ? '#min1' : '#max1';
                        $('#sliderReturn1 .ui-slider-handle:first').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[0] + ":00" + '</div>');
                        $('#sliderReturn1 .ui-slider-handle:last').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[1] + ":00" + '</div>');
                    };
                    retappendedResults = 0;
                    $('#returnresults').empty();

                    dynresults(RetArrArray, 'returnresults', '#sliderReturn', '#sliderReturn1');

                    filterResults('#returnresults');
                    setTimeout(delay, 10);
                }
            });
        }
    }
    //change
    $('#sliderReturn .ui-slider-handle:first').html('<div class="tooltip bottom slider-tip"></div><div class="tooltip-inner">0:00</div></div>');
    $('#sliderReturn .ui-slider-handle:last').html('<div class="tooltip bottom slider-tip"></div><div class="tooltip-inner">24:00</div></div>');

    $('#sliderReturn1 .ui-slider-handle:first').html('<div class="tooltip bottom slider-tip"></div><div class="tooltip-inner">0:00</div></div>');
    $('#sliderReturn1 .ui-slider-handle:last').html('<div class="tooltip bottom slider-tip"></div><div class="tooltip-inner">24:00</div></div>');





    /** Search Results page Filter slider for Arrival and departure **/
    //change
    if ($("#slider").length > 0) {

        $("#slider").slider({
            range: true,
            min: 0,
            max: 24,
            step: 1,
            values: [0, 24],
            slide: function (event, ui) {
                $('#slider .ui-slider-handle:first').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[0] + ":00" + '</div>');
                $('#slider .ui-slider-handle:last').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[1] + ":00" + '</div>');
            },
            change: function (event, ui) {
                var delay = function () {
                    var handleIndex = $(ui.handle).data('index.uiSliderHandle');
                    var label = handleIndex == 0 ? '#min' : '#max';
                    $('#slider .ui-slider-handle:first').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[0] + ":00" + '</div>');
                    $('#slider .ui-slider-handle:last').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[1] + ":00" + '</div>');

                };

                appendedResults = 0;
                $('#showresults').empty();
                dynresults(DepArrArray, 'showresults', '#slider', '#slider1');

                filterResults("#showresults");
                setTimeout(delay, 10);

            }
        });

    }
    if ($("#slider1").length > 0) {
        $("#slider1").slider({
            range: true,
            min: 0,
            max: 24,
            step: 1,
            values: [0, 24],
            slide: function (event, ui) {
                $('#slider1 .ui-slider-handle:first').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[0] + ":00" + '</div>');
                $('#slider1 .ui-slider-handle:last').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[1] + ":00" + '</div>');
            },
            change: function (event, ui) {
                var delay = function () {
                    var handleIndex = $(ui.handle).data('index.uiSliderHandle1');
                    var label = handleIndex == 0 ? '#min1' : '#max1';
                    $('#slider1 .ui-slider-handle:first').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[0] + ":00" + '</div>');
                    $('#slider1 .ui-slider-handle:last').html('<div class="tooltip slider-tip"></div><div class="tooltip-inner">' + ui.values[1] + ":00" + '</div>');
                };
                appendedResults = 0;
                $('#showresults').empty();
                dynresults(DepArrArray, 'showresults', '#slider', '#slider1');

                filterResults("#showresults");
                setTimeout(delay, 10);
            }
        });
    }


    $('#slider1 .ui-slider-handle:first').html('<div class="tooltip bottom slider-tip"></div><div class="tooltip-inner">0:00</div></div>');
    $('#slider1 .ui-slider-handle:last').html('<div class="tooltip bottom slider-tip"></div><div class="tooltip-inner">24:00</div></div>');

    $('#slider .ui-slider-handle:first').html('<div class="tooltip bottom slider-tip"></div><div class="tooltip-inner">0:00</div></div>');
    $('#slider .ui-slider-handle:last').html('<div class="tooltip bottom slider-tip"></div><div class="tooltip-inner">24:00</div></div>');
}



var airlineListObject = {
    "AM": "aeromexico",
    "KQ": "kenyaairways",
    "AZ": "alitalia",
    "CZ": "chinasouthern",
    "KE": "koreanair",
    "ME": "mea",
    "KL": "klm",
    "MU": "chinaeastern",
    "OK": "czechairlines",
    "RO": "tarom",
    "UX": "aireuropa",
    "DL": "delta",
    "VN": "vietnamairlines",
    "AF": "airfrance",
    "SU": "aeroflot",
    "SV": "saudia",
    "MF": "xiamenair",
    "GA": "garudaindonesia",
    "AR": "aerolineasargentinas",
    "CI": "chinaairlines"
};
function returnlogo(operatorcode) {
    var returnvalue;
    returnvalue = '<img src="' + MemberAirlineBaseURL + airlineListObject[operatorcode] + '.png">';
    return returnvalue;
}
//scrollup autocomplete - JRS - 29-Oct-2015
function onCtrlFocus() {
    //$('html, body').animate({
    //    scrollTop: $('#spanscroll').offset().top
    //}, 1000);
}

function airportLanding() {
    if ($("#form-airport").valid()) {
        $("#dialogpopup").hide();
        var airportCode = $("#textbox-airport").val().split("(")[1].replace(")", "");
        localStorage.removeItem("land-airportname");
        localStorage.removeItem("airportHeading");
        localStorage.setItem("land-airportname", $("#textbox-airport").val());
        localStorage.setItem("airportHeading", $("#textbox-airport").val());
        //console.log(localStorage.getItem("land-airportname"));
        //console.log(localStorage.getItem("airportHeading"));
        // var CityNameDep = $("#textbox-airport").val().split("(")[0];

        //var CityName1 = $("#textbox-airport").val().split("-")[0];    

        var actionlink = $("#textbox-airport").parents("form").attr("action");
        var redirectlink = $(location).attr('href');
        if (airportCode == "AMS") {
            console.log(window.location.href);
            window.location.href = redirectlink+'amsterdam-airport-schiphol/';
        } else if (airportCode == "CDG") {
            console.log(window.location.href);
            window.location.href =  redirectlink+'paris-charles-de-gaulle-airport/';
        } else if (airportCode == "ATL") {
            console.log(window.location.href);
            window.location.href =  redirectlink+'Hartsfield-Jackson-Atlanta-International-Airport/';
        } else if (airportCode == "ICN") {
            console.log(window.location.href);
            window.location.href =  redirectlink+'seoul/';
        } else if (airportCode == "PEK") {
            console.log(window.location.href);
            window.location.href =  redirectlink+'beijing/';
         }
        else {
            window.location.href = actionlink + "/" + airportCode;
        }
    }
}



function createSkipLinks() {

    var skiplinkHTML = [];
    $("section[id ^= 'skiplinkcomp-'], div[id ^= 'skiplinkcomp-']").each(function (i) {

        if ($(this).find("H1").length > 0) {
            skiplinkHTML.push($(this).attr("id") + "#SKIPTEXT#" + $(this).find("H1").first().text());
        }
        else if ($(this).find("H2").length > 0) {
            skiplinkHTML.push($(this).attr("id") + "#SKIPTEXT#" + $(this).find("H2").first().text());
        }
        else if ($(this).find("H3").length > 0) {
            skiplinkHTML.push($(this).attr("id") + "#SKIPTEXT#" + $(this).find("H3").first().text());
        }

    });

    if (skiplinkHTML != null && skiplinkHTML.length > 0) {
        var skipHTML = '';
        $(skiplinkHTML).each(function (i) {
            skipHTML = skipHTML + '<li><a href="#' + skiplinkHTML[i].split("#SKIPTEXT#")[0] + '">' + skiplinkHTML[i].split("#SKIPTEXT#")[1] + '<span class="icon-arrowdown"></span></a></li>';
        });
        if (skipHTML != '') {
            $("#skiplinkscontainer").find("UL").html(skipHTML);
            $(".skiplinkscontent").html($("#skiplinkscontainer").html());
            $("#skiplinkscontainer").remove();
        }
    }
    $(window).bind('scroll', function () {
        var navHeight = 600;
        ($(window).scrollTop() > navHeight) ? $('.skiplinkscontent').addClass('goToTop') : $('.skiplinkscontent').removeClass('goToTop');
    });

    var clickCount = 0;    
    $(".skiplinkscontent").find("A").click(function (ev) {
        var offsetScroll = 160;
        if (clickCount == 0) {
            offsetScroll = 300;
        }
      //  console.log("element offset top:" + $($(this).attr("href")).offset().top);
     //   console.log("skiplinkscontent  offset top:" + $(".skiplinkscontent").offset().top);
        // alert(clickCount);
        $(".skiplinkscontent").hide();
        ev.preventDefault();
        $('html, body').animate({
            scrollTop: $($(this).attr("href")).offset().top - ($(".skiplinkscontent").height() + 85)
        }, 1200, function () { $(".skiplinkscontent").show(); });
        clickCount = clickCount + 1;
    });


    
}

function compareStrings(a, b) {
    // Assuming you want case-insensitive comparison
    a = a.toLowerCase();
    b = b.toLowerCase();

    return (a < b) ? -1 : (a > b) ? 1 : 0;
}
function loungeAccessData(loungesAccessData) {      
    var jsonloungeCMSAccess = '';
    if (typeof LoungeFinderContentJSON != 'undefined') {
        jsonloungeCMSAccess = $.parseJSON(LoungeFinderContentJSON);
    }
    var loungeacessjson = loungesAccessData;
    var lounge_Airport_Code = loungeacessjson.Airport.Airport_Code;
    var lounge_Airport_Name = loungeacessjson.Airport.Airport_Name;
    var lounge_Airport_Lounges_Records = loungeacessjson.Airport.Airport_Lounges_Records;
    var Lounges = loungeacessjson.Airport.Lounges;
    var loungeacesshtml = '';
    //var airportQuickCard = '';
    
    for (var i = 0; i < Lounges.length; i++) {
        for (var k = 0; k < loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible.length; k++) {
            //loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible.sort(function (a, b) {
              //  return compareStrings(a.Name, b.Name);
            //});
           
            if (loungeacessjson.Airport.Lounges[i].Lounge_Ownership != null && loungeacessjson.Airport.Lounges[i].Lounge_Ownership.toLowerCase() == "skyteam lounges") {
                if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'SU') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'aeroflot.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'AR') {
                    loungeacesshtml = loungeacesshtml + '<li class="list-group-item"<img src="' + airlinelogobaseURL + 'aerolineasargentinas.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'AM') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'aeromexico.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'UX') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'aireuropa.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'AF') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'airfrance.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'AZ') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'alitalia.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'CI') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'chinaairlines.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'MU') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'chinaeastern.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'CZ') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'chinasouthern.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'OK') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'czechairlines.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'DL') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'delta.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'GA') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'garudaindonesia.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'KQ') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'kenyaairways.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'KL') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'klm.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'KE') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'koreanair.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'ME') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'mea.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'SV') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'saudia.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'RO') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'tarom.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'VN') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'vietnamairlines.png" /></li>';
                } else if (loungeacessjson.Airport.Lounges[i].Airlines_Access_Eligible[k].Airline_Code == 'MF  ') {
                    loungeacesshtml = loungeacesshtml + '<li><img src="' + airlinelogobaseURL + 'xiamenair.png" /></li>';
                }
            }
           
        }
    }
    if (jsonloungeCMSAccess != '') {
        $("#lounges-access-text").html(jsonloungeCMSAccess.AirlineAccessHeadingText);
    }
    $("#lounges-access-images").html(loungeacesshtml);


}

function SetLinkTargets() {
    $("a").filter(function () {
        return this.hostname && this.hostname !== location.hostname;
    }).each(function () {
        $(this).attr({
            target: "_blank",
        });
    });
    $("a").filter(function () {
        return ((this.hostname && this.hostname == "res.skyteam.com") || (this.hostname && this.hostname == "roundtheworld.skyteam.com"));
    }).each(function () {
        $(this).removeAttr("target");
    });
}



function validateMaxLength(obj) {
   // debugger;
    var text = obj.val();
    var maxlength = obj.attr('maxlength');

    if (maxlength > 0) {
        obj.val(text.substr(0, maxlength));
    }
}

function getUrlVars(locationHref) {
    var vars = [], hash;
    var hashes = locationHref.slice(locationHref.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function setCookie(key, value, expireTime) {
    var expires = new Date();
    expires.setTime(expires.getTime() + (expireTime));
    document.cookie = key + '=' + value + ';path=/;expires=' + expires.toUTCString();
}

function getCookie(key) {
    var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
    return keyValue ? keyValue[2] : null;
}

function eraseCookie(name) {
    setCookie(name, "", -1);
}

function MaintainenceAction() {
    
    if ($("#maintenance-message").length > 0) {
       // alert(getCookie("skyteam-maintenance-cookie"));
        if (getCookie("skyteam-maintenance-cookie") == null || getCookie("skyteam-maintenance-cookie") != "closed") {
            $("#maintenance-message").modal("show");
        }
    }
    $("#close-maintenance-message").click(function (ev) {
        var expireTime = 1 * 24 * 60 * 60 * 1000;
        setCookie("skyteam-maintenance-cookie", "closed", expireTime);
    });
}

function contactUsFormValidation() {
    var $thisForm = $("#contact-us-form");
    $("#contact-form-validation").addClass("hidden");
    $thisForm.find(".form-control").removeClass("input-error");
    var valid = 1;
    $thisForm.find(".form-control").filter(function () {
        return this.value == '';
    }).each(function () {
        valid = valid * 0;
        $(this).addClass("input-error");
        $("#contact-form-validation").removeClass("hidden");
    });
}

function ClearInputMask() {
    if (!$("body").hasClass("cargo")) {
        $("input[type='text'], input[type='email'], input[type='tel']").not(".hasDatepicker").not('#textbox-skypriority').before("<i class='icon-closecircle inputclear'></i>").addClass("clearenabled");
             $(".clearenabled").keyup(function () {
            //  $(this).prev().toggle(Boolean($(this).val()));
            if ($(this).val() != '') {
                $(this).prev().show();
            }
            else {
                $(this).prev().hide();
            }
        });

        $(".inputclear").toggle(Boolean($(this).next().val()));
        $(".inputclear").bind('click', function (ev) {
            $(this).next().val('').focus().addClass("empty");
            $(this).hide();
            return false;
        });
        $(".clearenabled").trigger("keyup");
    }
}

function buttonUp() {
    var inputVal = $('.searchbox-input').val();
    inputVal = $.trim(inputVal).length;
    if (inputVal !== 0) {
        $('.searchbox-icon').css('display', 'none');
    } else {
        $('.searchbox-input').val('');
        $('.searchbox-icon').css('display', 'block');
    }
}   

$(document).ready(function () {
 //remove label in lounge finder//
    $('#lounge-search-form #fromautocomplete').click(function () {
        $('#lounge-search-form').find('label').removeAttr('style');
    })
//change for airport map//
    $("#btn-search-airport-map").click(function (e) {
        var airportMapLink;
        airportMapLink = $('#sp-airportmap').val();
        if (airportMapLink != "") {
            $('#sp-airportmap-button').removeClass('error');
            window.open(airportMapLink, '_blank');
        }
        else {
            $('#sp-airportmap-button').addClass('error');
            
        }
    });
$('.global-meetings #scrollContent .msgbox-small-intro .row .msgbox-hover .msgbox-wrapper a.btn').css('width', $('.global-meetings #scrollContent .msgbox-small-intro .row .msgbox-hover .msgbox-wrapper a.btn SPAN').width() + 50);
	cargoresizeSection();
    if (location.hash) {
        setTimeout(function () {
            window.scrollTop(0, 0);
        }, 1);
    };
    if ($("#search-more-results").length > 0) {
        WebsiteSearch(true);
 
    $("#search-more-results").click(function (ev) {
        if (isWorking == 0) {
            isWorking = 1;
            WebsiteSearch(false, fromCount);
        }
    });
}
    function toggleChevron(e) {
        $(e.target)
            .prev('.panel-heading')
            .find("span.indicator")
            .toggleClass('icon-arrowdown icon-arrowup');
    }
    $('#accordion').on('hidden.bs.collapse', toggleChevron);
    $('#accordion').on('shown.bs.collapse', toggleChevron);

    //$("input").change(function () {
    //    var inputs = $(this).closest('form').find(':input');
    //    inputs.eq(inputs.index(this) + 1).focus();
    //});

    var submitIcon = $('.searchbox-icon');
    var inputBox = $('.searchbox-input');
    //30-Mar Release
    var searchBox = $('.menu-options .searchbox');
    //end
    var isOpen = false;
    submitIcon.click(function () {       
        if (isOpen == false) {
            searchBox.addClass('searchbox-open');
            inputBox.focus();
            isOpen = true;
	    $('.language-box').removeClass('language-active');
            $('.language-box').find('.languages').hide();
        } else {
            searchBox.removeClass('searchbox-open');
            inputBox.focusout();
            isOpen = false;
        }
        if ($.trim(inputBox.val()).length) {
            localStorage.setItem("searchPageKeyword", inputBox.val());
            window.location.href = $(".searchbox").attr("action");
        }
        return false;
    });
    submitIcon.mouseup(function () {
        return false;
    });
    searchBox.mouseup(function () {
        return false;
    });
    $(document).mouseup(function () {
        if (isOpen == true) {
            $('.searchbox-icon').css('display', 'block');
            submitIcon.click();
        }
    });

    $(".searchbox-submit").click(function (ev) {
        ev.preventDefault();
        if ($.trim(inputBox.val()).length) {
            localStorage.setItem("searchPageKeyword", inputBox.val());
            window.location.href = $(".searchbox").attr("action") + "?q=" + inputBox.val();
        }
	//30-Mar Release
        if ($('#error-searchbox').val().length) {
            localStorage.setItem("searchPageKeyword", $('#error-searchbox').val());
            window.location.href = $(".searchbox").attr("action") + "?q=" + $('#error-searchbox').val();
        }
        return false;
    });

    if ($("#support-mail-id").length > 0) {
        $("#SupportEmail").val($("#support-mail-id").val());       
    }

    $("#contact-us-form").submit(function () {
        if ($("#contact-us-form").valid()) {
            $("#dialogpopup").hide();
            $("#contact-form-sucess").addClass("hidden");
            $("#contact-form-error").addClass("hidden");
            var formAction = $(this).attr('action');

            $.post(formAction, $(this).serialize(), function (data) {
                if (data != null && data == true) {
                    $("#contact-form-section").find(".inputclear").trigger("click");
                    $("#contact-form-section").find("textarea").val("");
                    $("#contact-form-sucess").removeClass("hidden");
                }
                else {                   
                    $("#contact-form-error").removeClass("hidden");
                }

            }).fail(function () {               
                $("#contact-form-error").removeClass("hidden");
            });
            return false;
        }
    });
    //$("#contact-form-btn").click(function () {
    //    var $thisForm = $(this).parents("form");
    //    $("#contact-form-validation").addClass("hidden");
    //    $thisForm.find(".form-control").removeClass("input-error");
    //    var valid = 1;
    //    $thisForm.find(".form-control").filter(function () {
    //        return this.value == '';
    //    }).each(function () {
    //        valid = valid * 0;
    //        $(this).addClass("input-error");
    //        $("#contact-form-validation").removeClass("hidden");
    //    });
    //    //alert(valid);
    //    if (valid == 0) {
    //        return false;
    //    }
    //});
    
    

    if ($("#airline-fleet").length > 0) {
        $("#airline-fleet").selectmenu({});
        var palletAction = $("#pallet-container-action").val();
        // alert(palletAction);
        $("#airline-fleet").on ("selectmenuchange", function (ev) {
            if ($(this).val() != '' && palletAction != '') {
                $.ajax({
                    url: palletAction + '?fleetid=' + $(this).val(),
                    success: function (data) {
                        
                        $("#fleet-details").html(data);
                        $("#fleet-details").find("table").addClass("table");
                        $("#fleet-details").find("ul.nav-tabs a").click(function (e) {
                            e.preventDefault();
                            $(this).tab('show');
                        });
                        $("#fleet-details").find("ul.nav-pills a").click(function (e) {
                            e.preventDefault();
                            $(this).tab('show');
                        });
                    },
                    error: function (xhr, textStatus, errorThrown) {
                    }
                });
            }
        });
    }

    $(".fancybox").fancybox({
        padding: 0,
        autoResize: true,
        beforeShow: function () {
            this.title = $(this.element).attr('title');
            if ($(this.element).parent().find('p.desc').length > 0 && $(this.element).parent().find('p.desc').html() != null && $(this.element).parent().find('p.desc').html() != '') {
                this.title = '<h4>' + this.title + '</h4>' + '<p>' + $(this.element).parent().find('p.desc').html() + '</p>';
            }
        },
        helpers: {
            title: { type: 'inside' },
        }
    });
    //Language Filter and exclusion - 29-Feb-2016
    var theLanguage = $('html').attr('lang');
    //if (theLanguage.toLowerCase() == 'nl' || theLanguage.toLowerCase() == 'cs')
    //{
    //    theLanguage = 'en';
    //}
    if(theLanguage.toLowerCase() == 'pt-br')
    {
        theLanguage = 'pt';
    }

    if ($("#textbox-airport").length > 0 && $("#button-airport").length > 0) {
        loadAutoCompleteWidget("allAirports", "yfunvneadwz62wywjvtgqc8a", theLanguage, true, true, "#f6f6f6", "#eef0f8");
    }
    if ($("#textbox-skypriority").length > 0) {
        loadAutoCompleteWidget("allAirports", "yfunvneadwz62wywjvtgqc8a", theLanguage, true, true, "#f6f6f6", "#eef0f8");
    }
    if ($("#lounges-access-images").length > 0) {
        //  alert(airportCode);
        // alert($("#lounge-access-text").length);
        if (typeof exclusiveLoungeCode != 'undefined' && exclusiveLoungeCode != '') {
            APICallForJSON("https://api.skyteam.com/v1/locations/airports/lounges?airportcode=" + exclusiveLoungeCode, "yfunvneadwz62wywjvtgqc8a", "loungeaccess");
        }
    }
    //$(function () {
    //    $(".player").mb_YTPlayer(); // .player - class to add for playing video ( see the div above to understand)
    //});
    //$('#videoplay').click(function () {
    //    $("#video-sec").seekToYTP(0);
    //    $("#video-sec").unmuteYTPVolume();
    //    $("#video-sec").fullscreen();
    //});

    //$("#video-sec").on('YTPFullScreenEnd', function (e) {
    //    //$("#video-sec").playerDestroy();
    //    $("#video-sec").muteYTPVolume();
    //});

    if ($(".ffpstatusform").length > 0) {
        $("#ffp_tirelevel").selectmenu({});
        $("#ffp_program").selectmenu({});

        var screenWidth = $(window).width();
        
        $('#ffp_program').on('selectmenuchange', function () {
            tmpAirPro = $('#ffp_program').val();
            midAirPro = tmpAirPro.split(":");
            airlinecode = midAirPro[0];
            loyaltyProgrammeName = midAirPro[1];
            tierLevel = $('#ffp_tirelevel').val();

            $(".ffp-results").css("display", "none");
            $("#ffp-status-info").html("");

            $("#ffp-tierlevel-dropdown").addClass("hidden");
            $(".ffp-results-error").html("");
            if (typeof loyaltyProgrammeName == 'undefined') {
                $(".ffp-results").css("display", "none");
                $("#ffp-status-info").html("");
                $(".ffp-results-error").html("Please select a valid airline code.");
                $(".ffp-results-error").css("display", "block");
            } else {
                APICallForJSON("https://api.skyteam.com/v1/loyalty/status?airlineCode=" + airlinecode + "&loyaltyProgrammeName=" + loyaltyProgrammeName, "yfunvneadwz62wywjvtgqc8a", "ffp_tirlevels");
            }
        });

        $('#ffp_tirelevel').on('selectmenuchange', function () {
            tmpAirPro = $('#ffp_program').val();
            midAirPro = tmpAirPro.split(":");
            airlinecode = midAirPro[0];
            loyaltyProgrammeName = midAirPro[1];
            tierLevel = $('#ffp_tirelevel').val();
            if (tierLevel == 'Your Tier Level') {
                $(".ffp-results").css("display", "none");
                $("#ffp-status-info").html("");
                $(".ffp-results-error").html("Please select a valid tire level.");
                $(".ffp-results-error").css("display", "block");
            }
            else if (typeof loyaltyProgrammeName == 'undefined') {
                $(".ffp-results").css("display", "none");
                $("#ffp-status-info").html("");
                $(".ffp-results-error").html("Please select a valid airline code.");
                $(".ffp-results-error").css("display", "block");
            }
            else {
                APICallForJSON("https://api.skyteam.com/v1/loyalty/status?airlineCode=" + airlinecode + "&loyaltyProgrammeName=" + loyaltyProgrammeName + "&tierLevel=" + tierLevel, "yfunvneadwz62wywjvtgqc8a", "ffp_status");
                //if (screenWidth <= 996) {
                //    $('.skyteam-programs').css("margin-top", "40px");
                //    $('.status-program').css("height", "1149px");
                //} else {
                //    $('.skyteam-programs').css("margin-top", "457px");
                //    $('.status-program').css("height", "1199px");
                //}
            }
        });



    }
    SetLinkTargets();


    $(window).scroll(function () {
        if ($(this).scrollTop() == 0) {
            $('.navbar').css({
                'box-shadow': 'none',
                '-moz-box-shadow': 'none',
                '-webkit-box-shadow': 'none'
            });
        }
        else {
            $('.navbar').css({
                'box-shadow': '1px 1px 1px rgba(0,0,0,0.5)',
                '-moz-box-shadow': '1px 1px 1px rgba(0,0,0,0.5)',
                '-webkit-box-shadow': '1px 1px 1px rgba(0,0,0,0.5)'
            });
        }
    });

    $("form#form-cargo input#cargoInputOne").on('input', function () {
        // alert($(this).attr('maxlength'));
        if ($(this).val().length == $(this).attr('maxlength')) {
            $(this).parents("FORM").find("input#cargoInputTwo").focus();
        }
    });

    $("input#cargoInputOne,input#cargoInputTwo").focus(function (event) {
        $(this).val("");
    });

    $("input#cargoInputTwo").on("keyup", function () { validateMaxLength($(this)); });

    /* Code for Preview Presentation in CMS Iframe*/
    $(".PreviewEditComp").click(function (ev) {

        ev.preventDefault();
        var parentLocation = window.top.location.href;

        parentLocation = parentLocation.split("epi.cms.contentdata")[0];
        window.top.location.href = parentLocation + "epi.cms.contentdata:///" + $(this).attr("href").replace("#", "");
        return false;
    });

    if ($(".PreviewEditComp").length > 0 && $(".epi-compare-toolbar__text-wrapper", window.top.document).length <= 0) {
        var epilanguage = getUrlVars(window.top.location.href)["language"];
        if (epilanguage != null && epilanguage != '' && epilanguage != 'undefined') {

            epilanguage = epilanguage.split("#")[0];

            if (previewCulture.toLowerCase() != epilanguage.toLowerCase()) {

                $("div.languages").show("fast");

                setTimeout(function () {
                    $("DIV.languages").find("A[href='#" + epilanguage + "']").trigger("click", function (ev) {
                        ev.preventDefault();


                        document.location.href = $(this).attr("name");
                    });
                }, 500);


            }
        }
    }


    /** read more option **/
    (function ($) {
        $.fn.shorten = function (settings) {

            var config = {
                showChars: 300,
                ellipsesText: "...",
                moreText: "Read more",
                lessText: ""
            };

            if (settings) {
                $.extend(config, settings);
            }

            $(document).off("click", '.morelink');

            $(document).on({
                click: function () {

                    var $this = $(this);
                    if ($this.hasClass('less')) {
                        $this.removeClass('less');
                        $this.html(config.moreText);
                    } else {
                        $this.addClass('less');
                        $this.html(config.lessText);
                    }
                    $this.parent().prev().toggle();
                    $this.prev().toggle();
                    return false;
                }
            }, '.morelink');

            return this.each(function () {
                var $this = $(this);
                if ($this.hasClass("shortened")) return;

                $this.addClass("shortened");
                var content = $this.html();
                if (content.length > config.showChars) {
                    var c = content.substr(0, config.showChars);
                    var h = content.substr(config.showChars, content.length - config.showChars);
                    var html = c + '<span class="moreellipses">' + config.ellipsesText + ' </span><span class="morecontent"><span>' + h + '</span> <a href="#" class="morelink">' + config.moreText + '</a></span>';
                    $this.html(html);
                    $(".morecontent span").hide();
                }
            });

        };

    })(jQuery);

    //Cookie Bar - Privacy Policy for Website using CookieBar Plugin
    $.cookieBar({ message: 'We use cookies on this website, you can read about them<a href="http://www.skyteam.com/cookie-policy/">here</a>. To use the website as intended, please accept cookies.', acceptText: 'Accept' });
    $("#cookie-bar .cb-enable").addClass("btn st-primary-button");

    $(window).load(function () {
        MaintainenceAction();
        ClearInputMask();   
	//changes form arabic share plugin
        theLanguage = $('html').attr('lang');
        if (theLanguage == 'ar') {
            $('#at4-share').removeClass('atss-right slideInRight');
            $('#at4-share').addClass('atss-left slideInLeft');
            $('#at4-scc').find('.at4-arrow').removeClass('at-right').addClass('at-left');
            $('#at4-soc').find('.at4-arrow').removeClass('at-left').addClass('at-right');
            $('#at4-soc').css('padding','0px');
            $('#at4-scc').click(function () {
                $('#at4-soc').removeClass('at-share-open-control-right slideInRight');
                $('#at4-soc').addClass('at-share-open-control-left slideInLeft');
            });

            $('#at4-soc,#at4-scc').find('.at4-arrow').text("");
        }  
        //changes for airport map
        $('#textbox-airportmap').removeClass('clearenabled');
        $('#textbox-airportmap').addClass('empty');
        $('#lounge-search-form #fromautocomplete').removeClass('clearenabled');
        $('#lounge-search-form #fromautocomplete').addClass('empty');
        $("#dialogpopup").hide();
        $('form').find('.error').removeClass("error");
        $('.at4-share-label').html(shareLabel);
        $('.at4-share-title').html(shareLabel);
        
        $("#download-pdf-btn").click(function (ev) {
            var printHTML = '';
            $(".print-content").each(function (ev) {
                printHTML = printHTML + $(this)[0].outerHTML;
            });
            var $printHTML = $(printHTML);
                      

            if ($(".cargo-referenceid h3").length > 0) {
                $("#pdfcontent").val(printHTML);
                $("#fileName").val($(".cargo-referenceid h3").text());
            }
            else {
                $printHTML.find("form").remove();
                $printHTML.find(".details").remove();
                $printHTML.find(".more-options").remove();
                $printHTML.find(".return-more-options").remove();
                if ($printHTML.find("div.result.active").length > 0) {                    
                    $printHTML.find("div.result:not(.active)").remove();
                    $printHTML.find(".icon-tick").html("&#10004;");
                    //console.log("final COntent: " + $printHTML.html());
                    $("#pdfcontent").val($printHTML.html());
                }
                else {
                    $("#pdfcontent").val($printHTML.html());
                }
                $("#fileName").val("Flight Finder Results");
            }
            return true;
        });

        $('.press-release p').succinct({
            size: 200
        });

        $('.press-release h3 a').succinct({
            size: 75
        });

        if ($(window).width() > 767) {

            $(".themecards").each(function () {
                var $thisObj = $(this);
                var maxHeightp = 0;
                var maxHeighth2 = 0;
                var maxHeighth3 = 0;
                $thisObj.find(".st-height-cards").each(function () {
                    if ($(this).height() > maxHeightp) { maxHeightp = $(this).height(); }
                });
                $thisObj.find("h2").each(function () {
                    if ($(this).height() > maxHeighth2) { maxHeighth2 = $(this).height(); }
                });
                $thisObj.find("h3").each(function () {
                    if ($(this).height() > maxHeighth3) { maxHeighth3 = $(this).height(); }
                });
                $thisObj.find(".st-height-cards").height(maxHeightp);
                $thisObj.find("h2").height(maxHeighth2);
                $thisObj.find("h3").height(maxHeighth3);
            });
       

            $(".press-release").each(function () {
                var $thisObj = $(this);

                var maxHeightpressrelease = 0;
                $thisObj.find(".list-wrapper h3").each(function () {
                    if ($(this).height() > maxHeightpressrelease) { maxHeightpressrelease = $(this).height(); }
                });
                $thisObj.find(".list-wrapper h3").height(maxHeightpressrelease);

                var maxHeightpressrelease = 0;
                $thisObj.find(".list-wrapper").each(function () {
                    if ($(this).height() > maxHeightpressrelease) { maxHeightpressrelease = $(this).height(); }
                });
                $thisObj.find(".list-wrapper").height(maxHeightpressrelease);
            });
            $(".facts").each(function () {
                var $thisObj = $(this);

                var factheight = 0;
                $thisObj.find(".facts-each").each(function () {
                    if ($(this).height() > factheight) { factheight = $(this).height(); }
                });
                $thisObj.find(".facts-each").height(factheight);

            });
            $(".cards").each(function () {
                var $thisObj = $(this);

                var spheight = 0;
                $thisObj.find(".thumbnail").each(function () {
                    if ($(this).height() > spheight) { spheight = $(this).height(); }
                });
                $thisObj.find(".thumbnail").height(spheight);

            });

        }
    });

    $("body").css('paddingTop', $("nav.navbar").outerHeight());
    //alert($("nav.navbar").outerHeight());


    if ($('.quickcard').length > 0) {
        $('.msgbox-quickcard').css('display', 'none');
        $('.msgbox-small-intro .row').first().append('<div class="col-md-3"><div class="quickcard">' + $('.quickcard').html() + '</div></div>');
    }

    //if ($('.panel-collapse').length > 0) {
    //    console.log(1)
    //    $('.panel-collapse').first().addClass('in');
    //}


 



});
    


$(window).resize(function () {
    $("body").css('paddingTop', $("nav.navbar").outerHeight());
    if ($(window).width() > 767) {
        $(".themecards").each(function () {
            var $thisObj = $(this);
            var maxHeightp = 0;
            var maxHeighth2 = 0;
            var maxHeighth3 = 0;
            $thisObj.find(".st-height-cards").each(function () {
                if ($(this).height() > maxHeightp) { maxHeightp = $(this).height(); }
            });
            $thisObj.find("h2").each(function () {
                if ($(this).height() > maxHeighth2) { maxHeighth2 = $(this).height(); }
            });
            $thisObj.find("h3").each(function () {
                if ($(this).height() > maxHeighth3) { maxHeighth3 = $(this).height(); }
            });
            $thisObj.find(".st-height-cards").height(maxHeightp);
            $thisObj.find("h2").height(maxHeighth2);
            $thisObj.find("h3").height(maxHeighth3);
        });
    }
});


$(document).ajaxStop(function () {
    SetLinkTargets();
    $(".comment").shorten();    
    $('#lastPostsLoader').css("display", "none");
});

//Function to call API for Airlines list
function airlineCall(airportcode, airlineCtrl) {
    //call for airportmap//
    getAirportMapResponse(airportcode, "#sp-airportmap");
    APICallForJSON('https://api.skyteam.com/v1/locations/airports/' + airportcode, 'yfunvneadwz62wywjvtgqc8a', "AirlineAPI", airlineCtrl);
}

//Function to Airlines list in dropdown
function getAirlineList(airlineAPI, airlineCtrl) {
  
    var mySelect = $(airlineCtrl);
    mySelect.selectmenu("destroy").selectmenu({ style: "dropdown" });
    if ($("#default-ailine-option").length > 0) {
        mySelect.append(
            $('<option selected="selected"></option>').val("").html($("#default-ailine-option").val()));
        
    }
    else {
        mySelect.append(
        $('<option selected="selected"></option>').val("").html("Select an airline"));
    }
    var airline_Contents = '<option value="" selected>Select an Airline</option>';
    if (airlineAPI.airport.skyPriorityFacilities != null && airlineAPI.airport.skyPriorityFacilities.airlines != null) {
        console.log(4);
        //debugger;
        //if (airlineAPI.airport.skyPriorityFacilities.available == "No") {
        //    console.log(1);
        //} else {
	//Adding of a banner for airports without skytips-Start
        $('#banner-id').append(airlineAPI.airport.airportName);
        //End

        var airlineslength = airlineAPI.airport.skyPriorityFacilities.airlines.length;
        var airlineArrays = airlineAPI.airport.skyPriorityFacilities.airlines.sort(function (a, b) {
            return compareStrings(a.name, b.name);
        });
        for (var i = 0; i < airlineslength; i++) {
            mySelect.append(
                $('<option></option>').val(airlineArrays[i].code).html(airlineArrays[i].name)
            );
        }
        mySelect.selectmenu('refresh', true);

    } else {
        $("#sp-error-api").show().html(airlineAPI.airport.skyPriorityFacilities.errors[0].description);
        $('#sp-airline-button').hide();
        $('.newtransfer-sp').hide();
        $('#btn-search-sky-flights').hide();
        $('.returninput-skypriority').hide();
        $("#skiplinkcomp-skypriorityform").addClass("hidden");
        
    }
}
//Adding Airport maps
function getAirportMapResponse(airportcode, airportMapCtrl) {
    APICallForJSON('https://api.skyteam.com/v3/locations/airports/' + airportcode, 'yfunvneadwz62wywjvtgqc8a', "AirportMap", airportMapCtrl);

}
function getAirportMap(airportMap, airportMapCtrl) {
    $('#textbox-airportmap').val($('#textbox-skypriority').val());
    //$('#textbox-airportmap').val(airportMap.airport.airportName);
    var mySelect = $(airportMapCtrl);
    mySelect.append(
         $('<option selected="selected"></option>').val("").html("Select a Map"));
    if (airportMap.airport.maps != null) {
        var airportMapLength = airportMap.airport.maps.length;
        var airportMapArrays = airportMap.airport.maps.sort(function (a, b) {
            return compareStrings(a.name, b.name);
        });
        for (var i = 0; i < airportMapLength; i++) {
            mySelect.append(
                $('<option></option>').val(airportMapArrays[i].url).html(airportMapArrays[i].name)
            );
        }
        $('#sp-airportmap').selectmenu({});
        mySelect.selectmenu('refresh', true);        
    }
    else {
        $('#skiplinkcomp-airportmapform').css('display', 'none');
    }
}

$.fn.extend({
    toggleText: function (a, b) {
        $.trim(this.html()) == a ? this.html(b) : this.html(a);
    }
});
function cargoresizeSection(){
    var ht = ($('.themecards SECTION.linklist').eq(0)).height(), ht1 = ($('.themecards SECTION.biglist-long .list-wrapper').eq(0)).height();
    var finalht = ht > ht1 ? ht : ht1;
    ($('.themecards SECTION.linklist').eq(0)).height(finalht);
    ($('.themecards SECTION.biglist-long .list-wrapper').eq(0)).height(finalht);
}

var flag = 0; //global variable
$("#textbox-airport").on({
    autocompleteclose: function (event, ui) {
        flag = 1;
        //set flag back to 0 with a short delay so the next keypress can submit form
        setTimeout(function () {
            flag = 0;
        }, 150);
    },
    //if the autocomplete widget is open, don't submit form on keypress
    autocompleteopen: function (event, ui) {
        flag = 1;
    }
});



function onCtrlFocus_airport(event) {
    if (event.keyCode == 13 && !$('.ui-autocomplete').is(':visible')) {
        
        if (flag == 0) {
            $("#button-airport").trigger("click");
            return false;
        }
    }
}
function videotagging(page)
{
    $('.header-video .comp-header-image .video-main .video-wrapper a.icon-play p img').remove();
	if(page=='skypriority')
{
//alert(page);
$('.header-video .comp-header-image .video-main .video-wrapper a.icon-play p').append('<img src="https://secure.adnxs.com/px?id=691172&t=2" width="1" height="1" />');
}
else if (page=='lounges-video-header')
{
//alert(page);
$('.header-video .comp-header-image .video-main .video-wrapper a.icon-play p').append('<img src="https://secure.adnxs.com/px?id=691170&t=2" width="1" height="1" />');
}
else if (page == 'Global Meetings Header')
{
   // alert(page);
    $('.header-video .comp-header-image .video-main .video-wrapper a.icon-play p').append('<img src="https://secure.adnxs.com/px?id=715765&t=2" width="1" height="1" />');
}
}

//share label multilingual//
shareLanguage = $('html').attr('lang');
shareLabel = '';
shareUrl = 'https://content.skyteam.com/contentapi/api/pages/getstaticcontent?pageURL=/site/shared/skyteam-footer,' + shareLanguage;
shareCmskey = '575fbcdd-0e55-4ac8-a7d7-633248fdcd91';
$.ajax({

    url: shareUrl,
    dataType: "json",
    headers: {
        'cmsapikey': shareCmskey
    },
    success: function (data) {
        apiValue = JSON.parse(data);
        shareLabel = apiValue.shareLabel;
    }
});
