//Copyright © [Year(s)] Nokia Corporation and/or its subsidiary(-ies).
Fp.Modules.PremiumContent={elements:{template:null,premiumCList:null},currentProvider:"",init:function(){this.setElements();},load:function(){if(null===this.elements.template||null===this.elements.premiumCList){this.setElements();}if(Fp.POI.premiumContent){this.fillContent(Fp.POI.premiumContent);}},setElements:function(){this.elements.template=Fp.byId("premiumElements").children[0];this.elements.premiumCList=Fp.byId("PremiumProviderList");},fillContent:function(c){if(c){this.clearContent();Fp.Utils.addClass(this.elements.premiumCList,"hide");if(c.constructor!=Array){this.addOneRecord(c,1);this.currentProvider=c.provider;}else{for(var b=0,a=c.length;a>b;b++){this.addOneRecord(c[b],b+1);}this.currentProvider=c[0].provider;}Fp.Utils.removeClass(this.elements.premiumCList,"hide");Fp.Modules.toggleLoader();}},addOneRecord:function(d,b){if(d){var a=this.elements.template.cloneNode(true);var c="";if(b===1){c="first ";}if((b&1)===1){c=c+"odd";}if(c){a.className=c;}new Fp.Utils.Events.addTapEvent({element:a,onEvent:this.openPremiumPage});a.title=d.provider;if(a.children){a.children[0].src=d.providerIconUrl;a.children[1].innerHTML=d.providerDisplayName;a.children[2].children[0].innerHTML=d.description||Language["places.moreInformation"];this.elements.premiumCList.appendChild(a);}}},getPremiumUrl:function(b,c){if(b&&c){var a=(Fp.Settings.premiumServicesURLs[c])?Fp.Settings.premiumServicesURLs[c]:Fp.Settings.premiumDynamicURL;a+="&geox="+b.longitude;a+="&geoy="+b.latitude;a+="&name="+encodeURIComponent(b.name);a+="&language="+Fp.Lang.language;a+="&countrycode="+b.address.countryCode.toLowerCase();a+="&metric="+(b.distance.metric?1:0);a+="&uuid="+b.uuid;a+="&id="+b.placeId;a+="&width="+window.screen.width;a+="&height="+window.screen.height;a+="&mapsClient=true&entryPoint=2";a+="&city="+encodeURIComponent(b.address.city);a+="&provider="+c;return a;}return false;},openPremiumPage:function(f,b){var d=Fp.Modules.PremiumContent;var c=b.title.toLowerCase();d.currentProvider=c;var a=d.getPremiumUrl(Fp.POI,c);Fp.Utils.Iframe.open({url:a,callback:function(){Fp.Tracking.track("otherProvider");}});},clearContent:function(){this.elements.premiumCList.innerHTML="";this.currentProvider="";},refresh:function(){}};