var MF = MF || {};

MF.Navigation=function ()
{
	var hiddenClass = 'visuallyhidden', openClass = 'open', activeClass = 'active', $nav = $('nav.main'), $ul = $('ul',$nav), $li = $('li',$ul), $shim = "<div id='navShim'></div>";
	function NavClick (id)
	{
		var $elm = id, $parent = $elm.parent('li');
		$('.active',$nav).removeClass(activeClass);
		if ($elm.hasClass(openClass)) { if ($('#navShim').length === 1) { $('#navShim').remove(); } $elm.removeClass(openClass).addClass(hiddenClass); $parent.removeClass(activeClass); }
		else { $('.open',$li).removeClass(openClass).addClass(hiddenClass); if ($('#navShim').length === 0) { $('body').append($shim); $('#navShim').height($(window).height()).click(function (e) { e.preventDefault(); $('.active',$nav).removeClass(activeClass); $('.open',$li).removeClass(openClass).addClass(hiddenClass); $(this).remove(); }); } $parent.addClass(activeClass); $elm.removeClass(hiddenClass).addClass(openClass); }
	}
	$li.children('a').each(function () { var $this = $(this), h = $('#'+$this.attr('href').split('#')[1]); $this.click(function (e) { e.preventDefault(); NavClick(h); }); });
	$('.flyout',$li).children('.close').each(function () { var $this = $(this), p = $this.parent('.flyout'); $this.click(function (e) { e.preventDefault(); NavClick(p); }); });
	
	$('.flyout .content').each(function ()
	{
		var dlh = 0;
		$(this).find('dl').each(function ()
		{
			var $this = $(this);
			if ($this.height() >= dlh) { dlh = $this.height(); }
		}).height(dlh);
	});
	
};

MF.setCookie=function(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

MF.getCookie=function(c_name)
{
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	{
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x=x.replace(/^\s+|\s+$/g,"");
		if (x==c_name) return unescape(y);
	}
	
	return null;
}

MF.getQueryStringVariable=function(val)
{
    var hu = window.location.search.substring(1);
    var gy = hu.split("&");

    for (i = 0; i < gy.length; i++) {
        var ft = gy[i].split("=");
        if (ft[0].toLowerCase() == val.toLowerCase()) {
            return ft[1];
        }
    }

    return '';
}


$(function(){
	MF.Navigation();
}); 


$(function()
{
	$(".accordion2 h3").eq(0).addClass("active");
	$(".accordion2 p").eq(0).show();
	
	$(".accordion2 h3").click(function()
	{
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});
});



$(function ()
{
	$("#expertise").selectbox();
	$("#accolades").selectbox();
	$("#accordion1").accordion( {autoHeight: false} );
	$("#accordion2").accordion({autoHeight: false} ); 
	$("#accordion3").accordion({autoHeight: false} ); 
	$("#accordion4").accordion({autoHeight: false} ); 
	$('#tabs').tabs();
});


$(function ()
{
	if ($.browser.msie && $.browser.version=="7")
	{
		$("#slider2").easySlider(
		{ 
			auto:true,
			continuous:true,
			numeric: true
		});
	}
});	



$(document).ready(function()
{

	//if ($('.breadcrumb').children().length > 4) {
	//	$('.breadcrumb div:gt(3)').remove();
	//}


	$("div.breadcrumb a[href*='/MF_Content/Mutual+Funds+Home']").each(function()
	{              
      	this.href = this.href.replace("/MF_Content/Mutual+Funds+Home","").replace(/\+/g,"").toLowerCase();
	});


    	for(var i = 0; i <= $(".profile_canvas").length; i+=4){
    	    $(".profile_canvas:nth-child("+(i+1)+")").attr("style","background-color: #FEF7EA");
    	    $(".profile_canvas:nth-child("+(i+2)+")").attr("style","background-color: #FEF7EA");
    	}
    	$(".profile_canvas:odd").removeClass("profile_canvas").addClass("profile_canvas2");
 });  
