function switchToStructuredView(){Cookies.set("FicheView","structured",{path:"/"}),$("#changeFiche").attr("data-original-title",btnFicheViewComplete),$("#changeFiche").toggleClass("isActive"),tabDocuments?(tabDocuments.prependTo($("#stepDetailContent")),tabDocuments=null):($("#paneResults").append($("#section-results").html()),$("#paneRequirements").append($("#section-requirements").html()),$("#paneLaws").append($("#section-laws").html())),tabGeneral?(tabGeneral.prependTo($("#stepDetailContent")),tabGeneral=null):($("#paneContact").append($("#section-contacts").html()),$("#paneAdditionalInfo").append($("#section-additional").html()),$("#paneRecourse").append($("#section-recourse").html())),contactSection=$("#section-contacts").detach(),resultsSection=$("#section-results").detach(),requirementsSection=$("#section-requirements").detach(),lawsSection=$("#section-laws").detach(),additionalSection=$("#section-additional").detach(),recourseSection=$("#section-recourse").detach(),$(".costDetailsStructured").attr("data-content",$("#section-costs").html()),costSection=$("#section-costs").detach(),$("#ficheStep").addClass("structured")}function switchToFlowView(){Cookies.set("FicheView","flow",{path:"/"}),$("#changeFiche").attr("data-original-title",btnFicheViewStructured),$("#changeFiche").toggleClass("isActive"),lawsSection||(lawsSection=$("#section-laws").append($("#paneLaws").html())),lawsSection.appendTo($("#stepDetailContent")),additionalSection||(additionalSection=$("#section-additional").append($("#paneAdditionalInfo").html())),additionalSection.appendTo($("#stepDetailContent")),costSection||(costSection=$("#section-costs").append($(".costDetailsStructured").attr("data-content"))),costSection.prependTo($("#stepDetailContent")),requirementsSection||(requirementsSection=$("#section-requirements").append($("#paneRequirements").html())),requirementsSection.prependTo($("#stepDetailContent")),resultsSection||(resultsSection=$("#section-results").append($("#paneResults").html())),resultsSection.prependTo($("#stepDetailContent")),contactSection||(contactSection=$("#section-contacts").append($("#paneContact").html())),contactSection.prependTo($("#stepDetailContent")),$("<div class='clearfix'><\/div>").prependTo($("#stepDetailContent")),recourseSection||(recourseSection=$("#section-recourse").append($("#paneRecourse").html())),recourseSection.appendTo($("#stepDetailContent")),tabGeneral=$("#generalInfoTab").detach(),tabDocuments=$("#documentsTab").detach(),$("#ficheStep").removeClass("structured")}function calculateTotalStepCosts(){var t=0,i=0,r,u;$(".costCalculatedVal").each(function(n,r){var f=$(r).closest(".costValue").find(".costCalculatedUnit").text(),u=$(r).attr("data-value").replace(/\,/g,"");$.trim(f)==="USD"?t+=parseFloat($.trim(u)):i+=parseFloat($.trim(u))}),r=i.formatMoney(2,",","."),u=t.formatMoney(2,",","."),$(".summary-cost-sum").length>0&&($(".summary-cost-sum").find(".totalLocal").text(r),$(".summary-cost-sum").find(".totalLocal").attr("data-value",i),$(".summary-cost-sum").find(".totalUSD").text(u),$(".summary-cost-sum").find(".totalUSD").attr("data-value",t),currencyConverter.convertTotal(currencyConverter.currentCurrency),currencyConverter.convertDetails(currencyConverter.currentCurrency))}function validateInput(n){var t=$.trim(n);return isNaN(t/1)!==!0}function openStepFeedback(n,t,i,r,u,f){var e=curUrl;return i>0&&(e=e.replace("index.aspx","page1.aspx"),e=e+"?lang="+t,e=e+"&showObjectives="+DisplayObjectTree,e=e+"&id="+u,e=e+"&sectionid="+r,e=e+"&stepid="+f,e=e+"&type="+i+"&sendFromStep=true"),hs.htmlExpand(n,{src:e,objectLoadTime:"before",objectType:"iframe",dimmingOpacity:.75,width:800,height:550,align:"center",dragByHeading:!1}),!1}function printPage(n){return hs.htmlExpand(n,{width:550,height:250,top:10,dimmingOpacity:.75,contentId:"hgContent"}),!1}function switchReqsInit(){$(".switchers .reqSwitcher").each(function(){var n=$(this).attr("id"),t=parseInt(n.match(/\d+$/)[0],10);switchReqs(t)})}function switchReqs(n){if($("#reqSwitcher"+n).hasClass("reqSwitcherOn")){var t=!0;n!=="11"||$("#reqSwitcher12").hasClass("reqSwitcherOn")||(t=!1),n!=="12"||$("#reqSwitcher11").hasClass("reqSwitcherOn")||(t=!1),t&&($(".grp"+n).hide(),$("#reqSwitcher"+n).removeClass("reqSwitcherOn"))}else $("#reqSwitcher"+n).addClass("reqSwitcherOn"),$(".grp"+n).show();return $("#reqSwitcher11").hasClass("reqSwitcherOn")||$(".grp11").hide(),$("#reqSwitcher12").hasClass("reqSwitcherOn")||$(".grp12").hide(),!1}function switchContact(n,t){return $(".regional-"+t).hide(),$(".contact-switcher-"+n).toggleClass("reqSwitcherOn"),$(".contactSwitcher.reqSwitcherOn").each(function(){var t=$(this).attr("id").replace("contact-switcher-","");$(".region-"+t).show()}),!1}var CurrencyConverter,currencyConverter,contactSection,additionalSection,recourseSection,resultsSection,requirementsSection,costSection,lawsSection,tabGeneral,tabDocuments,$costHypotesis;Number.prototype.formatMoney=function(n,t,i){var f=this,o=f<0?"-":"",e=parseInt(f=Math.abs(+f||0).toFixed(n))+"",r=(r=e.length)>3?r%3:0,u;return n=isNaN(n=Math.abs(n))?2:n,i=i===undefined?".":i,t=t===undefined?",":t,u=o+(r?e.substr(0,r)+t:"")+e.substr(r).replace(/(\d{3})(?=\d)/g,"$1"+t)+(n?i+Math.abs(f-e).toFixed(n).slice(2):""),this%1==0&&(u=u.substr(0,u.length-n-1)),u},CurrencyConverter=function(){},CurrencyConverter.prototype.container=$(".currency-selector"),CurrencyConverter.prototype.currentCurrency="",CurrencyConverter.prototype.conversionRates=[],CurrencyConverter.prototype.localCurrency=localCurrency,CurrencyConverter.prototype.foreignStandardCurrency="USD",CurrencyConverter.prototype.supportedCurrencies=supportedCurrencies&&supportedCurrencies.length?supportedCurrencies:[],CurrencyConverter.prototype.foreignCurrencies=supportedCurrencies.filter(function(n){return n!=localCurrency}),CurrencyConverter.prototype.init=function(){var n=this,t="";sessionStorage.selectedCurrency&&(t=sessionStorage.selectedCurrency),this.setCurrency(t),this.setCurrencyOptions(),$.when.apply(null,this.initConversionValues()).always(function(){n.registerEvents(),n.convertTotal(n.currentCurrency),n.convertDetails(n.currentCurrency)})},CurrencyConverter.prototype.setCurrency=function(n){n=n||localCurrency;var t=this.container.find(".selected-value");t.empty(),t.append("<i class='currency-flag currency-flag-"+n.toLowerCase()+"'><\/i> <b>"+n+"<\/b>"),sessionStorage.setItem("selectedCurrency",n),this.currentCurrency=n},CurrencyConverter.prototype.setCurrencyOptions=function(){var n=$(".currency-selector .options");n.empty(),this.supportedCurrencies.forEach(function(t){n.append("<li data-currency='"+t+"'><i class='currency-flag currency-flag-"+t.toLowerCase()+"'><\/i> <b>"+t+"<\/b><\/li>")})},CurrencyConverter.prototype.toggleSelector=function(){this.container.toggleClass("opened")},CurrencyConverter.prototype.initConversionValues=function(){var n=this,i=eRegulations?eRegulations.CURRENCY_API_KEY:"",r="&compact=ultra&apiKey="+i,t;return i||$(".currency-selector").hide(),t=this.foreignCurrencies.map(function(t){return{from:n.localCurrency,to:t}}).concat(this.foreignCurrencies.map(function(t){return{from:n.foreignStandardCurrency,to:t}})).concat(this.foreignCurrencies.map(function(){return{from:n.foreignStandardCurrency,to:n.localCurrency}})).concat(this.foreignCurrencies.map(function(t){return{from:t,to:n.localCurrency}})),t=t.filter(function(n){return n.from!==n.to}),t.map(function(t){var i=t.from+"_"+t.to,u="https://api.currconv.com/api/v6/convert?q="+i+r;return $.ajax({url:u,method:"GET",success:function(r){n.conversionRates.push({from:t.from,to:t.to,value:r[i]})}})})},CurrencyConverter.prototype.convertTotal=function(n){var i=0,r=0,t;$(".summary-cost-sum .totalLocal").length&&(i=parseFloat($(".summary-cost-sum .totalLocal").attr("data-value").split(",").join(""))),$(".summary-cost-sum .totalUSD").length&&(r=parseFloat($(".summary-cost-sum .totalUSD").attr("data-value").split(",").join("")));var u=1,f=1,e=0,o=this;n==this.localCurrency&&r==0||n!=this.localCurrency&&n==this.foreignStandardCurrency&&i==0?(t="",i&&(t+=this.localCurrency+" "+i.formatMoney(2,",",".")),r&&(t+=t?" + ":"",t+=this.foreignStandardCurrency+" "+r.formatMoney(2,",",".")),$(".summary-cost-sum .totalConverted").html(t),t==""?$("span.total-nb").hide():$("span.total-nb").show(),$("span.total-sum").hide()):(u=this.conversionRates.filter(function(t){return t.from==o.localCurrency&&t.to==n}),u=u[0]?parseFloat(u[0].value):1,f=this.conversionRates.filter(function(t){return t.from==o.foreignStandardCurrency&&t.to==n}),f=f[0]?parseFloat(f[0].value):1,e=i*u+r*f,e=e.formatMoney(2,",","."),$(".summary-cost-sum .totalConverted").html(this.currentCurrency+" "+e),e==0?$("span.total-nb").hide():$("span.total-nb").show(),$("span.total-sum").show()),eRegulations.isRTL&&changeNumerals()},CurrencyConverter.prototype.convertDetails=function(n){var f=this,r=0,u=0,t=1,i=1,e=0,o=0;$(".summary-cost-sum .totalLocal").length&&(e=parseFloat($(".summary-cost-sum .totalLocal").attr("data-value").split(",").join(""))),$(".summary-cost-sum .totalUSD").length&&(o=parseFloat($(".summary-cost-sum .totalUSD").attr("data-value").split(",").join(""))),n==this.localCurrency&&o==0||n!=this.localCurrency&&n==this.foreignStandardCurrency&&e==0?($(".costCalculatedConverted").addClass("hidden"),$(".costCalculatedConverted .costDetail").remove()):$(".costCalculatedVal").each(function(){var s=$(this).siblings(".costCalculatedUnit").html(),o=parseFloat($(this).attr("data-value").split(",").join(""))||0,e;s==="USD"?(i=f.conversionRates.filter(function(t){return t.from==f.foreignStandardCurrency&&t.to==n}),i=i[0]?parseFloat(i[0].value):1,r=i*o):(t=f.conversionRates.filter(function(t){return t.from==f.localCurrency&&t.to==n}),t=t[0]?parseFloat(t[0].value):1,r=t*o),e=$(this).siblings(".costCalculatedConverted"),e.find(".costCalculatedConvertedUnit").html(n),r=r.formatMoney(2,",","."),e.find(".costCalculatedConvertedValue").html(r),e.removeClass("hidden"),$(this).parents(".costDetails").find(".costDetail").length&&(e.find(".costDetail").remove(),e.find(".separator").show(),$(this).parents(".costDetails").find(".costDetail").clone().appendTo(e),e.find(".costDetail .costCalculatedUnit").html(n),parseFloat(e.find(".costDetail .numeral").attr("data-value"))&&(o=parseFloat(e.find(".costDetail .numeral").attr("data-value").split(",").join(""))||0,u=s==="USD"?i*o:t*o,u=u.formatMoney(2,",","."),e.find(".costDetail .numeral").html(u)))}),eRegulations.isRTL&&changeNumerals()},CurrencyConverter.prototype.registerEvents=function(){var n=this;this.container.find(".toggle").on("click",function(){n.toggleSelector()});this.container.find(".options li").on("click",function(){var t=$(this).data("currency");n.setCurrency(t),n.convertTotal(t),n.convertDetails(t),n.toggleSelector()})},currencyConverter=new CurrencyConverter,$(currencyConverter.init());$(".currency-selector").on("click",function(n){n.stopPropagation()});$("#listSteps").children(".block-step-container").collapse("show"),$("#listSteps").children(".row-block").addClass("opened"),$("#stepDetailContent").find(".stepContent").length===0&&($("#changeFiche").hide(),$("#stepDetailContent").prepend("<div class='clearfix'><\/div><div class='box flow' style='margin-top:10px; font-size:14px;'>"+msgStepInDocumentationProcess+"<\/div>")),$("[rel=tooltip]").tooltip(),$("a[data-toggle='popover']").popover({html:!0}).click(function(n){n.preventDefault()}),$("[data-toggle='tooltip']").tooltip({container:"#ficheStep"});$("#changeFiche").on("click",function(n){n.preventDefault(),$(this).data("mode")===1?(switchToStructuredView(),$(this).data("mode",0)):(switchToFlowView(),$(this).data("mode",1))});$(document).on("click",function(n){var i=$(".costostable").closest(".popover"),t;n.target.className!=="costDet"&&i.has(n.target).length===0&&$("a.costDetailsPop").popover("hide"),t=$(".timeframePopOver").closest(".popover"),n.target.className!=="timeFrameDet"&&t.has(n.target).length===0&&$("a.timeFrameDetails").popover("hide")});$costHypotesis=$(".costHypotesis");$costHypotesis.on("click",".editValue",function(n){var f,e;n.preventDefault();var r=$(this).closest("td"),i=r.find(".editableValue"),t={};if(t.initialAverageValue=parseFloat(i.attr("data-initialavgvalue")).toFixed(4),t.costOperator=i.attr("data-costOperator"),t.costValue=i.attr("data-costValue"),t.editableFieldId=i.attr("data-costId"),t.param=i.closest("td").find(".hypoLabel").text(),f=$("#averageCostEditTmpl").html(),e=_.template(f),r.html(e(t)),eRegulations.isRTL){var u=r.find("input.editableValue"),o="",h=u.val(),s=u.val().toString();o=s.replace(/\d/g,function(n){if(numeralMap[n])return String.fromCharCode(numeralMap[n].charCodeAt(0))}),u.val(o)}return $("input.editableValue",r).focus(),!1});$costHypotesis.on("click",".calculateCost",function(n){var e,u,o,l,r,v,y;n.preventDefault();var p=$(this).closest("td"),f=$(this).attr("data-costId"),w=$(this).closest(".cost").find(".costCalculatedUnit").first().text(),t=$(this).closest("td").find(".editableValue[data-costId='"+f+"']"),a=t.val(),b=parseFloat(t.val()),i="";if(eRegulations.isRTL)for(e=a.toString(),u=0;u<e.length;u++){e.charAt(u)=="."&&(i+=".");for(o in numeralMap)e.charAt(u)==numeralMap[o]&&(i+=o)}else i=a;if(t.attr("data-value",i),validateInput(i)){t.removeClass("error");var s=parseFloat(t.attr("data-costValue")),h=t.attr("data-costOperator"),c=0;h==="multiply"?c=s*i:h==="percentage"&&(c=s*i/100),l=c.formatMoney(2,",","."),$(".costCalculatedVal[data-costId='"+f+"']").html(l),$(".costCalculatedVal[data-costId='"+f+"']").attr("data-value",l),r={},r.initialAverageValue=parseFloat(i).toFixed(2),r.costOperator=h,r.costValue=parseFloat(s).toFixed(2),r.editableFieldId=f,r.param=t.closest("td").find(".hypoLabel").text(),calculateTotalStepCosts(w),v=$("#averageCostReadOnlyTmpl").html(),y=_.template(v),p.html(y(r)),eRegulations.isRTL&&changeNumerals()}else t.addClass("error")});$costHypotesis.on("click",".cancelCalculation",function(n){var u,f;n.preventDefault();var r=$(this).closest("td"),i=r.find(".editableValue"),t={};return t.initialAverageValue=parseFloat(i.attr("data-initialavgvalue")).toFixed(2),t.costOperator=i.attr("data-costOperator"),t.costValue=parseFloat(i.attr("data-costValue")).toFixed(2),t.param=i.closest("td").find(".hypoLabel").text(),t.editableFieldId=i.attr("data-costId"),u=$("#averageCostReadOnlyTmpl").html(),f=_.template(u),r.html(f(t)),eRegulations.isRTL&&changeNumerals(),!1});$(".closeCostDetails").on("click",function(){return $("a.costDetailsPop").popover("hide"),!1});$(".closeTimeframeDetails").on("click",function(){return $("a.timeFrameDetails").popover("hide"),!1});$("input.editableValue").on("keydown",function(n){var t,i;return(n.charCode||n.keyCode)===13?(t=$(this).closest("tr"),i=$(".calculateCost",t),i.trigger("click"),!1):(n.charCode||n.keyCode)===27?(t=$(this).closest("tr"),i=$(".cancelCalculation",t),i.trigger("click"),!1):void 0});switchReqsInit(),switchReqs(DefaultRequirementsOption),$(".contactSwitcher.contact").removeClass("reqSwitcherOn"),$(".regional-contact").hide(),$(".regional-rec-contact").hide();$("#linkChangeStatus").on("click",function(){$("#changeStatus").show()});$("#linkcancelChangeStatus").on("click",function(){$("#changeStatus").hide()});window.initTickets=function(){var t=$("#stepListReviews").data("section"),n="/api/ticket/";$.getJSON(n+stepListPageId+"/"+t+"/"+(MenuId||null)+"/"+ProcedureId+"/0",function(n){var t=new TicketList,i;n!==null&&t.add(n),i=new TicketListView({collection:t,el:"#stepListReviews"})}).fail(function(n,t,i){$("#errorsPane").html("<span class='error'>"+i+"<\/span>").show()}),$("div.stepDet").each(function(t,i){var r=$(i).attr("id"),u=$(i).data("section");$.getJSON(n+pageId+"/"+u+"/"+(MenuId||null)+"/"+ProcedureId+"/"+StepId,function(n){var t=new TicketList,i;n!==null&&t.add(n),i=new TicketListView({collection:t,el:"#"+r})}).fail(function(n,t,i){$("#errorsPane").html("<span class='error'>"+i+"<\/span>").show()})})}