function setupChart(){var t,r,i,n,u,f;if(chart=null,window.snl.ir.globalVars.models.financialCalculators!=undefined&&(t=window.snl.ir.globalVars.models.financialCalculators.chart,r=!0,window.Highcharts&&(r=!1),t.TotalReturnsCalculatorData.FormData!=null)){UpdateData(t.TotalReturnsCalculatorData.FormData[0]),i=new Date(t.TotalReturnsCalculatorData.FormData[0].TRStartDateFormatted),isNaN(i)&&(i=moment.utc(t.TotalReturnsCalculatorData.FormData[0].TRStartDateFormatted).toDate()),n=864e5,u=$("select[name=Frequency]").val().toLowerCase();switch(u){case"yearly":n=31536e6;break;case"monthly":n=2592e6;break;case"quarterly":n=7776e6;break;case"weekly":n=6048e5;break;default:n=n}t.Chart!=null&&(f={chartDiv:$("#stockchart"),loadStockScript:r,chartType:"area",xAxisType:"datetime",xAxisTypeFormat:"%m/%y",pointStart:Date.UTC(i.getFullYear(),i.getMonth(),i.getDate()),pointInterval:n,data:t.Chart,frequency:u},chart=new $.snl.ir.controls.chart(f))}}function UpdateData(n){$("#FromDate").val(moment(n.TRStartDateFormatted).format(shortDateFormat)),$("#ToDate").val(moment(n.TREndDateFormatted).format(shortDateFormat)),$("select[name=Frequency]").val(n.Frequency),$("select[name=Security]").val(n.Security)}function updatePageViewModel(){var n=window.snl.ir.globalVars.currentPageViewModel;n.BaseViewModel=$.snl.ir.models.financialCalculators.BaseViewModel,n.PageSettings=$.snl.ir.models.financialCalculators.PageSettings,n.TotalReturnsCalculatorData.TradedIssues=$.snl.ir.models.financialCalculators.TradedIssues,n.BasisCalculatorData==null&&(n.BasisCalculatorData=$.snl.ir.models.financialCalculators.BasisCalculatorData)}function getInternetExplorerVersion(){var i=-1,n,t;return navigator.appName=="Microsoft Internet Explorer"?(n=navigator.userAgent,t=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"),t.exec(n)!=null&&(i=parseFloat(RegExp.$1))):navigator.appName=="Netscape"&&(n=navigator.userAgent,t=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),t.exec(n)!=null&&(i=parseFloat(RegExp.$1))),i}var _urlFinancialCalculatorsBase=$.snl.ir.models.api.urlTemplate.replace("{Controller}","FinancialCalculators"),_urlBasisCalculatorData=_urlFinancialCalculatorsBase.replace("{Action}","GetBasisCalcData"),_urlTotalReturnCalculatorData=_urlFinancialCalculatorsBase.replace("{Action}","GetTotalReturnCalcData")+"?pageIndex={pageIndex}";$.snl.ir.models.api.financialCalculators={},$.snl.ir.models.financialCalculators={},$.snl.ir.models.api.financialCalculators.getBasisCalculatorData=function(n,t){$.post(_urlBasisCalculatorData,n).done(function(n){$.snl.ir.models.financialCalculators.financialCalculatorsData=n,t()}).fail(function(){}).always(function(){})},$.snl.ir.models.api.financialCalculators.getTotalReturnCalculatorData=function(n,t,i){var r=_urlTotalReturnCalculatorData.replace("{pageIndex}",n);$.post(r,t).done(function(n){$.snl.ir.models.financialCalculators.financialCalculatorsData=n,i()}).fail(function(){}).always(function(){})};var chart,shortDateFormat,getBasisCalculatorData=function(n){$.snl.ir.models.api.financialCalculators.getBasisCalculatorData(n,populateBasisCalculatorData)},getTotalReturnCalculatorData=function(n,t){$.snl.ir.models.api.financialCalculators.getTotalReturnCalculatorData(n,t,populateTotalReturnCalculatorData)},populateBasisCalculatorData=function(){var n=$.snl.ir.models.financialCalculators.financialCalculatorsData;n.trim().length>0&&($("#BCData").html(n),$("#BCData").css("opacity","1"),$(".irwScrollbar").mCustomScrollbar({theme:"bootstrap-thin",advanced:{updateOnContentResize:!0}})),$.snl.ir.models.financialCalculators.BasisCalculatorData=window.snl.ir.globalVars.currentPageViewModel.BasisCalculatorData,updatePageViewModel()},populateTotalReturnCalculatorData=function(){var n=$.snl.ir.models.financialCalculators.financialCalculatorsData;n.trim().length>0&&($("#TRData").html(n),$("#TRData").css("opacity","1"),$(".irwScrollbar").mCustomScrollbar({theme:"bootstrap-thin",advanced:{updateOnContentResize:!0}}),setupChart()),updatePageViewModel()},submitForm=function(n,t){var i;return n==undefined&&(n=0),t=="BasisCalculator"?(i=$("#basisfrom").serialize(),getBasisCalculatorData(i)):t=="TotalReturnCalculator"&&(i=$("#totalreturnform").serialize(),getTotalReturnCalculatorData(n,i)),!1};$(document).ready(function(){shortDateFormat=window.snl.ir.globalVars.currentPageViewModel.BaseViewModel.shortDateformat.toUpperCase();$("#basisfrom").bootstrapValidator({message:"This value is not valid",live:"disabled",trigger:"change",fields:{Price:{validators:{numeric:{message:"Please enter numbers only"}}},DateOfPurchase:{validators:{callback:{message:"Invalid date entered",callback:function(n){return moment(n,shortDateFormat,!0).isValid()}}}}}}).on("success.form.bv",function(n){return $("#BCData").css("opacity","0.5"),n.preventDefault(),submitForm(0,"BasisCalculator")});$("#totalreturnform").bootstrapValidator({message:"This value is not valid",live:"disabled",trigger:"change",fields:{Price:{validators:{notEmpty:{},numeric:{message:"Please enter numbers only"}}},FromDate:{validators:{callback:{message:"Invalid date entered",callback:function(n){return moment(n,shortDateFormat,!0).isValid()}}}},ToDate:{validators:{callback:{message:"Invalid date entered",callback:function(n){return moment(n,shortDateFormat,!0).isValid()}}}}}}).on("success.form.bv",function(n){return $("#TRData").css("opacity","0.5"),n.preventDefault(),submitForm(0,"TotalReturnCalculator")});window.snl.ir.globalVars.currentPageViewModel.BaseViewModel.IsPrintMode&&(window.snl.ir.globalVars.currentPageViewModel.Chart!=null&&$("#stockchart").html(""),UpdateData(window.snl.ir.globalVars.currentPageViewModel.TotalReturnsCalculatorData.FormData[0]));var n=window.snl.ir.globalVars.currentPageViewModel;$.snl.ir.models.financialCalculators.BaseViewModel=n.BaseViewModel,$.snl.ir.models.financialCalculators.PageSettings=n.PageSettings,$.snl.ir.models.financialCalculators.TradedIssues=n.TotalReturnsCalculatorData.TradedIssues}),$(document).delegate(".pagination button","click",function(){$(".irwTotalCalData2").css("opacity","0.5");var t=$("button[name="+this.name+"]").hasClass("btn disabled");t==!1&&submitForm(this.name,"TotalReturnCalculator")}),$(function(){$("#FromDate").datepicker({dateFormat:datepickerformat(window.snl.ir.globalVars.currentPageViewModel.BaseViewModel.shortDateformat),showOn:"focus",closeAtTop:!1,showStatus:!0,maxDate:"d",yearRange:"1980:"+(new Date).getFullYear(),changeMonth:!0,changeYear:!0,fixFocusIE:!1,beforeShow:function(){var i=getInternetExplorerVersion()<0?!0:!this.fixFocusIE;return this.fixFocusIE=!1,i},onSelect:function(){this.fixFocusIE=!0,$(this).change().focus()},onClose:function(){this.fixFocusIE=!0,$(this).focus()}}),$("#ToDate").datepicker({dateFormat:datepickerformat(window.snl.ir.globalVars.currentPageViewModel.BaseViewModel.shortDateformat),showOn:"focus",closeAtTop:!1,showStatus:!0,maxDate:"d",yearRange:"1980:"+(new Date).getFullYear(),changeMonth:!0,changeYear:!0,fixFocusIE:!1,beforeShow:function(){var i=getInternetExplorerVersion()<0?!0:!this.fixFocusIE;return this.fixFocusIE=!1,i},onSelect:function(){this.fixFocusIE=!0,$(this).change().focus()},onClose:function(){this.fixFocusIE=!0,$(this).focus()}}),$("#DateOfPurchase").datepicker({dateFormat:datepickerformat(window.snl.ir.globalVars.currentPageViewModel.BaseViewModel.shortDateformat),showOn:"focus",closeAtTop:!1,showStatus:!0,maxDate:"d",yearRange:"1980:"+(new Date).getFullYear(),changeMonth:!0,changeYear:!0,fixFocusIE:!1,beforeShow:function(){var i=getInternetExplorerVersion()<0?!0:!this.fixFocusIE;return this.fixFocusIE=!1,i},onSelect:function(){this.fixFocusIE=!0,$(this).change().focus()},onClose:function(){this.fixFocusIE=!0,$(this).change().focus()}})}),$("#ToDateGroup").click(function(){$("#ToDate").datepicker("show")}),$("#FromDateGroup").click(function(){$("#FromDate").datepicker("show")}),$("#DateOfPurchaseGroup").click(function(){$("#DateOfPurchase").datepicker("show")}),window.snl.ir.globalVars.exportCallback=function(n){chart!=null&&(n.Chart.SVG=chart.getSVG())},$.snl.ir.controls.chart=function(n){function rt(n){var h=n.loadStockScript?n.loadStockScript:!1,r=$.snl.ir.GetConfiguration("Chart.xml",n.configUrlQueryArgs).Chart;$.preferCulture(g),chartDiv=n.chartDiv,t=n.chartConfig,l=n.chartType,i=n.data,e=n.xAxisType?n.xAxisType:e,w=n.height,b=n.width,o=n.xAxisTypeFormat,k=n.pointStart,d=n.pointInterval,u=n.events,nt=n.frequency,s=n.stacking==0?null:s,c=n.marginRight==0?null:c,$.each(i.Series,function(n,t){data=[],$.each(t.Values,function(n,r){var u={};if(t.IsDrillDown)data[n]=[r.Key,r.Value];else{if(n==0&&r.Value==0?u.y=null:(u.key=r.Key,u.y=r.Value,u.name=r.Name),i.EnableDrillDown&&(u.drilldown=r.Drilldown,u.name=r.Name),r.TransparentColumn){var f=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t.Color.trim()),e=f?parseInt(f[1],16):0,o=f?parseInt(f[2],16):0,s=f?parseInt(f[3],16):0;u.color="rgba("+e+","+o+","+s+",0.30)"}data.push(u)}}),p=Math.max(p,data.length),it.push(t.Name);var r={name:t.Name,id:t.Id,data:data,color:t.Color,showInLegend:t.ShowInLegend,type:t.Type,yAxis:t.YAxisIndex,marker:{enabled:!0,lineColor:null}};t.IsDrillDown?v.push(r):a.push(r)}),$.each(i.YAxis,function(t,i){y.push({title:{text:i.Title,style:{fontWeight:"normal",backgroundColor:"#fff"}},labels:{format:n.pointValueFormat?n.pointValueFormat:"{value:,.2f}",formatter:function(){return $.format(this.value,"n2")}},opposite:i.IsOpposite,showEmpty:!1})}),h?$.when($.getScript($.snl.ir.vars.siteURL+"Scripts/Highstock/js/highstock.js").fail(f)).done(function(){$.when($.getScript($.snl.ir.vars.siteURL+"Scripts/Highstock/js/modules/drilldown.js").fail(f),$.getScript($.snl.ir.vars.siteURL+"Scripts/Highstock/js/modules/exporting.js").fail(f)).then(function(){tt(r)},f)}):tt(r)}function f(n,t,i){$.snl.ir.Log(i)}function tt(n){var f=Highcharts.setOptions({});$(chartDiv).highcharts({lang:{drillUpText:"◁"},credits:{text:"S&P Global Market Intelligence",href:"http://www.spglobal.com/marketintelligence",enabled:n.DisableCredits&&n.DisableCredits.toLowerCase()=="true"?!1:!0},drilldown:{drillUpButton:{relativeTo:"spacingBox",position:{y:2,x:3}}},chart:{type:l,height:w,width:b,marginRight:c,backgroundColor:n.BackgroundColor?n.BackgroundColor:i.BackgroundColor,borderColor:n.BorderColor?n.BorderColor:null,borderRadius:n.BorderRadius?n.BorderRadius:null,events:{load:function(){this.credits.element.onclick=function(){window.open("http://www.spglobal.com/marketintelligence","_blank")},r.chart=this,u&&u.loadCallBack&&u.loadCallBack()},drilldown:function(){r.chart.xAxis[0].options.tickInterval=i.XAxis.DrilldownTickInterval,h=!0},drillup:function(){r.chart.xAxis[0].options.tickInterval=i.XAxis.TickInterval,h=!1}}},subtitle:{text:n.SubTitle?n.SubTitle:null},title:{text:n.Title?n.Title:i.Title},tooltip:{enabled:n.DisableTooltip&&n.DisableTooltip.toLowerCase()=="true"?!1:!0,borderColor:n.TooltipBorderColor?n.TooltipBorderColor:t&&t.toolTip&&t.toolTip.borderColor?t.toolTip.borderColor:null,backgroundColor:n.TooltipBackgroundColor?n.TooltipBackgroundColor:null,borderRadius:n.TooltipBorderRadius?n.TooltipBorderRadius:null,useHTML:n.UseHTML?n.UseHTML:t&&t.toolTip&&t.toolTip.useHTML?t.toolTip.useHTML:!1,style:n.TooltipStyle?n.TooltipStyle:t&&t.toolTip&&t.toolTip.style?t.toolTip.style:f.tooltip.style,formatter:function(){var r,e,u,f;return e=i.XAxis.Categories?this.point.key:this.point.name,f=t&&t.toolTip&&t.toolTip.pointValueDecimalPlaces?t.toolTip.pointValueDecimalPlaces():this.point.y.toString().indexOf(".")>0?2:0,u=$.format(this.point.y,"n"+f),u=u.indexOf("-")==0?''+(g.toLowerCase()=="en-us"?"("+u.replace("-","")+")":u)+"<\/span>":u,r=n.TooltipHeader,r+=n.TooltipBody,r=r.replace("{pointValueFormatted}",u),r=r.replace("{pointName}",e),r=r.replace("{this.series.name}",this.series.name),r=r.replace("{this.point.name}",this.point.name),r=r.replace("{this.point.y}",this.point.y)}},xAxis:{type:e,title:{text:i.XAxis.Title,style:{fontWeight:"normal"}},tickInterval:i.XAxis.TickInterval>0?i.XAxis.TickInterval:nt=="yearly"?31536e6:null,labels:{format:o?"{value:"+o+"}":""},categories:i.XAxis.Categories?i.XAxis.Categories:null},yAxis:y,plotOptions:{area:{turboThreshold:0},column:{stacking:s},series:{dataLabels:{enabled:!1,color:"#FFFFFF"},pointStart:k,pointInterval:d,shadow:!1}},legend:{align:n.LegendAlign?n.LegendAlign:null,layout:n.LegendLayout?n.LegendLayout:null,verticalAlign:"bottom",borderColor:"#CCC",shadow:!1,enabled:n.DisableLegend&&n.DisableLegend.toLowerCase()=="true"?!1:!0,title:{text:n.LegendTitle?n.LegendTitle:null,style:{color:n.LegendTextColor?n.LegendTextColor:null}}},series:a,drilldown:{series:v},navigation:{buttonOptions:{enabled:!1}}})}var r=this,ut,ft,l,i,t,u,a=[],v=[],it=[],y=[],p=0,et,e="category",w,b,o,k,d,s="normal",h=!1,c=35,g=window.snl.ir.globalVars.currentPageViewModel.BaseViewModel.CurrentCulture,nt="daily";r.exportChart=function(n,t){var i=r.chart;r.chart.exportChart(n,t),r.chart=i},r.getSVG=function(){var n=r.chart,t=r.chart.getSVG();return r.chart=n,t},r.getIsDrillDown=function(){return h},rt(n)}