//Copyright © [Year(s)] Nokia Corporation and/or its subsidiary(-ies).
Fp.Menu.Report.IncorrectInformation=Fp.Utils.extendObject(Fp.Menu.Report,{type:"INCORRECT_INFORMATION",elements:null,mainCategories:null,subCategories:null,init:function(){this.elements={};this.elements.categoryList=Fp.byId("categoryList");this.elements.iNewName=Fp.byId("iNewName");this.elements.iNewPhoneNumber=Fp.byId("iNewPhoneNumber");this.elements.iNewEmail=Fp.byId("iNewEmail");this.elements.iNewFax=Fp.byId("iNewFax");this.elements.iNewCategory=Fp.byId("iNewCategory");this.elements.categoryVal=Fp.byId("categoryVal");this.setupEvents();},setupEvents:function(){new Fp.Utils.Events.addTapEvent({element:Fp.byId("menu-report-button-incorrect-information"),onEvent:Fp.Utils.bind(this.showPage,this)});new Fp.Utils.Events.addTapEvent({element:Fp.byId("report-incorrectinfo-submit"),onEvent:Fp.Utils.bind(this.post,this)});new Fp.Utils.Events.addTapEvent({element:Fp.byId("categorySelect"),onEvent:Fp.Utils.bind(Fp.Pages.showPage,Fp.Pages,{name:Fp.Pages.PAGE.SELECTIONLIST})});},showPage:function(){Fp.Pages.showPage({name:Fp.Pages.PAGE.REPORTINCORRECTINFO});this.initCategoriesList();this.fillContent(Fp.POI);},fillContent:function(a){this.clearContent();if(a){if(a.name){this.elements.iNewName.value=a.name;}if(a.contact&&a.contact.phone){this.elements.iNewPhoneNumber.value=a.contact.phone;}if(a.contact&&a.contact.email){this.elements.iNewEmail.value=a.contact.email;}if(a.contact&&a.contact.fax){this.elements.iNewFax.value=a.contact.fax;}if(this.mainCategories&&this.subCategories){if(a.category&&a.category.name){var b=this.getCategLabel(a.category.name);if(b){this.elements.iNewCategory.value=a.category.name;this.elements.categoryVal.innerHTML=b;}}this.elements.categoryList.style.display="block";}else{this.elements.categoryList.style.display="none";}return true;}return false;},clearContent:function(){this.elements.iNewName.value="";this.elements.iNewPhoneNumber.value="";this.elements.iNewEmail.value="";this.elements.iNewFax.value="";this.elements.iNewCategory.value="";this.elements.categoryVal.innerHTML="";},getReportValue:function(){var c=this.elements.iNewName.value;var f=this.elements.iNewCategory.value;var d=this.elements.iNewPhoneNumber.value;var b=this.elements.iNewFax.value;var e=this.elements.iNewEmail.value;var a="";if(c){a+="name:"+encodeURIComponent(c)+";";}if(f){a+="category:"+encodeURIComponent(f)+";";}if(d){a+="phone1:"+encodeURIComponent(d)+";";}if(b){a+="fax:"+encodeURIComponent(b)+";";}if(e){a+="email:"+encodeURIComponent(e)+";";}if(a!==""){return a;}else{return false;}},post:function(){var a=this.getReportValue();if(a){var b=Fp.Menu.Report.initIncident({reportType:this.type,reportValue:a});this.sendIncident(b);}},loadCategories:function(){if(this.mainCategories&&this.subCategories){return false;}var b={url:Fp.Settings.categoriesURL,method:Fp.Ajax.Method.GET,lang:Fp.Lang.language,exresp:Fp.Ajax.ExResponse.JSON,onSuccess:function(c,d){Fp.Menu.Report.IncorrectInformation.setCategories(d);},timeout:5};var a=new Fp.Ajax.Request(b);a.send();},setCategories:function(b){if(!b){return false;}var c=b.categories.group;this.mainCategories={};this.subCategories={};for(var a in c){this.mainCategories[c[a]["groupingCategory"]["name"]]=c[a]["groupingCategory"]["displayName"];this.subCategories[c[a]["groupingCategory"]["name"]]={name:c[a]["groupingCategory"]["displayName"],subcat:this.buildCategoryHash(c[a]["category"])};}},buildCategoryHash:function(a){var b={};for(var c in a){b[a[c]["name"]]=a[c]["displayName"];}return b;},getCategLabel:function(b){if(this.mainCategories[b]){return this.mainCategories[b];}for(var a in this.subCategories){var c=this.subCategories[a];if(c.subcat[b]){return c.name+" > "+c.subcat[b];}}return"";},initCategoriesList:function(){if(Fp.SelectionList.id!=="categories"){Fp.SelectionList.id="categories";}else{return;}var a=function(c){Fp.Pages.history.push({backCallback:b});Fp.SelectionList.id="";Fp.byId("header-title").innerHTML=Language["places.selectSubCategory"];Fp.byId("header-subtitle").innerHTML="";Fp.SelectionList.displayList(Fp.Menu.Report.IncorrectInformation.subCategories[c.id].subcat,function(d){Fp.Pages.history.pop();Fp.Pages.showPage({name:Fp.Pages.PAGE.REPORTINCORRECTINFO,fromHistory:true});Fp.byId("categoryVal").innerHTML=c.name+" > "+d.name;Fp.byId("iNewCategory").value=d.id;b();},{filtering:false,sort:true});};var b=function(){Fp.byId("header-title").innerHTML=Language["places.selectCategory"];Fp.byId("header-subtitle").innerHTML="";Fp.SelectionList.displayList(Fp.Menu.Report.IncorrectInformation.mainCategories,a,{filtering:false,multipage:true,sort:true});};b();}});