//Copyright © [Year(s)] Nokia Corporation and/or its subsidiary(-ies).
Fp.Menu.Report.WrongLocation=Fp.Utils.extendObject(Fp.Menu.Report,{type:"WRONG_LOCATION",setupEvents:function(){new Fp.Utils.Events.addTapEvent({element:Fp.byId("menu-report-button-wrong-location"),onEvent:Fp.Utils.bind(this.showPage,this)});new Fp.Utils.Events.addTapEvent({element:Fp.byId("report-wronglocation-submit"),onEvent:Fp.Utils.bind(this.submit,this)});new Fp.Utils.Events.addTapEvent({element:Fp.byId("countrySelect"),onEvent:function(){Fp.Pages.showPage({name:Fp.Pages.PAGE.SELECTIONLIST});if(Fp.SelectionList.input.value){Fp.SelectionList.input.value="";Fp.SelectionList.input.onkeyup();}Fp.SelectionList.input.focus();}});Fp.byId("iNewStreet").onkeydown=Fp.Utils.bind(this.toggleLocationSubmit,this);Fp.byId("iNewCity").onkeydown=Fp.Utils.bind(this.toggleLocationSubmit,this);},showPage:function(){Fp.Pages.showPage({name:Fp.Pages.PAGE.REPORTWRONGLOCATION});this.initCountriesList();this.fillContent(Fp.POI.address);},toggleLocationSubmit:function(){if(Fp.byId("iNewStreet").value&&Fp.byId("iNewCity").value&&Fp.byId("iNewCountry").value){Fp.Utils.removeClass(Fp.byId("report-wronglocation-submit"),"btnDisabled");}else{Fp.Utils.addClass(Fp.byId("report-wronglocation-submit"),"btnDisabled");}},submit:function(){this.post();},validate:function(b){var a="";if(!b.street||!b.number||!b.city||!b.country){return false;}a+="streetname:"+encodeURIComponent(b.street)+";";a+="number:"+encodeURIComponent(b.number)+";";a+="city:"+encodeURIComponent(b.city)+";";a+="country:"+encodeURIComponent(b.country)+";";if(b.zip){a+="postcode:"+encodeURIComponent(b.zip)+";";}return a;},getReportValue:function(){var b={street:Fp.byId("iNewStreet").value,number:Fp.byId("iNewNumber").value,zip:Fp.byId("iNewZip").value,city:Fp.byId("iNewCity").value,country:Fp.byId("iNewCountry").value};var a=this.validate(b);if(false==a){return false;}return a;},post:function(a){var a=this.getReportValue();if(a){var b=Fp.Menu.Report.initIncident({reportType:this.type,reportValue:a});this.sendIncident(b);}},initCountriesList:function(){if(Fp.SelectionList.id!=="countries"){Fp.SelectionList.id="countries";}else{return;}Fp.byId("header-title").innerHTML=Language["places.report.form.selectCountry"];Fp.byId("header-subtitle").innerHTML="";Fp.SelectionList.displayList(Fp.Lang.countryList,function(a){Fp.Pages.showPage({name:Fp.Pages.PAGE.REPORTWRONGLOCATION,fromHistory:true});Fp.byId("countryVal").innerHTML=a.name;Fp.byId("iNewCountry").value=a.id;},{filtering:false,sort:true,isCoutryList:true});},fillContent:function(a){Fp.byId("iNewStreet").value=a.street||"";Fp.byId("iNewNumber").value=a.houseNumber||"";Fp.byId("iNewZip").value=a.zipCode||"";Fp.byId("iNewCity").value=a.city||"";if(a.countryCode){Fp.byId("iNewCountry").value=a.countryCode;Fp.byId("countryVal").innerHTML=a.country||Language["places.report.form.selectCountry"];}this.toggleLocationSubmit();}});