willow.fixPodiumNav();

willow.ready(function($) {
  	$('#search').pdSearch({showButtonClass:'searchSubmit',showButtonText:''});
	var $sitemap = $(".sitemap");
	//menu code
	willow.getMenu("136339|136340|136341|136342|136343|136344",function(data){
		$('#L1').menu(data.menu,{showL3s: false, currentL1:pdGlobal.currentPages[0].id});
		if($sitemap.length > 0){
			$sitemap.sitemap(data);             
		}
    });
	/* Moved to banner html. Customer was complaining about homepage style not loading in first millisecond.
	if(pdGlobal.currentPages[0] !== undefined){
		if(pdGlobal.currentPages[0].id == 136338){
			if(pdGlobal.currentPageLevel == 1){ 
			//this check is so that it doesn't add the class on news detail and more event pages from the homepage
			$("body").addClass("homepage");
			$("#L1_136339").attr("hoffset","-32");
			$("#L1_136340").attr("hoffset","-38");
			$("#L1_136341").attr("hoffset","-42");
			$("#L1_136342").attr("hoffset","-39");
			$("#L1_136343").attr("hoffset","-50");
			$("#L1_136344").attr("hoffset","-97");
			}
		}
	}*/
	//annual fund
     $(".annualFund").annualfund();
	//code to get flyout menus not to hide behide left column in IE
	$("#GL_un_-1").mouseover(function(){
		var p = $("TABLE.u2g").parent();
		var l = p.css('left');
		var nl = parseInt(l) - parseInt($('#Form1').offset().left);
		nl = nl - 17;
		p.css('left',nl);
	});
	$("#GL_c5i0_sn_-1").mouseover(function(){
		var p = $("TABLE.s3g").parent();
		var l = p.css('left');
		var nl = parseInt(l) - parseInt($('#Form1').offset().left);
		nl = nl - 17;
		p.css('left',nl);
	});
	
	//footer social media links
	willow.getLinks(14859,function(data){
		if(data.link.length === 0){return;}
		$("#footerLinkTemplate").tmpl(data.link,{
			target : willow.checkTarget,
			img : willow.checkImg,
			url : willow.checkHTTP
		}).appendTo("#leftFootLinks");		
	});	
	//bulletin options
	var options = {
		emButton: false,
		data: [
			{type:"announcement",id:3724}
		]
	};		 
	//bulletin
	$('#Form1').bulletin(options);
});	
// Checks to see if self managed link has the 'open in new tab' flag set 
willow.checkTarget = function(target){
	if(target === 1 || target === true || target === "true"){
		return " target='_blank'";
	}
	return "";
};
// Checks to see if self managed link has an image
willow.checkImg = function(link){
	if(typeof link.data.image !== "undefined"){
		if(link.data.image.height > 0 && link.data.image.width > 0){
			return "<img src='"+link.data.image.path+"' height='"+link.data.image.height+"' width='"+link.data.image.width+"' alt='"+link.data.title+"' border='0'/>"
		}else{
			return "<img src='"+link.data.image.path+"' alt='"+link.data.title+"' border='0'/>"
		}
	}
	return link.data.title;
}
//checks if link has http in it
willow.checkHTTP = function(url){
	if(url.slice(0,3) != "http"){
		return "http://"+url;
	}else{
		return url;
	}
}

