//Copyright © [Year(s)] Nokia Corporation and/or its subsidiary(-ies).
Fp.Menu.Contact={elemIdPrefix:"menu-contact-",hideClass:"visible",contactDetailsPresent:false,buttons:[{name:"phone",hook:Fp.Api.C2Aid.DIAL,trackingFunc:"telephoneClicked"},{name:"email",hook:Fp.Api.C2Aid.MAILTO,trackingFunc:"emailClicked"},{name:"website",hook:Fp.Api.C2Aid.BROWSE,trackingFunc:"websiteClicked"}],init:function(){this.setupEvents();},setupEvents:function(){for(var b=0,a=this.buttons.length;b<a;b++){new Fp.Utils.Events.addTapEvent({element:Fp.byId(this.elemIdPrefix+this.buttons[b].name),onEvent:Fp.Utils.bind(this.fireAction,this,[this.buttons[b]])});}},fillContent:function(b){if(!b||!b.contact||!this.checkValues(b)){this.contactDetailsPresent=false;return false;}this.contactDetailsPresent=true;var d;for(var c=0,a=this.buttons.length;c<a;c++){d=("website"==this.buttons[c].name)?Fp.Utils.cleanUrl(b.contact.website):b.contact[this.buttons[c].name];this.toggleButton({id:this.buttons[c].name,value:d});}},toggleButton:function(a){if(!a||!a.id){return false;}var b=Fp.byId(this.elemIdPrefix+a.id);if(!b){return false;}if(a.value){b.innerHTML=a.value;Fp.Utils.addClass(b,this.hideClass);}else{b.innerHTML="";Fp.Utils.removeClass(b,this.hideClass);}return true;},fireAction:function(b){if(!b&&!b.hook){return false;}var a=function(){Fp.Api.fireC2A({hook:b.hook,param:{contact:Fp.POI.contact[b.name]}});};if(b.trackingFunc&&Fp.Tracking.trackingOn){Fp.Tracking.track(b.trackingFunc,{callback:function(){a();}});}else{a();}},checkValues:function(b){var d=0,a=this.buttons.length;for(var c=0;c<a;c++){d+=(b.contact[this.buttons[c].name])?0:1;}return(d===a)?false:true;}};