// delinstmac audience jquery
//finding what page we're on 
var url = window.location.href;
	if( url.match("/lfg/delinstmac/prf/isc/") ) {
		page = "inst_prf";
	} else if(url.match("/lfg/delinstmac/ist/vip")){
		page = "vip";
	} else{
		page = "";
	}
$(document).ready(function(){
/*adding column to fund facts table for waiver dates from an xml file
and adding a disclosure depending on if its Contractual or Voluntary*/
if(page == "inst_prf"){

	var inst_ary = url.split("/");
	if(inst_ary.length > 11){
		var plcment = inst_ary.length -1;
		var pg_fnd_cod = inst_ary[plcment];
	}else{
		var pg_fnd_cod = inst_ary[8];
	}
	
	$.ajax({
		url: 'http://www.lfg.com/lfg/delmac/includes/fund_exp_limits_dis.xml',
		type: 'GET',
		dataType: 'xml',
		timeout: 1000,
		success: function(data){
			$(data).find('Fund').each(function() {
				var $fund = $(this);
				var xml_fund_code = $fund.find('fund_code').text();
				var expns_dis = $fund.find('disclosure').text();

				//if the fund code from the xml doc matches the fund of the page we're on then display the dates
				if(xml_fund_code == pg_fnd_cod){
					var dis_para = "<p class='legalText'>"+expns_dis+"</p>";
					var dis_para_ishr = "<p id='fees_waivers' class='disclosure_482'>"+expns_dis+"</p>";
					$("#ishare-expenses").after(dis_para_ishr);
				}
			});//ending .each function
		}
	}); //ending ajax to bring in xml
	
	//hiding the printer friendly button because the jquery above doesn't print w/it.
	$('img[src$="/lfg/img/common/b_printfriendly.gif"]').parents('a:first').hide(); 
}//end fund facts page if for waivers info

if(page == "vip"){
	// UCITS cookie session
	var cookie_value_ses = $.cookies.get('del_vip_ses', {path : '/'});
	var cookie_value_hlf = $.cookies.get('del_vip_hlf', {path : '/'});
	
	if(cookie_value_ses != "full_acpt")
	{
		$('#popup_dis').modal();
	}else if(cookie_value_hlf != "full_acpt"){
		$('#popup_dis').modal();
	}else{
		$("#popup_dis").hide();
	}

	
	$('#agree').click(function () {
		$.cookies.set('del_vip_ses', 'full_acpt', {path : '/'});
		$.cookies.set('del_vip_hlf', 'full_acpt', {path : '/', hoursToLive: .5});
		$.modal.close();
		$("#popup_dis").hide();
	});
	
	$('#disagree').click(function () {
		window.location = "http://www.lfg.com/lfg/delinstmac/ist/index.html";
	});
	
	var window_height = $(window).height();
	var new_window_height = window_height + 50;
	$('#simplemodal-overlay').height(new_window_height);
}//end vip


});
