//Copyright © [Year(s)] Nokia Corporation and/or its subsidiary(-ies).

Fp.Popup={initialized:false,infoElem:null,submitElem:null,choiceElem:null,popupElem:null,loaderElem:null,isOpen:false,closeTimeout:null,init:function(){this.initialized=true;this.infoElem=Fp.byId("popupInfo");this.submitElem=Fp.byId("popupSubmit");this.choiceElem=Fp.byId("popupChoice");this.popupElem=Fp.byId("popup");this.loaderElem=Fp.byId("ajax-loader");},openInfo:function(b){this.hideLoader();if(b){this._openVeil();Fp.byId("pInfoHeader").innerHTML=b.headerText||"";Fp.byId("pInfoContent").innerHTML=b.subText||"";var a=function(){if(Fp.Popup.closeTimeout){clearTimeout(Fp.Popup.closeTimeout);}if(b.onOk){b.onOk();}Fp.Pages.history=[];Fp.Pages.open({name:Fp.Pages.PAGE.MAIN});};this.infoElem.onclick=a;this.infoElem.style.display="table-cell";if(b.timeout){Fp.Popup.closeTimeout=setTimeout(a,3000);}}},openChoice:function(d){this.hideLoader();if(d){this._openVeil();Fp.byId("pChoiceHeader").innerHTML=d.headerText||"";Fp.byId("pChoiceContent").innerHTML=d.subText||"";var b=this,a=Fp.byId("pChoiceYes"),c=Fp.byId("pChoiceCancel");a.onclick=function(){b.close();if(d.onOk){d.onOk();}};c.onclick=function(){b.close();if(d.onCancel){d.onCancel();}};this.choiceElem.style.display="table-cell";}},openSubmit:function(c){if(c){this._openVeil();var b=this,a=Fp.byId("pSubmitBtn");a.onclick=function(){b.close();if(c.onOk){c.onOk();}};Fp.byId("pSubmitHeader").innerHTML=c.headerText||"";Fp.byId("pSubmitContent").innerHTML=c.subText||"";this.submitElem.style.display="block";}},showLoader:function(){this.loaderElem.style.display="table-cell";Fp.byId("page").style.display="none";},hideLoader:function(a){this.loaderElem.style.display="none";if(!a){Fp.byId("page").style.display="block";}},_openVeil:function(){if(!this.initialized){return;}if(this.isOpen){this.close();}this.popupElem.style.display="block";this.isOpen=true;},_closeVeil:function(){this.popupElem.style.display="none";this.isOpen=false;},close:function(){this.infoElem.style.display="none";this.submitElem.style.display="none";this.choiceElem.style.display="none";Fp.byId("pChoiceHeader").innerHTML="";Fp.byId("pChoiceContent").innerHTML="";Fp.byId("pInfoHeader").innerHTML="";Fp.byId("pInfoContent").innerHTML="";this._closeVeil();}};