// delcemac audience jquery

var url = window.location.href; 

$(document).ready(function(){

		// hiding the D.D.L.P. disclosure on the products pages
		/*if(url.match("2Fdelcemac")) {			
			$('td.bodytext p.legalText:last').next().hide(); 
			$('td.bodytext p.legalText:last').next().next().hide();
		}*/
		
		if(url.match("2Fdelcemac")) {
			var DDLP = $('td.bodytext').children('p.bodyText:last');
			DDLP.hide();
			DDLP.prev().hide();
			
			var fundsManagedList = $('tr td.hd1-3:contains("Other funds managed")').parent().next();
			fundsManagedList.attr('id','fundsManaged');
					
			$('#fundsManaged a').each(function(i){								   
				var fundsManagedName = $(this).text();
				$(this).replaceWith(fundsManagedName);
			});
			
		}
		
		
		/* Injecting commentaries to the L4 box */
		var equityComm = '<td valign="top" align="left" class="bodytext"><ul class="l4List"><li class="l4List"><a href="http://www.delawareinvestments.com/share/web_uploads/retail/closed_end/commentaries/cls_equity_comm.pdf" class="l4-item" target="_blank">Commentary</a></li></ul></td>';
		
		var muniComm = '<td valign="top" align="left" class="bodytext"><ul class="l4List"><li class="l4List"><a href="http://www.delawareinvestments.com/share/web_uploads/retail/closed_end/commentaries/cls_muni_comm.pdf" class="l4-item" target="_blank">Commentary</a></li></ul></td>';
		
		var equityLinks = new Array;
		equityLinks = ["/cls/dif", "%2Fdif", "/cls/dex", "%2Fdex", "/cls/dgf", "%2Fdgf"];
		var muniLinks = new Array;
		muniLinks = ["/cls/vaz", "%2Fvaz", "/cls/vcf", "%2Fvcf", "/cls/vfl", "%2Fvfl", "/cls/vmm", "%2Fvmm"];
		
		for(var i = 0; i < equityLinks.length; i++){
			if(url.match(equityLinks[i])) {
			$('ul.l4List:last').parent().after(equityComm);
		}}
		
		for(var i = 0; i < muniLinks.length; i++){
			if(url.match(muniLinks[i])) {
			$('ul.l4List:last').parent().after(muniComm);
		}}

	
		
		// replacing press releases link on fund center pages
		$("a[href*='/lfg/delmac/abt/dpr']").attr('href','http://www.lfg.com/LincolnPageServer?LFGPage=/lfg/delcemac/add/cls/dpr/index.html');
		
		// quarterly updates links replacement
		$('li a:contains("Quarterly updates")').replaceWith('<a href="http://www.lfg.com/LincolnPageServer?LFGPage=/lfg/delcemac/prf/index.html" class="l4-item">Quarterly updates</a>');

});
