function getParkingBookingInformation(){var n=$J.ajax({url:"/ajax/aia/Dashboard/GetBookingDetails",method:"POST",contenttype:"text/html",beforeSend:function(){}});n.done(function(n){n!=""&&n.entryDateTime.length>0&&n.exitDateTime.length>0&&($J(".Parking_Parent").addClass("persona"),$J("article.Parking p.text-left").toggleClass("hide"),$J("article.Parking p.text-left span.entrydatetime").html(n.entryDateTime),$J("article.Parking p.text-left span.exitdatetime").html(n.exitDateTime),$J("a.parking-dictionary").attr("href",n.accountManagementURL),$J("a.parking-dictionary").toggleClass("hide"),$J("p.Parking").toggleClass("hide"),$J("a.Parking").toggleClass("hide"),$J("a#parkingpanel").remove(),$J(".Parking_Parent p.secondarytextdefaultvalue").toggleClass("hide"));hideProgressDashboard("Parking")});n.fail(function(){hideProgressDashboard("Parking")})}function getEmperorLoungeBookingInformation(){var n=$J.ajax({url:"/ajax/aia/Dashboard/GetLoungeBooking",method:"POST",contenttype:"text/html",beforeSend:function(){}});n.done(function(n){n!=""&&n.bookingRef!=""&&($J(".EmperorLounge_Parent").addClass("persona"),$J("p.EmperorLounge").toggleClass("hide"),$J("a.EmperorLounge").toggleClass("hide"),$J("article.EmperorLounge").addClass("persona"),$J(".emperorLoungedatetime").html(n.entryDateTime),$J(".emperorLoungeBookingref").html(n.bookingRef),$J("p.text-left.emperorlounge").toggleClass("hide"),$J("a#emperorLoungePanel").remove(),$J(".emperor-dictionary").toggleClass("hide"),$J("a.emperor-dictionary").attr("href",n.accountManagementURL),$J(".EmperorLounge_Parent p.secondarytextdefaultvalue").toggleClass("hide"));hideProgressDashboard("EmperorLounge")});n.fail(function(){hideProgressDashboard("EmperorLounge")})}function getFlightBookingInformation(){var n=$J.ajax({url:"/ajax/aia/Dashboard/GetRecentFollowedFlights",method:"POST",contenttype:"text/html",beforeSend:function(){}});n.done(function(n){n!=""&&n.flightNumber!=""&&($J(".Flights_Parent").addClass("persona"),$J("p.Flights").toggleClass("hide"),$J(".Flights_Parent p.secondarytextdefaultvalue").toggleClass("hide"),$J("a.Flights").toggleClass("hide"),$J(".flightdatetime").text(n.date),$J(".flightdatetime").prev().text(n.FlightType),$J("a#flightsPanel").remove(),$J(".flightdatetime").parent().removeClass("hide"),$J("article.Flights").find("h2").html('<i class="aia-ico aia-icons-16"><\/i>'+n.flightNumber),$J(".flights-dictionary").attr("href",n.accountManagementURL),$J(".flights-dictionary").toggleClass("hide"),n.checkInZone.length>0?($J(".checkInZone").toggleClass("hide"),$J("#checkInZone").html(n.checkInZone)):n.gate.length>0?($J(".gate").toggleClass("hide"),$J("#gate").html(n.gate)):n.FlightCarousel.length>0&&($J(".flightCarousel").toggleClass("hide"),$J("#flightCarousel").html(n.FlightCarousel)),$J(".Flights_Parent").find(".aia-ico.aia-icons-16").css("display","block"));hideProgressDashboard("Flights")});n.fail(function(){hideProgressDashboard("Flights")})}function showProgressDashboard(n){$J("div."+n).fadeIn("fast")}function hideProgressDashboard(n){var t=$J("div."+n);t.stop();t.fadeOut("fast")}function DateSelectonForm(){$J(".entry-date, .exit-date").datetimepicker({showMeridian:!0,autoclose:!0,todayBtn:!1,pickerPosition:"bottom-left",todayHighlight:!0})}function LoungeDateTimePickerEvent(){var n=$J(".emperor-lounge-entry-date")[0].attributes["data-hours-disabled"];$J(".emperor-lounge-entry-date").datetimepicker({showMeridian:!0,autoclose:!0,todayBtn:!1,hoursDisabled:n.value,pickerPosition:"bottom-left",todayHighlight:!0});$J("#form-emperor-lounge").validator().on("submit",function(n){var i=$J(".emperor-lounge-entry-date").data("datetimepicker").getDate().getHours(),t=$J(".emperor-lounge-entry-date")[0].attributes["data-hours-disabled"];t!=null&&t.value.split(",").forEach(function(t){if(parseInt(t.trim())===i)return $J("#lounge-time-validation").removeClass("hide"),n.preventDefault(),!1})})}function setColorToLoyaltyTile(){var r=$J("#login-button-desktop").attr("data-status"),i,n,t;r==="signed-in"&&(i=$J(".loyalty-tile"),typeof i!="undefined"&&$J(".loyalty-tile").length>0&&(n=$J(".loyalty-tile").attr("data-colour"),typeof n!="undefined"&&n.length>0&&(t=$J(".dashboard-item.Loyalty_Parent"),typeof t!="undefined"&&t.length>0&&$J(".Loyalty_Parent .Loyalty").find("h2").addClass(n))))}function getLoyaltyTileDetails(){var n=$J.ajax({url:"/ajax/aia/Dashboard/GetLoyaltyDetails",method:"POST",contenttype:"text/html"});n.done(function(n){var r,t,i;n.loyaltyNamePointsNumber!=undefined&&n.loyaltyNamePointsNumber.length>0&&(n.loyaltyNamePointsNumber[0]!=undefined&&n.loyaltyNamePointsNumber[0].length>0&&(r=$J(".loyalty-tile-details.tiername"),$J(".dashboard-loyalty-secondary-text").toggleClass("hide"),$J(".loyalty-secondarytext").toggleClass("hide"),r.text(n.loyaltyNamePointsNumber[0]),$J(".viewprofile-dictionary").toggleClass("hide"),$J("#loyaltyLink").remove(),$J(".viewprofile-dictionary").attr("href",n.AccountManagementActivityPageUrl)),n.loyaltyNamePointsNumber[1]!=undefined&&n.loyaltyNamePointsNumber[1].length>0&&(t=$J(".loyalty-tile-details.number"),t.text(t.attr("data-text")+" "+n.loyaltyNamePointsNumber[1])),n.loyaltyNamePointsNumber[2]!=undefined&&n.loyaltyNamePointsNumber[2].length>0&&(i=$J(".loyalty-tile-details.points"),i.text(i.attr("data-text")+" "+n.loyaltyNamePointsNumber[2])));hideProgressDashboard("Loyalty")});n.fail(function(){hideProgressDashboard("Loyalty")})}$J('.dashboard .btn-action[data-toggle="collapse"]').on("click",function(){var n=$J(this).attr("class"),t,i;(n.indexOf("loaded")=="-1"&&(n.indexOf("Parking")>=0||n.indexOf("EmperorLounge")>=0||n.indexOf("Flights")>=0)||n.indexOf("Insurance")>=0)&&(t="",n.indexOf("Parking")>=0?(t="/ajax/aia/Dashboard/GetCarParkBookingItem",$J(".parking-tile-spinner").removeClass("hide")):n.indexOf("EmperorLounge")>=0?($J(".emperorLounge-tile-spinner").removeClass("hide"),t="/ajax/aia/Dashboard/GetEmperorLoungeItem"):n.indexOf("Insurance")>=0&&(t="/ajax/aia/Dashboard/GetInsuranceQuoteItem",$J(".parking-tile-spinner").removeClass("hide")),i=$J.ajax({url:t,method:"POST",contenttype:"text/html",beforeSend:function(){}}),i.done(function(t){if(t!=""&&n.indexOf("EmperorLounge")>=0)$J(".emperorLounge-tile-spinner").addClass("hide"),$J("#EmperorLounge").html(t),$J("#EmperorLounge .emperor-lounge-background").attr("class","addons emperor-lounge-addons emperor-lounge-background"),$J("#EmperorLounge .form-card-content").validator(),LoungeDateTimePickerEvent();else if(t!=""&&n.indexOf("Parking")>=0){$J(".parking-tile-spinner").addClass("hide");$J("#Parking").html(t);$J("#Parking .booking-form").validator();var i=$J(".parking-dashboard-promotion .col-xs-12").html();$J("#Parking .parking-tall-promotion").html(i);DateSelectonForm()}else t!=""&&n.indexOf("Insurance")>=0&&($J(".parking-tile-spinner").addClass("hide"),$J("#InsuranceQuote").html(t));hideProgressDashboard();$J('[data-toggle="popover"]').popover()}),i.fail(function(){$J(".emperorLounge-tile-spinner").addClass("hide");$J(".parking-tile-spinner").addClass("hide")}),$J(this).addClass("loaded"))});$J("#dashboardCollapseCollection").on("shown.bs.collapse",function(){var i="#"+$J('#dashboardCollapseCollection div[aria-expanded="true"]').attr("id"),n=$J(i).offset().top,r=$J(".sitewide-alert"),t;r.length>0&&(t=$J(".sitewide-alert").outerHeight()*2,n=n-t);$J("html, body").animate({scrollTop:n},400)});$J(document).ready(function(){if($J(".dashboard").length>0&&$J(".dashboard").attr("class").indexOf("edit")=="-1"){var n=$J("#Parking ");n!=null&&n.length>0&&$J(".dashboard-item").each(function(){var n=$J(this).find("article").attr("class");n=="Parking"?(spinnerVisible=!1,($J("#login-button-desktop").attr("data-status")=="signed-in"||$J("#login-button-mobile").attr("data-status")=="signed-in")&&(showProgressDashboard(n),getParkingBookingInformation())):n=="EmperorLounge"?(spinnerVisible=!1,($J("#login-button-desktop").attr("data-status")=="signed-in"||$J("#login-button-mobile").attr("data-status")=="signed-in")&&(showProgressDashboard(n),getEmperorLoungeBookingInformation())):n=="Flights"?(spinnerVisible=!1,($J("#login-button-desktop").attr("data-status")=="signed-in"||$J("#login-button-mobile").attr("data-status")=="signed-in")&&(showProgressDashboard(n),getFlightBookingInformation())):n==="Loyalty"&&(spinnerVisible=!1,($J("#login-button-desktop").attr("data-status")=="signed-in"||$J("#login-button-mobile").attr("data-status")=="signed-in")&&(showProgressDashboard(n),getLoyaltyTileDetails()))})}});$J(document).ready(function(){$J(".dashboard").length>0&&($J(".dashboard-item i.aia-ico").css("display","block"),setColorToLoyaltyTile())})