function mobiView(index){
    var perIndex=index;
	$('.performaceTable'+perIndex).each(function(){

    var availRows=$(this).find(".cumlativeCol").length;

	$(this).find(".cumulativeId").attr("colspan",availRows);
    console.log("available columns:"+availRows);


	if(availRows==2){
		$(this).find(".cumulativeId .leftrund").css({"margin-left":"52px"});
		$(this).find(".cumulativeId .rightrund").css({"margin-right":"35px"});
        $(".col-lg-10 .cumulativeId .leftrund").css({"margin-left":"10px"});
		$(".col-lg-10 .cumulativeId .rightrund").css({"margin-right":"10px"});
        $(".funddetailspage .cumulativeId .leftrund").css({"margin-left":"35px"});
         $(".col-lg-12 .cumulativeId .leftrund").css({"margin-left":"35px"});

	}
	if(availRows==1){
		$(this).find(".leftrund").remove();
        $(this).find(".rightrund").remove();
	}
	var aarRows=$(this).find(".aarCol").length;
	$(this).find(".aarId").attr("colspan",aarRows);
	if(aarRows==5){
		$(this).find(".leftrundlg").css("width","123px");
        $(this).find(".rightrundlg").css("width","123px");
	}
	if(aarRows==4){
		$(this).find(".leftrundlg").css({"width":"87px","margin-left":"47px"});
		$(this).find(".rightrundlg").css("width","95px");
	}
	if(aarRows==3){
        $(this).find(".leftrundlg").css({"width":"40px","margin-left":"72px"});
		$(this).find(".rightrundlg").css({"width":"50px","margin-right":"58px"});
	}
	if(aarRows==2 || aarRows==1){
		$(this).find(".leftrundlg").remove();
        $(this).find(".rightrundlg").remove();
	}
    });
}
$(document).ready(function() {
	var perfComp= $('.averageannualreturns');
    
for(var i = 0; i < perfComp.length; i++) {

    $(perfComp[i]).parent(".averageAnnualReturns").addClass("performaceTable"+i);
mobiView(i);

} 
    $('.performaceTable'+i).each(function(){

    var availRows=$(this).find(".cumlativeCol").length;

	$(this).find(".cumulativeId").attr("colspan",availRows);
    console.log("available columns:"+availRows);

         if($(window).innerWidth() > 991){
        if(availRows==3){
            $(this).find(".cumulativeId .leftrund").css({"margin-left":"58px","width":"16px"});
            $(this).find(".cumulativeId .rightrund").css({"margin-right":"50px","width":"80px"});
        	}
         }

	if(availRows==2){
		$(this).find(".cumulativeId .leftrund").css({"margin-left":"52px"});
		$(this).find(".cumulativeId .rightrund").css({"margin-right":"35px"});
        $(".col-lg-10 .cumulativeId .leftrund").css({"margin-left":"10px"});
		$(".col-lg-10 .cumulativeId .rightrund").css({"margin-right":"10px"});
        $(".funddetailspage .cumulativeId .leftrund").css({"margin-left":"35px"});
         $(".col-lg-12 .cumulativeId .leftrund").css({"margin-left":"35px"});

	}
	if(availRows==1){
		$(this).find(".leftrund").remove();
        $(this).find(".rightrund").remove();
	}
	var aarRows=$(this).find(".aarCol").length;
	$(this).find(".aarId").attr("colspan",aarRows);
	if(aarRows==5){
		$(this).find(".leftrundlg").css("width","123px");
        $(this).find(".rightrundlg").css("width","123px");
	}
	if(aarRows==4){
		$(this).find(".leftrundlg").css({"width":"87px","margin-left":"47px"});
		$(this).find(".rightrundlg").css("width","95px");
	}
	if(aarRows==3){
        $(this).find(".leftrundlg").css({"width":"40px","margin-left":"72px"});
		$(this).find(".rightrundlg").css({"width":"50px","margin-right":"58px"});
	}
	if(aarRows==2 || aarRows==1){
		$(this).find(".leftrundlg").remove();
        $(this).find(".rightrundlg").remove();
	}
    });

    if($(window).innerWidth()<=991){
		mobiView(i);
	}


	
    $(".hoverable").hover(function(){
        var indexer=$(this).index()+1;
        $(".table-row").find($("td")).filter(":nth-child("+indexer+")").css("background","#9bbbef33");
        $("tbody").find($("th.hoverable")).filter(":nth-child("+indexer+")").css("background","#9bbbef33");
        $("thead").find($("th.table-header")).filter(":nth-child("+(indexer)+")").css("background", "#9bbbef33");
        $(this).css("background","#9bbbef99");
        $(this).css("color","#000000");
        $(this).parent().css("background","#9bbbef33");
    },function(){
        $(this).removeClass("hover-active");
        $(this).attr("style","");
         $(this).parent().attr("style","");
        $(".table-row").find($("td")).attr("style","");
        $("tbody th").attr("style","");
         $(".table-header").attr("style","");
    })


	$('.aatrtab3').hide();
	$('#tab-content1 div:first').show();
	$(".aatrnavtest li").each(function(){
		$(".aatrnavtest li:first-child").addClass('active');
		$(this).parent().parent().find('.quarterly').hide();
		$(this).click(function(){
			$(this).prev('li').removeClass('active');
			$(this).next('li').removeClass('active');
			$(this).addClass('active');
			var indexer = $(this).index();
			if (indexer !='1') {
				$(this).parent().parent().find('.aatrtab3').hide();
				$(this).parent().parent().find(".monthly").show();
			} else {
				$(this).parent().parent().find(".monthly").hide();
				$(this).parent().parent().find('.quarterly').show();
			}
			$('#tab-content1 div:eq(' + indexer + ')').fadeIn();
		});
	});


	/*tooltip code*/
	$('[data-toggle="tooltip"]').tooltip();
	$('.tooltips-elements').tooltip().each(function() {
        var color = $(this).data('color');
        var textColor = $(this).data('text-color');
        $(this).hover(function(){
            var aria = $(this).attr('aria-describedby');
            $('#' + aria).find('.tooltip-inner').css({
                "background": color,
                "color": textColor,
                "margin-left": "0px",
                "font-family": "OpenSans-Regular, sans-serif",
                "font-size": "8pt",
                "font-weight": "normal",
                "text-align": "left",
                "width": "inherit",
                "max-width": "350px",
                "box-shadow": "0px 0px 4px 0px rgba(0, 0, 0, 0.20)",
                "width": "300px",
                "border-radius":"0px"

            });
            $('#' + aria).find('.tooltip-arrow').css({
                "border-right-color": color,
            });
            $( ".exclamatory" ).click(function( event ) {
                event.preventDefault();
            });
            if(window.outerWidth<=991){
                $('.tooltips-elements').tooltip({trigger: "click"});
				var aria = $(this).attr('aria-describedby');
				$('#' + aria).find('.tooltip-inner').append("<div id='tooltipclose' style='border:none;float:right;'></div>");
                $('#' + aria).find('.tooltip-inner').css({
                "background": color,
                "color": textColor,
                "margin-left": "0px",
                "font-family": "OpenSans-Regular, sans-serif",
                "font-size": "8pt",
                "font-weight": "normal",
                "text-align": "left",
                "box-shadow": "0px 0px 4px 0px rgba(0, 0, 0, 0.20)",
                "width": "300px"
                
                });
				$("#tooltipclose").click(function() {
					$('.tooltips-elements').tooltip('hide');
				});
				$( ".exclamatory" ).click(function( event ) {
					event.preventDefault();
				});
			}
		});
	});
	if($(".table-curved .aatrperformacetab .table tbody tr").empty()){
        $(".table-curved .aatrperformacetab .table tbody tr").empty().remove();

    }

    	if($(".aatrtab3 .table tbody tr").empty()){
            $(".aatrtab3 .table tbody tr").empty().remove();
}
    	if($(".table-curved .aatrperformacetab .table tbody tr td").empty()){
        $(".table-curved.aatrperformacetab .table tbody tr td").empty().remove();

    }

    	if($(".aatrtab3 .table tbody tr td").empty()){
            $(".aatrtab3 .table tbody tr td").empty().remove();
}

});
