var ICBlueBiz;(function(n){"use strict";var i=function(){function n(){}return n}(),t;n.Events=i;t=function(){function t(){this.inited=!1;this.showRow=ko.observable(!0);this.settings=new n.ACLViewModel("/api/Links/GetCountriesForAirline","/api/Links/GetLanguagesForAirlineAndCountry");this.video=new VideoViewModel;this.pageModel=ko.observable(null);this.chosenBBnr=ko.observable();this.chosenCompany=ko.observable();this.chosenName=ko.observable();this.chosenEmail=ko.observable();this.chosenTelephone=ko.observable()}return t.prototype.init=function(){this.inited||(this.inited=!0);this.hasCookies();ko.applyBindings(this)},t.prototype.hasCookies=function(){var n=$.cookie("carrier")!=undefined&&$.cookie("carrier").length>0&&$.cookie("country")!=undefined&&$.cookie("country").length>0&&$.cookie("lang")!=undefined&&$.cookie("lang").length>0;n&&this.showRow(!1)},t.prototype.extend=function(n){this.pageModel(n)},t.prototype.setCookies=function(){var n=this;this.settings.airline($.cookie("carrier")||"");this.settings.populateCountries($.cookie("country")||"",function(){n.settings.populateLanguages($.cookie("lang")||"",function(){n.settings.viewModelInitialized=!0;$("#ltc").length>0&&$("#ltc .acl-select").msDropdown()})})},t.prototype.toggleVisibility=function(){this.showRow(!this.showRow());$("#ltc").length>0&&$("#ltc .acl-select").each(function(){$(this).msDropdown().data("dd").destroy();$(this).msDropdown()});$("html, body").animate({scrollTop:0},800)},t}();n.ViewModel=t})(ICBlueBiz||(ICBlueBiz={}));ko.bindingHandlers.valueWithInit={init:function(n,t,i,r){var u=t(),f=n.value;ko.isWriteableObservable(r[u])||(r[u]=ko.observable());f&&f.length>0&&r[u](f);ko.applyBindingsToNode(n,{value:r[u]})}},function(n){"use strict";var i=function(){function n(n,i){var r=this;this.saveSettings=function(){if(r.allOptionsSpecified()&&r.currentLinkType)r.goToLink(r.airline(),r.country(),r.language(),r.currentLinkType,r.contentId),$("#info .close-reveal-modal").trigger("click");else return!1};this.countryRequestUrl=n;this.languageRequestUrl=i;this.airline=ko.observable("");this.country=ko.observable("");this.language=ko.observable("");this.viewModelInitialized=!1;this.airlineOptions=[new t("AF","AirFrance"),new t("KQ","Kenya Airways"),new t("KL","KLM"),new t("DL","Delta")];this.countryOptions=ko.observableArray([]);this.languageOptions=ko.observableArray([]);this.bluebizUrl=ko.computed(function(){return"http://www.bluebiz.com?carrier="+r.airline()+"&country="+r.country()+"&lang="+r.language()});this.airline.subscribe(function(n){n&&n!=""&&r.viewModelInitialized==!0&&(r.getOptions(r.countryRequestUrl,r.countryOptions,function(){$("#ltc").length>0&&($("#ltc .acl-country").msDropdown().data("dd").destroy(),$("#ltc .acl-country").msDropdown())}),r.country()&&r.country().length>0&&r.getOptions(r.languageRequestUrl,r.languageOptions,function(){$("#ltc").length>0&&($("#ltc .acl-language").msDropdown().data("dd").destroy(),$("#ltc .acl-language").msDropdown())}))});this.country.subscribe(function(n){n&&n!=""&&r.viewModelInitialized==!0&&r.getOptions(r.languageRequestUrl,r.languageOptions,function(){$("#ltc").length>0&&($("#ltc .acl-language").msDropdown().data("dd").destroy(),$("#ltc .acl-language").msDropdown())})});this.currentLinkType=null;this.allOptionsSpecified=ko.computed({owner:this,read:function(){return r.airline()&&r.airline().length>0&&r.country()&&r.country().length>0&&r.language()&&r.language().length>0}})}return n.prototype.renderOption=function(n,t){t&&t.key&&(n.setAttribute("data-image","/Static/img/blank.gif"),n.setAttribute("data-imagecss","flag "+t.key.toLowerCase()))},n.prototype.populateCountries=function(n,t){var i=this;this.getOptions(this.countryRequestUrl,this.countryOptions,function(){i.country(n);t&&t()})},n.prototype.populateLanguages=function(n,t){var i=this;this.getOptions(this.languageRequestUrl,this.languageOptions,function(){i.language(n);t&&t()})},n.prototype.openDialog=function(n,t,i){this.currentLinkType=n;this.contentId=i;$("#"+t).foundation("reveal","open")},n.prototype.goToLink=function(n,t,i,r,u){$.ajax("/api/Links/GetTypedLink",{data:{airline:n,country:t,lang:i,linktype:r,contentId:u},type:"POST",async:!1,dataType:"json",success:function(n){n.target=="self"?document.location.href=n.url:window.open(n.url,"_blank")},statusCode:{404:function(){console.log("::page not found")},500:function(){console.log("::Server error")}}})},n.prototype.getOptions=function(n,i,r){$.ajax(n,{data:{airline:this.airline(),country:this.country()},type:"POST",dataType:"JSON",success:function(n){i($.map(n,function(n){return new t(n.Key,n.Value)}));r&&r()},statusCode:{404:function(){},500:function(){}}})},n}(),t;n.ACLViewModel=i;t=function(){function n(n,t){this.key=n;this.value=t}return n}();n.ACLListItem=t}(ICBlueBiz||(ICBlueBiz={}))