$(document).ready(function () {
/** For navigation applying class last and removing margin for last link -- added by indigo on 17-10-2011 **/
$(".primaryNav ul li:last-child").addClass("noMarginRight last");
/** For navigation applying class last and removing margin for last link ends **/

/* For Funds Pages Who should Invest -- Added by Indigo on 17-10-2011 */
$('.tab-1-content').find('.heading').each(function()
{
	if($(this).attr('title') == 'Who Should Invest')
	{
		$(this).next(".content-white-box").find(".column-1").css({"width": "465px"});
	}
});
/* For Funds Pages Who should Invest End -- Added by Indigo on 17-10-2011 */

    /**** Custom form controls start ****/
    //$('select').selectbox();
    /*try {
    oHandler = $("select").msDropDown().data("dd");
    oHandler.visible(true);
    $("#ver").html($.msDropDown.version);
    } catch(e) {
    //alert("Error: "+e.message);
    }*/
    if (IsInPageEditMode == false) {
        try {
            //debugger;
            oHandler = $("select").not('[id*="EditorZone"]').not('[class*="AutoComplete"]').not('[class*="ui-datepicker-month"]').not('[class*="ui-datepicker-year"]').msDropDown().data("dd");
            oHandler.visible(true);
            $("#ver").html($.msDropDown.version);
        } catch (e) {
            //alert("Error: "+e.message);
        }

        if ($('.AutoComplete').length > 0) {
            $('.AutoComplete').combobox();
        }
    }

    $('input:checkbox').not('[id*="EditorZone"]').stylecheck();
    $('input:radio').not('[id*="EditorZone"]').stylecheck();
    $('input:text').not('[id*="EditorZone"]').stylecheck();
    /**** Custom form controls end ****/
    /**** PNG fix for IE6 start ****/
    if ($.browser.msie && $.browser.version == '6.0') {
        $("img").each(function () {
            var imgsrc = $(this).attr("src");
            if (imgsrc.match(".png") == ".png") {
                //alert($(this).attr("src"));
                $(this).attr("src", "/SiteCollectionImages/SiteImages/pixel.gif");
                $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + imgsrc + ",sizingMethod='crop')")
            }
        })
    }
    /*$('img[@src$=.png]').ifixpng();
    $('input[@src$=.png]').ifixpng();
    $('div').ifixpng();
    $('.hp-col-content').css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/hp-col-content-bg.png',sizingMethod='scale')");
    $('ul').ifixpng();
    $('span').ifixpng();*/
    /**** PNG fix for IE6 end ****/
    /***To open an external link, PDF in a new window start *****/
    $("a[rel=external]").attr('target', '_blank');
    /***To open an external link, PDF in a new window end *****/


    /*****Tab Content Functionality start *****/
    //debugger;
    $('.tab-content-wrapper').children('div').css('display', 'none');
    //$('.tab-content-wrapper').find('div div').css('display','block');
    if ($.browser.msie && $.browser.version == '6.0') {
        $('.tab-content-wrapper').children('div').css('width', '100%');
    }
    else {
        $('.tab-content-wrapper').children('div').css({ 'float': 'left', 'width': '100%' });
    }
    $('.tab-content-wrapper').find('div:first').css('display', 'block');
    $('.tab-content-wrapper').find('li:first').addClass('sel');
    $('.tab-content-wrapper .tabs').find('li:last').css('margin-right', '0');

    if ($('.tab-content-wrapper').attr('id') == 'ajax-content') {
        var fundId = $('#ajax-content').find('.tabs').attr('id');
        var getClassFirstTab = $('.tab-content-wrapper ul:first-child').children('li').attr('class').split(/\s+/);
        var getIdFirstTab = $('.tab-content-wrapper ul:first-child').find('li:first').attr('id');

        $.get(fundId + '-' + getIdFirstTab + '.html', function (data) {
            $(".tab-content").html(data);
            Cufon.replace('.heading', { fontFamily: 'ErasItcTMed' });
        });
    }

    $('.tabs').children('li').click(function () {
        //debugger;
        if ($(this).parent().parent().attr('id') == 'ajax-content') {
            $.ajax({
                type: "GET",
                url: fundId + '-' + this.id + '.html',
                dataType: "html",
                success: function (data) {
                    $(".tab-content").html(data);
                    $(".tab-content").show('slow');
                    $(".tab-content .tabcontent").children('div').hide();
                    $(".tab-content .tabs").find('li:first').addClass('sel');
                    $(".tab-content .tabs1").find('li:first').removeClass('sel'); //
                    $('.tab-content .tabs').find('li:last').css('margin-right', '0');
                    $(".tab-content .tabcontent").each(function () {
                        $(this).children('div:first').show();
                    });

                    $(".tab-content .tabs").find('li').click(function () {
                        $(this).removeClass('sel');
                        var getClassName = this.className;
                        $(this).parent().siblings('div.tabcontent').children('div').hide();
                        $(this).parent().siblings('div.tabcontent').children('.' + getClassName + '-content').show();
                        //$(".tab-content .tabs").find("li").removeClass('sel');
                        //$(this).siblings().removeClass('sel');
                        $(this).siblings().removeClass('sel');
                        if ($(this).parent().next().is('ul')) {
                            $(this).parent().next().children('li').removeClass('sel');
                        }
                        else if ($(this).parent().prev().is('ul')) {
                            $(this).parent().prev().children('li').removeClass('sel');
                        }
                        $(this).addClass('sel');
                    })
                    Cufon.replace('.heading', { fontFamily: 'ErasItcTMed' });
                },
                error: function () {
                    $(".tab-content").html("Page not found");
                }
            });
            $(this).parent().parent().find('li').removeClass('sel');
            $(this).addClass('sel');
        }
        else if ($(this).parent().parent().attr('id') == 'up-content') {
            $('.' + this.className).parent().parent().children('div').css('display', 'none');
            $('.' + this.className).parent().parent().find('li').removeClass('sel');
            var selClass = '.' + this.className;
            $('.' + this.className).addClass('sel');
            $(selClass + '-content').fadeIn('slow');

            var OnSwitchFunctionName = $(this).parent().attr('id') + 'OnSwitch';

            if (typeof eval(OnSwitchFunctionName) != "undefined" && $.isFunction(eval(OnSwitchFunctionName))) {
                eval(OnSwitchFunctionName + '(' + $(this).attr('index') + ')');
            }
        }
        else {
            $('.' + this.className).parent().parent().children('div').css('display', 'none');
            $('.' + this.className).parent().parent().find('li').removeClass('sel');
            var selClass = '.' + this.className;
            $('.' + this.className).addClass('sel');
            $(selClass + '-content').fadeIn('slow');
        }
    });

    /*****Tab Content Functionality end *****/

    $('.tab-content-navhistory').hide();
    $('#viewTable').click(function () {
        $('.tab-content-graph').hide();
        $('.tab-content-navhistory').show();
    });

    $('#viewGraph').click(function () {
        $('.tab-content-navhistory').hide();
        $('.tab-content-graph').show();
    });


    /*****Accordion Functionality for Different Ways Homepage start *****/
    var expandStateContentWidth = 348;
    var collapseStateContainerWidth = 170;
    var currentSection;

    //$(".different-ways-container .content").hide();
    $(".different-ways-container .state-expand").hide();

    $(".different-ways").click(function () {
        //$('.different-ways-container').animate({'width':'976px'});
        //$('.accordion').animate({'width':'976px'});
        $(this).find(".state-collapse").hide();
        $(this).find(".state-expand").show();
        //$(this).find(".content").show();
        currentSection = this;

        $(".different-ways").each(function () {
            if (currentSection != this) {
                $(this).animate({ "width": collapseStateContainerWidth });
                $(this).find(".state-collapse").show();
                $(this).find(".state-expand").hide();
                //$(this).find(".content").hide();
            }
        });

        var currentSectionClass = currentSection.id;

        if ($("#" + currentSectionClass).find(".content").attr('class') == 'content choose-right-fund') {
            $('.different-ways-container').animate({ 'width': '976px' });
            $('.accordion').animate({ 'width': '976px' });
            $(currentSection).animate({ "width": 514 });
            $(currentSection).find('.content').css('width', '343px');
            //$(".content").css('padding-left','170px');
        }
        else {
            $('.different-ways-container').animate({ 'width': '810px' });
            $('.accordion').animate({ 'width': '810px' });
            $(currentSection).animate({ "width": expandStateContentWidth });
        }
    });

    $(".different-ways-container .state-expand").click(function (e) {
        e.stopPropagation();
        $(".different-ways-container .state-expand").hide();
        $(".different-ways-container .state-collapse").show();
        //$(".different-ways-container .content").hide();
        $(".different-ways").animate({ "width": collapseStateContainerWidth });
        $('.different-ways-container').animate({ 'width': '662px' });
        $('.accordion').animate({ 'width': '662px' });

    });
    /*****Accordion Functionality for Different Ways Homepage end *****/
    /***Div scrolling functionality for Homepage start ***/
    $(".scroll-down").click(function () {
        var scrollableContent = $(this).parent().prev();
        var scrollable_ul = $(scrollableContent).find("ul");
        var scrollable_ul_currMar = parseInt(scrollable_ul.css('marginTop'));

        if ($.browser.msie && $.browser.version == '6.0') {
            var totalHeight = (scrollable_ul.children('li').length - 2) * 16;

            if (scrollable_ul_currMar % 16 == 0) {
                if (Math.abs(scrollable_ul_currMar) < totalHeight) {
                    var assignMarginTop = scrollable_ul_currMar - 16 + 'px';
                    scrollable_ul.animate({ 'marginTop': assignMarginTop });
                }
            }
        }
        else {
            var totalHeight = (scrollable_ul.children('li').length - 2) * 14;
            if (scrollable_ul_currMar % 14 == 0) {
                if (Math.abs(scrollable_ul_currMar) < totalHeight) {
                    var assignMarginTop = scrollable_ul_currMar - 14 + 'px';
                    scrollable_ul.animate({ 'marginTop': assignMarginTop });
                }
            }
        }
    });
    $(".scroll-up").click(function () {
        var scrollableContent = $(this).parent().prev();
        var scrollable_ul = $(scrollableContent).find("ul");
        var scrollable_ul_currMar = parseInt(scrollable_ul.css('marginTop'));

        if ($.browser.msie && $.browser.version == '6.0') {
            var totalHeight = (scrollable_ul.children('li').length - 2) * 16;
            if (scrollable_ul_currMar % 16 == 0) {
                if (scrollable_ul_currMar < 0) {
                    var assignMarginTop = scrollable_ul_currMar + 16 + 'px';
                    scrollable_ul.animate({ 'marginTop': assignMarginTop });
                }
            }
        }
        else {
            var totalHeight = (scrollable_ul.children('li').length - 2) * 14;
            if (scrollable_ul_currMar % 14 == 0) {
                if (scrollable_ul_currMar < 0) {
                    var assignMarginTop = scrollable_ul_currMar + 14 + 'px';
                    //alert(assignMarginTop);
                    scrollable_ul.animate({ 'marginTop': assignMarginTop });
                }
            }
        }
    });
    /***Div scrolling functionality for Homepage end ***/
    /*** Global NAV Login Box Functionality start ***/
    /*$('.globalNav .login').hover(
    function()
    {
    $('.login-links').fadeIn('slow');
    },
    function()
    {
    $('.login-links').fadeOut('slow');
    }
    )*/

    $('.login').bind('mouseover', function () {
        $(".primaryNav-wrapper").css({ "position": "relative", "z-index": "-1" });
        $('.login-links').show();
    });

    $('.login-links').bind('mouseout', function () {
        $(".primaryNav-wrapper").removeAttr("style");
        $('.login-links').hide();
    });
    /*** Global NAV Login Box Functionality end ***/
    /**** Floating Footer Links Functionality start ****/
    $(".floating-footer-links a").click(function () {
        $(".floating-footer-wrapper").css("width", "100%");
        if ($(".recently-viewed-content").css("display") == 'block') {
            $(".recently-viewed-content").slideToggle("slow");
        }
        if ($(".my-watchlist-content").css("display") == 'block') {
            $(".my-watchlist-content").slideToggle("slow");
        }
        $(".slide").slideToggle("slow");
    });

    /*$(".floating-footer-links-content a").click(function () {
    //debugger;
    if ($(".slide").css("display") == 'block') {
    $(".slide").slideToggle("slow");
    }
    if (this.className == 'footer-recently-viewed') {
    $(".recently-viewed-content").slideToggle("slow");
    }
    else if (this.className == 'footer-my-watchlist') {
    $(".my-watchlist-content").slideToggle("slow");
    }
    });*/
    /**** Floating Footer Links Functionality end ****/
    /*  mywatchlist datagrid start */
    $('.mywacthlist-grid .del').click(function () {
        //alert('45646545646');

        $(this).parent().parent().hide();
    });
    /*  mywatchlist datagrid end */
    /****Accordion Functionality for Homepage Current Mantra start ****/
    var currentMantra;

    $(".mantras").find(".mantras-section-content").hide();
    $(".mantras .state-expand").css("display", "none");
    $("#section_1").find(".state-expand").css("display", "block");
    $("#section_1").find(".state-collapse").css("display", "none");

    $(".mantras-section").click(function () {
        currentMantra = $(this).parent().parent().attr("id");

        var $childDivIds = $(".mantras-accordion").children("div").map(function (i, childDivId) {
            return childDivId.id;
        });
        var currClickSection = $(this).parent().parent().attr("id");
        $childDivIds.each(function (i, childDivId) {
            if ($("#" + childDivId).attr("class") == 'mantras expanded' && childDivId != currClickSection) {
                $("#" + childDivId).animate({ "width": "65px" });
                $("#" + childDivId).removeClass("expanded");
                $(".mantras .state-collapse").css("display", "block");
            }
        });
        $("#" + currentMantra).animate({ "width": "349px" });
        $("#" + currentMantra).addClass("expanded");
        $("#" + currentMantra).find(".state-collapse").css("display", "none");
        $("#" + currentMantra).find(".state-expand").css("display", "block");
        $("#" + currentMantra).find(".mantras-section-content").show();
    });

    $(".mantras .state-expand").click(function () {
        $(this).parent().animate({ "width": "65px" });
        $(this).parent().removeClass("expanded");
        $(this).css("display", "none");
        $(".mantras .state-collapse").css("display", "block");
    });

    $(".mantras .state-collapse").click(function () {
        var $childDivIds = $(".mantras-accordion").children("div").map(function (i, childDivId) {
            return childDivId.id;
        });

        $childDivIds.each(function (i, childDivId) {
            if ($("#" + childDivId).attr("class") == 'mantras expanded') {
                $("#" + childDivId).animate({ "width": "65px" });
                $("#" + childDivId).removeClass("expanded");
                $(".mantras .state-collapse").css("display", "block");
            }
        });
        $(this).parent().animate({ "width": "349px" });
        $(this).parent().addClass("expanded");
        $(this).css("display", "none");
        $(".mantras .state-expand").css("display", "block");
    });

    /****Accordion Functionality for Homepage Current Mantra end ****/
    /****Primary NAV hover functionality for IE6 start ****/

    /*Added by Dilip for Sharpoint based menu START*/
    $(".primaryNav div div ul").removeAttr('class');
    //$(".primaryNav div div li").removeAttr('class');
    //$(".primaryNav div div li").addClass('first-lvl');
    //debugger;
    //var OuterText = $('.primaryNav ul')[0].outerHTML;
    //$('.primaryNav #zz10_TopNavigationMenuV4').replaceWith(OuterText);

    $(".primaryNav div div li").hover(function () {

        //$("#"+this.id).css('backgroundColor','#f8b442');
        //$("#"+this.id).find('ul').fadeIn('slow');
        //alert($("#"+this.id).attr('class').search("sel"));
        /*** 31/05/2011 changes start ***/
        //$(this).css('cursor','pointer');
        //debugger;
        //From masterpage we are assigne site name as ID for anchor tag.
        //From here we are assigne id to LI tag from anchor.
        $(this).attr('id', this.firstChild.id.replace(" ", "-"));

        if ($("#" + this.id).attr('class') != 'sel') {
            $("#" + this.id).addClass('sel');
        }
        /*** 31/05/2011 changes end ***/
        $("#" + this.id).find('ul').show();
    },
	function () {

	    //$("#"+this.id).css('backgroundColor','');
	    //$("#"+this.id).find('ul').fadeOut('slow');
	    //$("#"+this.id).attr('class',$("#"+this.id).attr('class')+"-sel");
	    var splitClassName = $("#" + this.id).attr('class').split("-");
	    //alert(splitClassName[0]);
	    /*** 31/05/2011 changes start ***/
	    //$(this).css('cursor','default');

	    if ($("#" + this.id).hasClass('sel')) {
	        $("#" + this.id).removeClass('sel');
	    }
	    /*** 31/05/2011 changes end ***/
	    $("#" + this.id).find('ul').hide();
	}
	);

    $(".primaryNav div div li ul a").hover(function () {
        $(this).parent().addClass('hover');
    },
	function () {
	    $(this).parent().removeClass('hover');
	}
	);
    /*Added by Dilip for Sharpoint based menu END*/

    $(".primaryNav li").hover(function () {
        //$("#"+this.id).css('backgroundColor','#f8b442');
        //$("#"+this.id).find('ul').fadeIn('slow');
        //alert($("#"+this.id).attr('class').search("sel"));
        /*** 31/05/2011 changes start ***/
        //$(this).css('cursor','pointer');

        if ($("#" + this.id).attr('class') != 'sel') {
            $("#" + this.id).addClass('sel');
        }
        /*** 31/05/2011 changes end ***/
        $("#" + this.id).find('ul').show();
    },
	function () {
	    //$("#"+this.id).css('backgroundColor','');
	    //$("#"+this.id).find('ul').fadeOut('slow');
	    //$("#"+this.id).attr('class',$("#"+this.id).attr('class')+"-sel");
	    var splitClassName = $("#" + this.id).attr('class').split("-");
	    //alert(splitClassName[0]);
	    /*** 31/05/2011 changes start ***/
	    //$(this).css('cursor','default');

	    if ($("#" + this.id).hasClass('sel')) {
	        $("#" + this.id).removeClass('sel');
	    }
	    /*** 31/05/2011 changes end ***/
	    $("#" + this.id).find('ul').hide();
	}
	);



    $(".primaryNav li ul a").hover(function () {
        $(this).parent().addClass('hover');
    },
	function () {
	    $(this).parent().removeClass('hover');
	}
	);



    /*$(".primaryNav li").bind('mouseover',function() {
    if($.browser.msie && $.browser.version=='6.0') 
    {
    $("#"+this.id).css('backgroundColor','#f8b442');
    $("#"+this.id).find('ul').css("left","0");
    }
    });
    $(".primaryNav li").bind('mouseout',function() {
    if($.browser.msie && $.browser.version=='6.0') 
    {
    $("#"+this.id).css('backgroundColor','');
    $("#"+this.id).find('ul').css("left","-10000px");
    }
    });*/
    /****Primary NAV hover functionality for IE6 end ****/


    /****lhs-menu LHS hover functionality for start *****/
    /* Ajay changed on 30 July 2011 - Replaced UL with DIV */
   $(".lhs-menu > ul > li").find("div > span > span > ul > li > span:last").remove();
$(".lhs-menu > ul > li").hover(function() {
		if($(this).children('a').next().is('div'))
		{
			$(this).addClass('menu');
			$(this).find('div').show();
			//Added for assigning the width to the container div
			var divWidth=($(this).find("div span span ul span").length)*($(this).find("div span span ul span").eq(0).width())+16;		
if(divWidth > 776){
	divWidth = 776;
}	
//alert($(this).find("div span span ul span").length);
$(this).find('div').css("width",divWidth+"px");		
		}
	},
	function() {
		if($(this).children('a').next().is('div'))
		{
			$(this).removeClass('menu');
			$(this).find('div').hide();
		}
	}
	);
    /****lhs-menu LHS hover functionality for end ****/



    /****Bubble Functionality for inner page start *****/
    /*$('.section-brief span').click(function (e) {
        if ($(".bubble").length == 0) {
            $("<div class='bubble'><div class='bubble-close' onclick=\"$('.bubble').hide();\"><a href='javascript:;' title='close'>&nbsp;</a></div><div class='bubble-content'><h4>Regular Monthly Income Through UTI MF</h4><p>Lorem ipsum dolor sit amet, consectetuer adipisc50 g elit. Ut nec lacus a neque pulvinar pulvinar. A100liquam sagittis. lacus a neque pulvinar pulvinar. Lorem ipsum dolor sit amet, consectetuer adipisc50 g elit.</p><p>Sagittis.lacus a neque pulvinar pulvinar. Lorem ipsum dolor sit amet, consectetuer adipisc elit.</p></div><div class='bubble-btm'></div></div>").appendTo(".wrapper");
        }
        else {
            $(".bubble").show();
        }
        if ($.browser.msie && $.browser.version == '6.0') {
            var getPageY = e.pageY + $(".wrapper").scrollTop();
            $(".bubble").css("top", getPageY - $(".bubble").height());
        }
        else {
            $(".bubble").css("top", e.pageY - $(".bubble").height());
        }
        $(".bubble").css("left", e.pageX - 250);
    });*/
    /****Bubble Functionality for inner page end *****/

    /****HELP Functionality for inner page start *****/
    $('.help-button').hover(function (e) {
        if ($(".bubble").length == 0) {
            $("<div class='bubble'><div class='bubble-content'><p>" + $(this).attr("rel") + "</p></div><div class='bubble-btm'></div></div>").appendTo("body");
        }
        else {
            $(".bubble-content p").text($(this).attr("rel"));
            $(".bubble").stop(true, true).show();
        }

        $(".bubble").css("top", e.pageY - $(".bubble").height());
        $(".bubble").css("left", e.pageX - 250);
    },
function () {
    $(".bubble").hide();
}
);
    /****HELP Functionality for inner page end *****/

    /****Collapsible Box functionality for RHS starts ****/
    $(".accordion-vertical").find("div:first").addClass('expand');
    $(".accordion-vertical").find("div:first").find(".column-2-colapsible-box-content").css("display", "block");

    $(".column-2-colapsible-box").find(".heading").click(function () {
        //$(".accordion-vertical").find(".column-2-colapsible-box-content").slideUp("slow");
        $(".accordion-vertical").find(".column-2-colapsible-box-content").parent().removeClass('expand');
        //alert($(this).parent().next().find(".column-2-colapsible-box-content").hasClass("displayNone"));
        if ($(this).parent().next().find(".column-2-colapsible-box-content").hasClass("displayNone") == true) {
            $(this).parent().next().addClass('expand');
            $(this).parent().next().find(".column-2-colapsible-box-content").slideDown("slow");
            $(this).parent().next().slideDown("slow");
        }
        else {
            $(this).parent().prev().addClass('expand');
            $(this).parent().prev().find(".column-2-colapsible-box-content").slideDown("slow");
            $(this).parent().prev().slideDown("slow");
        }

        if ($(this).next().css("display") == "none") {
            $(this).next().slideDown("slow");
            $(this).parent().addClass('expand');
        }
        else {
            $(this).next().slideUp("slow");
        }
        /*$(this).next().slideToggle('slow',function(){
        $(this).parent().toggleClass('expand');
        });*/
    });
    /****Collapsible Box functionality for RHS ends ****/
    /****Search Site Clear Input Box start *****/
    function onFocusInput(param) {
        var storeVal = param.alt;
        clearFormField.clear(param, storeVal);
    }

    function onBlurInput(param) {
        var storeVal = param.alt;
        clearFormField.fill(param, storeVal);
    }

    $(".search-site-input-box").focus(function () {
        onFocusInput(this);
    }
)

    $(".search-site-input-box").blur(function () {
        onBlurInput(this);
    }
)

    $(".input").focus(function () {
        onFocusInput(this);
    }
)

    $(".input").blur(function () {
        onBlurInput(this);
    }
)

    /****Search Site Clear Input Box end *****/

    /**** Carousel functionality start *****/
    $(".lp-box-content a").click(function () {
        var currMargin = parseInt($(".lp-box-content").find(".carousel-content").css("marginLeft"));

        if ((currMargin % 404) == 0) {
            if ($(this).attr("class") == 'next' && parseInt($(".lp-box-content").find(".carousel-content").css("marginLeft")) > "-808") {

                var newMargin = currMargin - 404 + "px";
                $(".lp-box-content").find(".carousel-content").animate({ "marginLeft": newMargin });
                $(".lp-box-content .prev").addClass("prev-active");
                if (parseInt($(".lp-box-content").find(".carousel-content").css("marginLeft")) == "-404") {
                    $(this).addClass("next-inactive");
                }
            }
            else if ($(this).attr("class") == 'prev prev-active' && parseInt($(".lp-box-content").find(".carousel-content").css("marginLeft")) != "0") {
                var newMargin = currMargin + 404 + "px";
                $(".lp-box-content").find(".carousel-content").animate({ "marginLeft": newMargin });
                $(".lp-box-content .next").removeClass("next-inactive");
                if (parseInt($(".lp-box-content").find(".carousel-content").css("marginLeft")) == "-404") {
                    $(this).removeClass("prev-active");
                }
            }
        }
    });

    /**** Carousel functionality end *****/

    /*** Date Picker start ***/
    /*
    var getDateInput;		
    $(".date-picker").click(function(e) {
    getDateInput=$(this).prev();
    var xPos=e.pageX;
    var yPos=e.pageY;
	
    $(".date-picker-container").css({"left":xPos,"top":yPos});		
    $(".date-picker-container").show();
    });

    $('.date-picker-container').datepicker({
    onSelect: function(dateText) {
    $(getDateInput).css('color','#888');
    $(getDateInput).attr('value',dateText);
    $(".date-picker-container").hide();
    }
    });
    */
    /*var getDateInput;
    $(".date-picker").click(function (e) {
    getDateInput = $(this).prev();
    var xPos = e.pageX;
    var yPos = e.pageY;

    $(".date-picker-container").css({ "left": xPos, "top": yPos });
    $(".date-picker-container").show();
    });

    $('.date-picker-container').datepicker({
    onSelect: function (dateText) {
    $(getDateInput).css('color', '#888');
    $(getDateInput).attr('value', dateText);
    $(".date-picker-container").hide();
    }
    });
    $(".date-picker-container").datepicker("option", "dateFormat", 'dd-mm-yy');*/

    /*** Date Picker end ***/

});
/*** End Document.Ready ***/


/*** Clearing the Form Fields start ***/
var clearFormField = {
    clear: function (param, value) {
        if (param.value == value) {
            param.value = '';
        }
    },
    fill: function (param, value) {
        if (param.value == '') {
            param.value = value;
        }
    }
}
/*** Clearing the Form Fields end ***/

/****Quiz for Myth or Fact for Homepage start ****/
/* Added on 01-12-2011 */
$(function (){
	$('.column-2-box .quiz-wrapper .question-wrapper').find('#question-1 .question-number').html('<strong>Question 1</strong>');
	$('.column-2-box .quiz-wrapper .question-wrapper').find('#question-2 .question-number').html('<strong>Question 2</strong>');
	$('.column-2-box .quiz-wrapper .question-wrapper').find('#question-3 .question-number').html('<strong>Question 3</strong>');
});

function checkQuiz(num, booleanVal, animateMarginValue, placeholder) {
	var homePageMyth = $('body').find('.hp-acc-tab-content').length;
	if(homePageMyth == 1)
	{
		animateMarginValue = 400;
		placeholder = 'homepage';
	}
	else
	{
		animateMarginValue = 241;
		placeholder = 'rhs';
	}
    if (booleanVal == 'true') {
        $("#question-" + num + "-stat").addClass("correct");
    }
    else {
        $("#question-" + num + "-stat").addClass("wrong");
    }
    var currMargin = parseInt($(".questionaire").css("marginLeft"));
    var newMargin = currMargin - animateMarginValue + "px";
    var questionaire_div = $(".questionaire").children("div").length;
    var totalWidth = (questionaire_div - 1) * animateMarginValue;

    if (currMargin <= 0) {
        if (Math.abs(currMargin) != totalWidth) {
            $(".questionaire").animate({ "marginLeft": newMargin });
        }
    }
    if (placeholder == 'homepage') {
        if ($(".questionaire").css("margin-left") == "-800px") {
            $(".quiz-score .button").show();
        }
    }
    else if (placeholder == 'rhs') {
        if ($(".questionaire").css("margin-left") == "-482px") {
            $(".quiz-score").show();
        }
    }
}
/*** 31/05/2011 changes start ***/
function btn_new_quiz(placeholder) {
    $(".questionaire").css("margin-left", "0");
    if (placeholder == 'homepage') {
        $(".quiz-score .button").hide();
    }
    else if (placeholder == 'rhs') {
        $(".quiz-score").hide();
    }
    $(".quiz-score").find(".checkbox").each(function () {
        if ($(".quiz-score").find(".checkbox").hasClass('correct')) {
            $(".quiz-score").find(".checkbox").removeClass('correct');
        }
        else {
            $(".quiz-score").find(".checkbox").removeClass('wrong');
        }
    }
	)
}
/*** 31/05/2011 changes end ***/
/****Quiz for Myth or Fact for Homepage end ****/
/****Call Out box starts ****/
function compare_callout_show(param, positionX, positionY) {
    var getParent = $(param).parent().parent().parent();

    if ($(param).next().attr('class') == 'label-checked') {
        $(getParent).removeAttr("style");
        $(getParent).next().css("position", "static");
        $(getParent).next().next().css("position", "static");

        if ($("#callout-box").length == 0) {
            $("<div id='callout-box' class='bubble callout-box'><div class='bubble-close'><a href='javascript:;' title='close'>&nbsp;</a></div><div class='bubble-content'></div><div class='bubble-btm'></div></div>").appendTo(".wrapper");
            $("#callout-box").css({ "display": "block", "top": positionY, "left": positionX, "z-index": "100" });
        }
        else {
            //$("#callout-box").appendTo(getParent);
            //$("#callout-box").css("display","block");
            $("#callout-box").css({ "display": "block", "top": positionY, "left": positionX, "z-index": "100" });
        }
        $(".bubble-content").html('');
        $(".bubble-content").append($("#callout-fund-brief").html());
    }
    else if ($(param).next().attr('class') == 'label-unchecked') {
        $(".funds-filter-results-container").find('label').each(function () {
            if ($(this).attr('class') == 'label-checked') {
                $("#callout-box").css("display", "block");
                return false;
            }
            else {
                $("#callout-box").css("display", "none");
                /*$(getParent).removeAttr("style");
                $(getParent).next().css("position","static");
                $(getParent).next().next().css("position","static");*/
            }
        });
    }
    $(".bubble-close").click(function () {
        $("#callout-box").css("display", "none");
    });
}

function compare_uncheckChkBox(currentElem) {
    var name_of_fund = $(currentElem).prev().html();

    $(".funds-filter-results-container-tbl-content").each(function () {
        if (name_of_fund == $(this).find("a").html()) {
            $(this).find('label').removeClass('label-checked');
            $(this).find('label').addClass('label-unchecked');
        }
    });
}
function compare_uncheckChkBox_grid(currentElem) {
    $("#" + currentElem).removeClass('label-checked');
    $("#" + currentElem).addClass('label-unchecked');
}
/****Call Out box end ****/

/**** Remove an element start ****/
function removeElem(currentElem) {
    $(currentElem).parent().parent().remove();
}
/**** Remove an element end ****/



/**** ContactUs - LocateUs page - Scrolling Code start ****/
function locateusScroller() {
    if ($('.scroll-pane').length != 0) {
        //alert(1);
        $('.scroll-pane').jScrollPane();
        //$('#pane1').jScrollPane();
    }
}


/**** ContactUs - LocateUs page - Scrolling Code  end ****/

/**** Added By Nitin For Funds - FundsFinder page - Scrolling Code start ****/
function fundScroller() {
    $('#pane11').jScrollPane();
}

/**** Funds - FundsFinder page - Scrolling Code  end ****/

/**** Added By Nitin For Home - Refer A Friend page - Scrolling Code start ****/
function referafrnd() {
    $('#pane1').jScrollPane();
}

/**** Home - Refer A Friend page - Scrolling Code  end ****/

function removeTableColumn(param) {
    var getClass = $(param).parent().parent().attr('class');
    var nextElemToCurr = $("." + getClass).prev().attr('class');

    $("." + getClass).each(function () {
        $(this).remove();
    });

    //alert("1"+$(".scroll-pane").outerHeight());

    $("." + nextElemToCurr).parent().each(function () {
        $("<td class=" + getClass + ">Please select a fund." + getClass + "</td>").appendTo(this);
    }
	);

    $(".scroll-pane").animate({ "top": "0" });
    $(".jScrollPaneDrag").animate({ "top": "0" });
}


/*** Function for Auto Scroll to Results Section start ***/
function displayResults() {
    if ($.browser.msie && $.browser.version == '6.0') {
        $(".wrapper").animate({
            scrollTop: $(".wrapper").scrollTop() + $("#results").offset().top
        }, 1000);
    }
    else {
        $("html,body").animate({
            scrollTop: $("#results").offset().top
        }, 1000);
    }
}
/* Added by Indigo on 09-09-2011 */
function displaySipResults() {
    if ($.browser.msie && $.browser.version == '6.0') {
        $(".wrapper").animate({
            scrollTop: $(".wrapper").scrollTop() + $("#sipresults").offset().top
        }, 1000);
    }
    else {
        $("html,body").animate({
            scrollTop: $("#sipresults").offset().top
        }, 1000);
    }
}
/* end */
/*** Function for Auto Scroll to Results Section start ***/




/*** Function for Poplayer start ***/
var scrollTopParam = 0;
//var getPopLayerShowParam=null;
var lyteboxWidth;
var lyteboxHeight;

var popLayer = {
    show: function(param, paramIframe) {
        //debugger;
        var varChieldFrame = $("#PopLayer_ChildFrame");

        if ($(".transparent-layer").length == 0) {
            $("<div class='transparent-layer'></div>").prependTo(".wrapper");

            if ($.browser.msie && $.browser.version == '6.0') {

                var transparentLayerHeight = $(".content-wrapper").height() + 492 + "px";
                $(".transparent-layer").css("height", transparentLayerHeight);
            }
        }

        if (paramIframe == undefined) {
            //debugger;
            /*if ($(".poplayer").length == 0) {
            //$("<div class='poplayer'><div class='poplayer-top'><div class='poplayer-top-left'></div><div class='poplayer-top-middle'><div class='poplayer-top-middle-bg'></div></div><div class='poplayer-top-right'><div class='close' onclick='popLayer.hide();'></div></div></div><div class='poplayer-content-wrapper'><div class='poplayer-content-left'></div><div class='poplayer-content-middle'><iframe id='IFramePopLayer' width='100%' onload=autoIframe(this.id) frameborder='0' scrolling='no'  src='" + param + "'></iframe></div><div class='poplayer-content-right'></div></div><div class='poplayer-bottom'><div class='poplayer-bottom-left'></div><div class='poplayer-bottom-middle'><div class='poplayer-bottom-middle-bg'></div></div><div class='poplayer-bottom-right'></div></div></div>").appendTo(".wrapper");
            $("<div class='poplayer'><div class='poplayer-top'><div class='poplayer-top-left'></div><div class='poplayer-top-middle'><div class='poplayer-top-middle-bg'></div></div><div class='poplayer-top-right'><div class='close' onclick='popLayer.hide();'></div></div></div><div class='poplayer-content-wrapper'><div class='poplayer-content-left'></div><div class='poplayer-content-middle'>" + varChieldFrame[0].outerHTML + "</div><div class='poplayer-content-right'></div></div><div class='poplayer-bottom'><div class='poplayer-bottom-left'></div><div class='poplayer-bottom-middle'><div class='poplayer-bottom-middle-bg'></div></div><div class='poplayer-bottom-right'></div></div></div>").appendTo(".wrapper");
            }*/

            $.ajax({
                type: "GET",
                url: param,
                dataType: "html",
                success: function(data) {
                    //debugger;
                    //var htmltest = $(data).applyMetaData();
                    //Only get the Div_PlaceHolderMain
                    var finalData = $(data).find('#Div_PlaceHolderMain').html();

                    finalData = "<SCRIPT type=text/javascript src='/Style%20Library/Javascript/highcharts.src.js'></SCRIPT><SCRIPT type=text/javascript src='/Style%20Library/Javascript/calculator.js'></SCRIPT>" + finalData;
                    
                    //Get only HTML from Div_PlaceHolderMain div.
                    //finalData = $('<div>').append($(data).find('#Div_PlaceHolderMain').html()).find("#Div_PlaceHolderMain").html();
                    $(".poplayer-content-middle").html(finalData);
                    //$(".poplayer-content-middle").html("<div class='lytebox compare-funds-results'><div class='content'><div class='popup-wrapper compare-funds-results-content'><div class='heading-wrapper'><div class='heading' title='Compare Funds'>Compare Funds</div><div class='print-section'><a title='Print' class='icon-print' href='javascript:;'>Print</a><a title='Email' class='icon-email' href='javascript:;'>Email</a></div></div> Prosares Solution Pvt Ltd. </div></div></div>");

                    //$(".poplayer-content-middle").html($(data).find(".lytebox").parent().html());
                    /*lyteboxWidth = parseInt($(".lytebox .content").css('width')) + 32;*/ /*Line commented by indigo on 15-10-2011 */

                    //lyteboxWidth=$(".lytebox .content").width();
                    //lyteboxHeight=$(".lytebox .content").height();
                    /*lyteboxHeight = parseInt($(".lytebox .content").css('height')) + 22;

                    getIframeParam(lyteboxWidth, lyteboxHeight)*/
                    /*Line Commented by Indigo on 15-10-2011 */

                    /* Added by Indigo on 15-10-2011 */
                   // lyteboxWidth = parseInt($(".lytebox .content").css('width'));                    
                      lyteboxWidth=$(".lytebox .content").width();
                      lyteboxHeight=$(".lytebox .content").height();
                   // lyteboxHeight = parseInt($(".lytebox .content").css('height'));
                    //alert(lyteboxWidth + '\n' + lyteboxHeight + '\n' + $(".poplayer-content-middle").width());

                    //var lyteboxContentHtml=$(".lytebox-content").html();
                    //$(lyteboxContentHtml).appendTo(".poplayer-content-middle");
                    $(".poplayer").css({ "width": lyteboxWidth + 30 + "px", "height": lyteboxHeight + 22 + "px" });
                    $(".poplayer-top-middle").css("width", lyteboxWidth - 26 + "px");
                    $(".poplayer-content-wrapper").css("height", lyteboxHeight + 52 + "px");
                    $(".poplayer-content-middle").css({ "width": lyteboxWidth + "px", "height": lyteboxHeight + 22 + "px" });
                    $(".poplayer-content-left").css("height", lyteboxHeight + 52 + "px");
                    $(".poplayer-content-right").css("height", lyteboxHeight + 52 + "px");
                    $(".poplayer-bottom-middle").css("width", lyteboxWidth - 26 + "px");

                    //$('select').selectbox();
                    try {
                        oHandler = $("select").msDropDown().data("dd");
                        oHandler.visible(true);
                        $("#ver").html($.msDropDown.version);
                    } catch (e) {
                        //alert("Error: "+e.message);
                    }
                    $('input:checkbox').stylecheck();
                    $('input:radio').stylecheck();
                    $('input:text').stylecheck();
                    Cufon.replace('.content h3', { fontFamily: 'ErasItcTDem' });
                    Cufon.replace('.button span', { fontFamily: 'ErasItcTDem' });
                    Cufon.replace('.content h4', { fontFamily: 'ErasItcTDem' });
                    Cufon.replace('.heading', { fontFamily: 'ErasItcTDem' });
                    if ($.browser.msie && $.browser.version == '6.0') {
                        $("img").each(function() {
                            var imgsrc = $(this).attr("src");
                            if (imgsrc.match(".png") == ".png") {
                                //alert($(this).attr("src"));
                                $(this).attr("src", "../images/pixel.gif");
                                $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + imgsrc + ",sizingMethod='crop')")
                            }
                        })
                    }

                    var clientHeight = $(window).height();
                    var poplayerHeight = $(".poplayer").height() + 58;

                    if ($.browser.msie && $.browser.version == '6.0') {
                        $(".floating-footer-wrapper").hide();
                        var scrollTop = $(".wrapper").scrollTop();
                        scrollTopParam = scrollTop;

                        var clientWidth = $(window).width() - 19;
                    }
                    else {
                        var scrollTop = $("html,body").scrollTop();
                        var clientWidth = $(window).width();
                    }

                    //var clientWidth=$(window).width();
                    var poplayerWidth = $(".poplayer").width();
                    var horizontalPos;
                    var veticalPos;

                    if (clientWidth - poplayerWidth < 0) {
                        horizontalPos = 0;
                    }
                    else {
                        horizontalPos = Math.round(Math.abs(clientWidth - poplayerWidth) / 2);
                    }

                    if (clientHeight - poplayerHeight < 0) {
                        veticalPos = Math.round(scrollTop);
                    }
                    else {
                        veticalPos = Math.round(Math.abs(clientHeight - poplayerHeight) / 2 + scrollTop);
                    }

                    if ($.browser.msie && $.browser.version == '6.0') {
                        $(".poplayer").css({ "left": horizontalPos + "px", "top": "20px" });
                        $(".wrapper").animate({
                            scrollTop: 0
                        }, 1000);
                    }
                    else {
                        if (veticalPos < 0) {
                            $(".poplayer").css({ "left": horizontalPos + "px", "top": "20px" });
                        }
                        else {
                            $(".poplayer").css({ "left": horizontalPos + "px", "top": veticalPos + "px" });
                        }
                    }
                    /* Code end */

                },
                error: function() {
                    //$(".tab-content").html("Page not found");
                }
            });
        }
        else {
            if ($(".poplayer").css('display') == 'none') {
                varChieldFrame[0].src = param;
                //$(".poplayer").css('display') = 'block';
            }
        }

        $(".poplayer").show();

    },
    hide: function() {
        //$(".poplayer").remove();
        $(".poplayer-content-middle").html("<iframe frameborder=0 border=0 src='' name='PopLayer_ChildFrame' id='PopLayer_ChildFrame'>");
        $(".poplayer").hide();
        $(".transparent-layer").remove();

        if ($.browser.msie && $.browser.version == '6.0') {
            $(".floating-footer-wrapper").show();
            $(".wrapper").animate({
                scrollTop: scrollTopParam + "px"
            }, 1000);
        }
    }
}

function getIframeParam(paramWidth, paramHeight) {
    //debugger;
    paramWidth = paramWidth + 30;
    $(".poplayer").css("width", paramWidth + "px");
    if ($.browser.msie && $.browser.version == '6.0') {
        $(".poplayer-top-middle").css("width", paramWidth - 60 + "px");
    }
    else {
        $(".poplayer-top-middle").css("width", paramWidth - 56 + "px");
    }

    $(".poplayer-content-wrapper").css("height", paramHeight + 52 + "px");
    $(".poplayer-content-middle").css({ "width": paramWidth - 30 + "px", "height": paramHeight + 22 + "px" });
    $(".poplayer-content-middle iframe").css({ "width": paramWidth - 30 + "px", "height": paramHeight + 32 + "px" });
    $(".poplayer-content-left").css("height", paramHeight + 52 + "px");
    $(".poplayer-content-right").css("height", paramHeight + 52 + "px");
    $(".poplayer-bottom-middle").css("width", paramWidth - 56 + "px");

    try {
        oHandler = $("select").msDropDown().data("dd");
        oHandler.visible(true);
        $("#ver").html($.msDropDown.version);
    } catch (e) {
        //alert("Error: "+e.message);
    }
    $('input:checkbox').stylecheck();
    $('input:radio').stylecheck();
    $('input:text').stylecheck();

    /*Cufon.replace('.content h3', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.button span', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.content h4', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.heading', { fontFamily: 'ErasItcTDem' });*/

    //debugger
    if ($.browser.msie && $.browser.version == '6.0') {
        $("img").each(function () {
            var imgsrc = $(this).attr("src");
            if (imgsrc.match(".png") == ".png") {
                //alert($(this).attr("src"));
                $(this).attr("src", "/SiteCollectionImages/SiteImages/pixel.gif");
                $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=.." + imgsrc + ",sizingMethod='crop')")
            }
        })
    }

    var clientHeight = $(window).height();
    var poplayerHeight = $(".poplayer").height() + 58;

    if ($.browser.msie && $.browser.version == '6.0') {
        $(".floating-footer-wrapper").hide();
        var scrollTop = $(".wrapper").scrollTop();
        scrollTopParam = scrollTop;

        var clientWidth = $(window).width() - 19;
    }
    else {
        var scrollTop = $("html,body").scrollTop();
        var clientWidth = $(window).width();
    }

    //var clientWidth=$(window).width();
    var poplayerWidth = $(".poplayer").width();
    var horizontalPos;
    var veticalPos;

    if (clientWidth - poplayerWidth < 0) {
        horizontalPos = 0;
    }
    else {
        horizontalPos = Math.round(Math.abs(clientWidth - poplayerWidth) / 2);
    }

    if (clientHeight - poplayerHeight < 0) {
        veticalPos = Math.round(scrollTop);
    }
    else {
        veticalPos = Math.round(Math.abs(clientHeight - poplayerHeight) / 2 + scrollTop);
    }

    if ($.browser.msie && $.browser.version == '6.0') {
        $(".poplayer").css({ "left": horizontalPos + "px", "top": "20px" });
        $(".wrapper").animate({
            scrollTop: 0
        }, 1000);
    }
    else {
        $(".poplayer").css({ "left": horizontalPos + "px", "top": veticalPos + "px" });
    }
}

    /*var popLayer = {
    show: function (param) {
    if ($(".transparent-layer").length == 0) {
    $("<div class='transparent-layer'></div>").prependTo(".wrapper");

    if ($.browser.msie && $.browser.version == '6.0') {

    var transparentLayerHeight = $(".content-wrapper").height() + 492 + "px";
    $(".transparent-layer").css("height", transparentLayerHeight);
    }
    }

    if ($(".poplayer").length == 0) {
    $("<div class='poplayer'><div class='poplayer-top'><div class='poplayer-top-left'></div><div class='poplayer-top-middle'><div class='poplayer-top-middle-bg'></div></div><div class='poplayer-top-right'><div class='close' onclick='popLayer.hide();'></div></div></div><div class='poplayer-content-wrapper'><div class='poplayer-content-left'></div><div class='poplayer-content-middle'></div><div class='poplayer-content-right'></div></div><div class='poplayer-bottom'><div class='poplayer-bottom-left'></div><div class='poplayer-bottom-middle'><div class='poplayer-bottom-middle-bg'></div></div><div class='poplayer-bottom-right'></div></div></div>").appendTo(".wrapper");


    $.ajax({
    type: "GET",
    url: param,
    dataType: "html",
    success: function (data) {
    $(".poplayer-content-middle").html(data);
    lyteboxWidth = parseInt($(".lytebox .content").css('width'));
    lyteboxHeight = parseInt($(".lytebox .content").css('height'));

    $(".poplayer").css({ "width": lyteboxWidth + 30 + "px", "height": lyteboxHeight + 22 + "px" });
    $(".poplayer-top-middle").css("width", lyteboxWidth - 26 + "px");
    $(".poplayer-content-wrapper").css("height", lyteboxHeight + 52 + "px");
    $(".poplayer-content-middle").css({ "width": lyteboxWidth + "px", "height": lyteboxHeight + 22 + "px" });
    $(".poplayer-content-left").css("height", lyteboxHeight + 52 + "px");
    $(".poplayer-content-right").css("height", lyteboxHeight + 52 + "px");
    $(".poplayer-bottom-middle").css("width", lyteboxWidth - 26 + "px");

    try {
    oHandler = $("select").msDropDown().data("dd");
    oHandler.visible(true);
    $("#ver").html($.msDropDown.version);
    } catch (e) {
    //alert("Error: "+e.message);
    }
    $('input:checkbox').stylecheck();
    $('input:radio').stylecheck();
    $('input:text').stylecheck();
    Cufon.replace('.content h3', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.button span', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.content h4', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.heading', { fontFamily: 'ErasItcTDem' });
    if ($.browser.msie && $.browser.version == '6.0') {
    $("img").each(function () {
    var imgsrc = $(this).attr("src");
    if (imgsrc.match(".png") == ".png") {
    $(this).attr("src", "/SiteCollectionImages/SiteImages/pixel.gif");
    $(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + imgsrc + ",sizingMethod='crop')")
    }
    })
    }

    var clientHeight = $(window).height();
    var poplayerHeight = $(".poplayer").height() + 58;

    if ($.browser.msie && $.browser.version == '6.0') {
    $(".floating-footer-wrapper").hide();
    var scrollTop = $(".wrapper").scrollTop();
    scrollTopParam = scrollTop;

    var clientWidth = $(window).width() - 19;
    }
    else {
    var scrollTop = $("html,body").scrollTop();
    var clientWidth = $(window).width();
    }

    var poplayerWidth = $(".poplayer").width();
    var horizontalPos;
    var veticalPos;

    if (clientWidth - poplayerWidth < 0) {
    horizontalPos = 0;
    }
    else {
    horizontalPos = Math.round(Math.abs(clientWidth - poplayerWidth) / 2);
    }

    if (clientHeight - poplayerHeight < 0) {
    veticalPos = Math.round(scrollTop);
    }
    else {
    veticalPos = Math.round(Math.abs(clientHeight - poplayerHeight) / 2 + scrollTop);
    }

    if ($.browser.msie && $.browser.version == '6.0') {
    $(".poplayer").css({ "left": horizontalPos + "px", "top": "20px" });
    $(".wrapper").animate({
    scrollTop: 0
    }, 1000);
    }
    else {
    $(".poplayer").css({ "left": horizontalPos + "px", "top": veticalPos + "px" });
    }
    },
    error: function () {
    //$(".tab-content").html("Page not found");
    }
    });

    }
    },
    hide: function () {
    $(".poplayer").remove();
    $(".transparent-layer").remove();

    if ($.browser.msie && $.browser.version == '6.0') {
    $(".floating-footer-wrapper").show();
    $(".wrapper").animate({
    scrollTop: scrollTopParam + "px"
    }, 1000);
    }
    }
    }*/
    /*** Function for Poplayer end ***/


/*  Functions used in fund-performance-nav.html page code START  */

function checkH() {
    if ($('#navHistory').hasClass('label-unchecked')) {
        $('#disable').slideDown();
    }

    if ($('#navHistory').hasClass('label-checked')) {
        $('#disable').slideUp();
    }
}

function checkForm(param) {
    if (param == "dividend") {
        $('#dividendH').show();
        displayResults();
    }
    else if (param == "nav") {
        if ($('#navHistory').hasClass('label-checked')) {
            $('#navH').show();
            $('.tab-content-graphview').show();
            displayResults();
        }
        else if ($('#navHistory').hasClass('label-unchecked')) {
            $('#navH').hide();
            $('.tab-content-graphview').hide();
        }
        if ($('#navCurrent').hasClass('label-checked')) {
            $('#navC').show();
            displayResults();
        }
        else if ($('#navCurrent').hasClass('label-unchecked')) {
            $('#navC').hide();
        }
    }
}

/*  Functions used in fund-performance-nav.html page code END  */


/*  Functions used in performance-analyser.html page code START  */
function checkPerformanceAnalyserForm() {
    if ($("#radio label").each(function () {
        if ($(this).attr("class") == 'label-checked') {
            $("#results .returns-col1 h3").text($(this).text());
            Cufon.replace('#results .returns-col1 h3', { fontFamily: 'ErasItcTDem' });
        }
    }
	));

    var flag = false;

    if ($("#analyser-calculator label").each(function () {
        var currId = $(this).attr('id') + "-content";

        $("#" + currId).hide();
        if ($(this).attr("class") == 'label-checked') {
            $("#sh-benchmark").show();
            $("#" + currId).show();
            flag = true;
        }
    }
	));

    if (flag == false) {
        $("#sh-benchmark").hide();
    }
    $('#sipresults').hide();
    $('#results').show();
    displayResults();
}
/* Added on 26-Aug-2011 by Indigo */
function checkPerformanceAnalyserForm1() {
    if ($("#radio label").each(function () {
        if ($(this).attr("class") == 'label-checked') {
            $("#sipresults .returns-col1 h3").text($(this).text());
            Cufon.replace('#sipresults .returns-col1 h3', { fontFamily: 'ErasItcTDem' });
        }
    }
	));

    $('#results').hide();
    $('#sipresults').show();
    displaySipResults();
}
$(function () {
    $(".performance-analyser label").click(function () {
        var val = $(this).attr("id");
        if (val == 'Absolute') {
            $("#absolute-content").show();
            $("#sip-content, #sipresults").hide();
        }
        else if (val == "SIP") {
            $("#sip-content").show();
            $("#absolute-content, #results").hide();
        }
    });
});

/* */
/*  Functions used in performance-analyser.html page code END  */

/*** Functionality for Forms and Literature start ***/
/*Changed by Indigo on 14-Nov-11 starts*/
/*$(document).ready(function(){
	$(".accordion-header").click(function(){
		var currElemHeight=$(this).height()+26;
		
		if($(this).find(".active").length!=0)
		{
			if($(this).find(".label-unchecked").length!=0)
			{
				$(this).find(".label-unchecked").attr("class","label-checked");
			}
			$(this).next().find(".formsLiteratureResults").hide();
			$(this).find(".active").attr("class","inactive");
			var totalHeight=$(this).next(".accordion-content").height()+20+currElemHeight+"px";
			$(this).parent().animate({"height":totalHeight});
			$(this).parent().css("z-index","10000");
			$(this).next().css({"position":"static","left":"0"});
		}
		else
		{
			alert($(this).html());
			if($(this).find(".label-checked").length!=0)
			{
				$(this).find(".label-checked").attr("class","label-unchecked");
			}
			else if($(this).find(".label-unchecked").length!=0)
			{
				$(this).find(".label-unchecked").attr("class","label-checked");
			}
			$(this).find(".inactive").attr("class","active");
			$(this).parent().animate({"height":currElemHeight+"px"});
			$(this).next().css({"position":"absolute","left":"-10000px"});
		}
	});
})*/

function accordion(param) {
    if ($(param).attr("class") == 'active') {
        $(param).parent().next().find(".formsLiteratureResults").hide();
		$(param).attr("title","Collapse");
        $(param).attr("class", "inactive");
        var hiddenContentHeight = $(param).parent().next().height() + 72 + "px";
        $(param).parent().parent().animate({ "height": hiddenContentHeight });
        $(param).parent().next().css({ "position": "static", "left": "0" });
        //$(param).parent().next().animate({"opacity":"1"});
        $(param).parent().parent().css("z-index", "10000");
    }
    else if ($(param).attr("class") == 'inactive') {
		$(param).attr("title","Expand");
        $(param).attr("class", "active");
        $(param).parent().parent().animate({ "height": "52px" });
        $(param).parent().next().css({ "position": "absolute", "left": "-10000px" });
        //$(param).parent().next().css("opacity","0");
    }
}
/*Changed by Indigo on 14-Nov-11 ends*/
function formsLiteratureResults(param, currElem) {
    if ($("#" + param).css("display") == 'none') {
        var totalHeight = $(currElem).parent().parent().parent().parent().height() + $("#" + param).height() + "px";
        $("#" + param).slideDown();
        $("#" + param).parent().parent().animate({ "height": totalHeight });
    }
}
/*** Functionality for Forms and Literature end ***/

/*** Continous Carousel start ***/

function mycarousel_initCallback(carousel) {
    $(".auto-scrolling-carousel .prev").bind('click', function () {
        carousel.prev();
        return false;
    });

    $(".auto-scrolling-carousel .next").bind('click', function () {
        carousel.next();
        return false;
    });
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function () {
        carousel.stopAuto();
    }, function () {
        carousel.startAuto();
    });
};
/*** Continous Carousel start ***/

/*  Send Email Code Starts  */

//Function move into the PrintSection.ascx control By Dilip.

/*  Send Email Code End  */

function FontStyler() {
    Cufon.replace('.primaryNav li a.first-lvl', { fontFamily: 'ErasItcTMed' });
    Cufon.replace('.myth-fact-text', { fontFamily: 'ErasItcTMed' });
    Cufon.replace('.word-of-day', { fontFamily: 'ErasItcTMed' });
    Cufon.replace('.title span', { fontFamily: 'ErasItcTDem', textTransform: 'uppercase' });
    Cufon.replace('.secondaryNav span.icon-helpline', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.cufon li', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.button span', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.global-footer-links-container ul li', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.floating-footer-links a', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.footer-recently-viewed', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.footer-my-watchlist', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.footer-uti-social', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.lhs-menu li a.first-lvl', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.landing-page-columns h2', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.landing-page-columns h3', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.helpdesk-content h2', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.helpdesk-links h3', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.hp-acc-tab-content .myth-content .myth-name', { fontFamily: 'ErasItcTMed' });
    Cufon.replace('.funds-filter-results-container-tbl-header div', { fontFamily: 'ErasItcTMed' });
    Cufon.replace('.heading', { fontFamily: 'ErasItcTMed' });
    Cufon.replace('.content h3', { fontFamily: 'ErasItcTDem' });
    Cufon.replace('.funds-finder-container-header div', { fontFamily: 'ErasItcTMed' });
    Cufon.replace('.social-connect .col .heading h2', { fontFamily: 'ErasItcTMed' });
    Cufon.replace('.sitemap .column h3', { fontFamily: 'ErasItcTMed' });
}

function FormStyler() {
    /**** Custom form controls start ****/
    if ($('select').attr("StyleAdded") == undefined) {
        $('select').selectbox();
    }
    $('input:checkbox').stylecheck();
    $('input:radio').stylecheck();
    $('input:text').stylecheck();
    /**** Custom form controls end ****/
}




function ControlStyler() {//debugger;
    //After adding style from jquery.style.form.js we marked as a StyleAdded as true.
    if ($('select').attr("StyleAdded") == undefined) {
        try {
            oHandler = $("select").not('[id*="EditorZone"]').not('[class*="AutoComplete"]').not('[class*="ui-datepicker-month"]').not('[class*="ui-datepicker-year"]').msDropDown().data("dd");
            oHandler.visible(true);
            $("#ver").html($.msDropDown.version);
        } catch (e) {
            //alert("Error: "+e.message);
        }

        if ($('.AutoComplete').length > 0) {
            $('.AutoComplete').combobox();
        }
    }
    //$('select').selectbox();
    $('input:checkbox').not('[id*="EditorZone"]').stylecheck();
    $('input:radio').not('[id*="EditorZone"]').stylecheck();
    $('input:text').not('[id*="EditorZone"]').stylecheck();

}

function TabReStyler() {

    if ($('.tab-content-wrapper').length > 0) {
        /*****Tab Content Functionality start *****/

        //$('.tab-content-wrapper').children('div').css('display', 'none');
        if ($.browser.msie && $.browser.version == '6.0') {
            $('.tab-content-wrapper').children('div').css('width', '100%');
        }
        else {
            $('.tab-content-wrapper').children('div').css({ 'float': 'left', 'width': '100%' });
        }
        // $('.tab-content-wrapper').find('div:first').css('display', 'block');
        //$('.tab-content-wrapper').find('li:first').addClass('sel');
        $('.tab-content-wrapper .tabs').find('li:last').css('margin-right', '0');

        if ($('.tab-content-wrapper').attr('id') == 'ajax-content') {
            var fundId = $('#ajax-content').find('.tabs').attr('id');
            var getClassFirstTab = $('.tab-content-wrapper ul:first-child').children('li').attr('class').split(/\s+/);
            var getIdFirstTab = $('.tab-content-wrapper ul:first-child').find('li:first').attr('id');

            $.get(fundId + '-' + getIdFirstTab + '.html', function (data) {
                $(".tab-content").html(data);
                Cufon.replace('.heading', { fontFamily: 'ErasItcTMed' });
            });
        }

        $('.tabs').children('li').click(function () {

            if ($(this).parent().parent().attr('id') == 'ajax-content') {
                //debugger;
                $.ajax({
                    type: "GET",
                    url: fundId + '-' + this.id + '.html',
                    dataType: "html",
                    success: function (data) {
                        $(".tab-content").html(data);
                        $(".tab-content").show('slow');
                        $(".tab-content .tabcontent").children('div').hide();
                        $(".tab-content .tabs").find('li:first').addClass('sel');
                        $(".tab-content .tabs1").find('li:first').removeClass('sel'); //
                        $('.tab-content .tabs').find('li:last').css('margin-right', '0');
                        $(".tab-content .tabcontent").each(function () {
                            $(this).children('div:first').show();
                        });

                        $(".tab-content .tabs").find('li').click(function () {
                            $(this).removeClass('sel');
                            var getClassName = this.className;
                            $(this).parent().siblings('div.tabcontent').children('div').hide();
                            $(this).parent().siblings('div.tabcontent').children('.' + getClassName + '-content').show();
                            $(this).siblings().removeClass('sel');
                            if ($(this).parent().next().is('ul')) {
                                $(this).parent().next().children('li').removeClass('sel');
                            }
                            else if ($(this).parent().prev().is('ul')) {
                                $(this).parent().prev().children('li').removeClass('sel');
                            }
                            $(this).addClass('sel');
                        })
                        Cufon.replace('.heading', { fontFamily: 'ErasItcTMed' });
                    },
                    error: function () {
                        $(".tab-content").html("Page not found");
                    }
                });
                $(this).parent().parent().find('li').removeClass('sel');
                $(this).addClass('sel');
            }
            else if ($(this).parent().parent().attr('id') == 'up-content') {
                //debugger;
                $('.' + this.className).parent().parent().children('div').css('display', 'none');
                $('.' + this.className).parent().parent().find('li').removeClass('sel');
                var selClass = '.' + this.className;
                $('.' + this.className).addClass('sel');
                $(selClass + '-content').fadeIn('slow');

                var OnSwitchFunctionName = $(this).parent().attr('id') + 'OnSwitch';

                if (typeof eval(OnSwitchFunctionName) != "undefined" && $.isFunction(eval(OnSwitchFunctionName))) {
                    eval(OnSwitchFunctionName + '(' + $(this).attr('index') + ')');
                }
            }
            else {
                //debugger;
                $('.' + this.className).parent().parent().children('div').css('display', 'none');
                $('.' + this.className).parent().parent().find('li').removeClass('sel');
                var selClass = '.' + this.className;
                $('.' + this.className).addClass('sel');
                $(selClass + '-content').fadeIn('slow');
            }
        });

        /*****Tab Content Functionality end *****/
    }
}

var varlitab;
function TabStyler(varlitab) {
    //debugger;
    //$('.tab-content-wrapper').find('li').removeClass('sel');
    varlitab.className = 'sel';
    //$(varlitab).click();
}
/**** Added By nitin For Providing Searchable textbox to dropdown ***/
var DropDownID;
function DropDownSearchBoxStyler(DropDownID) {
    debugger;
    /*Auto Search Box START*/

    (function ($) {
        //debugger;
        $.widget("ui.combobox", {
            _create: function () {
                //debugger;
                var self = this,
					select = this.element.hide(),
					selected = select.children(":selected"),
					value = selected.val() ? selected.text() : "";
                //var input = this.input = $("<input onblur=GetAlert('" + select[0].id + "');>")
                //select.wrap('<div class="select-wrapper"></div>')
                //                var input = this.input = $("<input>")

                //Get Property value for assigne Textbox
                var DropDownID = select.attr("id");
                var _txtClss = (select.attr("txtClass") == undefined) ? '' : select.attr("txtClass");
                var _alt = (select.attr("alt") == undefined) ? '' : select.attr("alt");
                var _title = (select.attr("title") == undefined) ? '' : select.attr("title");
                select.attr("StyleAdded", "True");
                //debugger;
                var _InputWidth = select.outerWidth();

                var input = this.input = $("<input style='width:" + _InputWidth + "px;' class=" + _txtClss + "  alt=" + _alt + "  title=" + _title + "  id='" + "Input" + DropDownID + "'>")

                //var dropDown = select[0];
                //var input = this.input = $('<input onblur="GetAlert('+ dropDown +')">')

					.insertAfter(select)
					.val(value)
					.autocomplete({
					    delay: 0,
					    minLength: 0,
					    source: function (request, response) {
					        var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
					        response(select.children("option").map(function () {
					            var text = $(this).text();
					            if (this.value && (!request.term || matcher.test(text)))
					                return {
					                    label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>"),
					                    value: text,
					                    option: this
					                };
					        }));

					    },
					    select: function (event, ui) {

					        ui.item.option.selected = true;
					        self._trigger("selected", event, {
					            item: ui.item.option
					        });
					        //on change fire post back event event
					        select.trigger('change');
					    },
					    change: function (event, ui) {

					        if (!ui.item) {
					            var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i"),
									valid = false;
					            select.children("option").each(function () {
					                if ($(this).text().match(matcher)) {
					                    this.selected = valid = true;
					                    //on change fire post back event event
					                    select.trigger('change');
					                    input.focus();

					                    //alert('Change');
					                    return false;
					                }
					            });
					            if (!valid) {
					                // remove invalid value, as it didn't match anything

					                select.value = "0";
					                var defaultValue = select.children(":selected").text();
					                $(this).val(defaultValue);
					                select.val(defaultValue);
					                input.data("autocomplete").term = defaultValue;
					                return false;
					            }
					        }
					    }
					})
					.addClass("ui-widget ui-widget-content ui-corner-left");

                input.data("autocomplete")._renderItem = function (ul, item) {

                    return $("<li></li>")
						.data("item.autocomplete", item)
						.append("<a>" + item.label + "</a>")
						.appendTo(ul);
                };

                input.click(function () {
                    // close if already visible

                    if (input.autocomplete("widget").is(":visible")) {

                        input.autocomplete("close");
                        return;
                    }

                    // work around a bug (likely same cause as #5265)
                    //$(this).blur();

                    // pass empty string as value to search for, displaying all results
                    input.autocomplete("search", "");
                });

                this.button = $("<button style='display:none;' type='button'>&nbsp;</button>")
					.attr("tabIndex", -1)
					.attr("title", "Show All Items")
					.insertAfter(input)
					.button({
					    icons: {
					        primary: "ui-icon-triangle-1-s"
					    },
					    text: false
					})
					.removeClass("ui-corner-all")
					.addClass("ui-corner-right ui-button-icon")
					.click(function () {
					    // close if already visible
					    if (input.autocomplete("widget").is(":visible")) {
					        input.autocomplete("close");
					        return;
					    }

					    // work around a bug (likely same cause as #5265)
					    $(this).blur();

					    // pass empty string as value to search for, displaying all results
					    input.autocomplete("search", "");
					});
            },

            destroy: function () {
                this.input.remove();
                this.button.remove();
                this.element.show();
                $.Widget.prototype.destroy.call(this);
            }
        });
    })(jQuery);

    /*Auto Search Box END*/

    $(DropDownID).combobox();
}

function loadChildSimpleTabs(parentControlID) {
    $('#' + parentControlID + ' .tabcontent').children('div').hide();
    $('#' + parentControlID + ' .tabs').find('li:first').addClass('sel');
    $('#' + parentControlID + ' .tabs1').find('li:first').removeClass('sel'); //
    $('#' + parentControlID + ' .tabs').find('li:last').css('margin-right', '0');
    $('#' + parentControlID + ' .tabcontent').each(function () {
        $(this).children('div:first').show();
    });

    $('#' + parentControlID + ' .tabs').find('li').click(function () {
        $(this).removeClass('sel');
        var getClassName = this.className;
        $(this).parent().siblings('div.tabcontent').children('div').hide();
        $(this).parent().siblings('div.tabcontent').children('.' + getClassName + '-content').show();
        $(this).siblings().removeClass('sel');
        if ($(this).parent().next().is('ul')) {
            $(this).parent().next().children('li').removeClass('sel');
        }
        else if ($(this).parent().prev().is('ul')) {
            $(this).parent().prev().children('li').removeClass('sel');
        }
        $(this).addClass('sel');
    })
}

/* Funds Manger Tab view start */
function view_fund_manager() {
    $(".tab-1").removeClass("sel");
    $(".tab-1-content").hide();
    $(".tab-4").addClass("sel");
    $(".tab-4-content").show();
    $("html,body").animate({
        scrollTop: $(".page-content").offset().top
    })
}
/* Funds Manger Tab view end */


$(function()
{
/** Added to open the respective tab **/
	var paramURL=location.href;
	//alert(paramURL.search("#"));
	if(paramURL.search("#")!=-1)
	{
		paramURL=paramURL.split("#");
		$(".tab-content-wrapper ul").find("li").each(function()
		{
			$(this).removeClass("sel");
			var thisIndex=$(this).index()+1;
			$(this).parents(".tab-content-wrapper").find(".tab-"+thisIndex+"-content").addClass("ui-tabs-hide");
			$(this).parents(".tab-content-wrapper").find(".tab-"+thisIndex+"-content").hide();
		})
		$(".tab-content-wrapper ul").find(".tab-"+paramURL[1]).addClass("sel");
		$(".tab-content-wrapper").find(".tab-"+paramURL[1]+"-content").removeClass("ui-tabs-hide");
		// Added by Indigo for Learn and Plan Tab show on 12/12/2011 starts here
			if($(".tab-content-wrapper").find(".tab-"+paramURL[1]+"-content").css("display")=="none")
			{
				$(".tab-content-wrapper").find(".tab-"+paramURL[1]+"-content").show();
			}
		// Added by Indigo for Learn and Plan Tab show on 12/12/2011 ends here
	}
	/** Added to open the respective tab ends **/

});
