/**
 * 
 *  Common used functions for JQuery
 *
 */

function expiration(section) {
		
	var nowDate = new Date();
	
	var nowDate = JSDateToExcelDate(nowDate);
	
	/*** us home, featured markets insights in center column ***/	
	if (section == "featured_market_insights"){
		
		$.ajax({
			type: "GET",
			url: "xml/exp_home_featured_market_insights.xml",
			dataType: "xml",
			success: function(xml) {
				
				/* count the number of records so we can do a different style for the last item (no divider line) */
				x = 0;
				total = $(xml).find('Expiration_Item').length;
									
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					var format_text = $(this).find('Format').text();
					
					/* set the HTML to display or not based on exp date */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					/* 1 - chose which icon to show with what 'alt' text for that image */
					/* 2 - choose link format from whitepaper, newsletter, or webcast */
					if (format_text == "White Paper") {
						var format = "icon-whitepaper.jpg";
						var formatAlt = "whitepaper";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}
					if (format_text == "Webcast") {
						var format = "icon-webcast.jpg";
						var formatAlt = "webcast";
						var formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>"
					}
					if (format_text == "Newlsetter") {
						var format = "icon-newsletter.jpg";
						var formatAlt = "newsletter";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}	
					
					
					/* build the HTML string */
					
					x += 1;
					
					strToAppend = "<span " + alertStyle + ">" +
								"<div class='portlet-content-pic'><img src='images/" + format + "' alt='" + formatAlt + "'></div>" + 
								"<div class='portlet-content-text'>" +
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<p>" + description_text + "</p>" +
								"<div class='link-wrapper'>" + formatLink + "</div>" +
								"</div>";					
					
					/* apply a different style to the last item only: get rid of divider line */
					if (x < total){
						strToAppend += "<div class='rule'></div>" +
								"<div class='spacer-15'></div>" +
								"</span>";
					}
					if (x == total){
						strToAppend += "</span>";
					}
					
					
					/* take the entire string and add it to the div on the page */
					$('#exp-featured-market-insights-items').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/
	
	
	
	/*** us home, accordion ***/
	if (section == "pyramis_glance"){
		
		$.ajax({
			type: "GET",
			url: "xml/exp_home_pyramis_glance.xml",
			dataType: "xml",
			fail: function() { alert("can't find " + url) },
			success: function(xml) {
									
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					
					/* expiration routine using nowDate from the top of this function */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					strToAppend = "<span " + alertStyle + ">" +
								"<div class='link-wrapper'><a href='" + url_text + "' target='_blank' class='button-silver'>" + title_text + " &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a></div>" +
								"</span>";
										
					$('#pyramis-glance-01').append(strToAppend);
					$('#pyramis-glance-02').append(strToAppend);
											 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close XML section	
	/*****/
	
	
	
	/*** pyramis in the news ***/
	if (section == "news"){
			
		$.ajax({
			type: "GET",
			url: "xml/exp_news.xml",
			dataType: "xml",
			success: function(xml) {
				
				$(xml).find('News_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					
					/* expiration routine using nowDate from the top of this function */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					strToAppend = "<span " + alertStyle + ">" +
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<p>" + description_text + "</p>" +
								"<div class='link-wrapper'><a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a></div>" +
								"<div class='rule'></div>" +
								"</span>";
										
					$('#news-items').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/
	
	
	/*** entire us site, pyramis news in the accordion, single item ***/
	if (section == "news_accordion"){
			
		$.ajax({
			type: "GET",
			url: "xml/exp_acc_pyramis_news.xml",
			dataType: "xml",
			success: function(xml) {
				
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
												
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					strToAppend = "<span " + alertStyle + ">" +
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p><br>" +
								"<p>" + description_text + "</p><br>" +
								"<div class='link-wrapper'><a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a></div>" +
								"</span>";
										
					$('#news-acc-items').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/
	
	
	
	/*** EQUITY - Insights & Events ***/
	if (section == "equity-insights-events"){
				
		$.ajax({
			type: "GET",
			url: "xml/exp_equity_insights_events.xml",
			dataType: "xml",
			success: function(xml) {
				
				/* count the number of records so we can do a different style for the last item (no divider line) */
				x = 0;
				total = $(xml).find('Expiration_Item').length;
									
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					var format_text = $(this).find('Format').text();
					
					/* set the HTML to display or not based on exp date */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					/* 1 - chose which icon to show with what 'alt' text for that image */
					/* 2 - choose link format from whitepaper, newsletter, or webcast */
					if (format_text == "White Paper") {
						var format = "icon-whitepaper.jpg";
						var formatAlt = "whitepaper";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}
					if (format_text == "Webcast") {
						var format = "icon-webcast.jpg";
						var formatAlt = "webcast";
						var formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>"
					}
					if (format_text == "Newsletter") {
						var format = "icon-newsletter.jpg";
						var formatAlt = "newsletter";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}	
					
					
					/* build the HTML string */
					
					x += 1;
					
					strToAppend = "<span " + alertStyle + ">" +
								"<img class='img-left' src='images/" + format + "' alt='" + formatAlt + "'>" + 
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<br>" +
								"<p>" + description_text + "</p>" +
								"<br>" +
								"<div class='link-wrapper'>" + formatLink + "</div>";	
								
					/* apply a different style to the last item only: get rid of divider line */
					if (x < total){
						strToAppend += "<div class='rule'></div>" +
								"</span>";
					}
					if (x == total){
						strToAppend += "</span>";
					}
					
					/* take the entire string and add it to the div on the page */
					$('#exp-equity-insights-events').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/



	/*** FIXED INCOME - Insights & Events ***/
	if (section == "fixed-income-insights-events"){
				
		$.ajax({
			type: "GET",
			url: "xml/exp_fixed_income_insights_events.xml",
			dataType: "xml",
			success: function(xml) {
				
				/* count the number of records so we can do a different style for the last item (no divider line) */
				x = 0;
				total = $(xml).find('Expiration_Item').length;
									
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					var format_text = $(this).find('Format').text();
					
					/* set the HTML to display or not based on exp date */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					/* 1 - chose which icon to show with what 'alt' text for that image */
					/* 2 - choose link format from whitepaper, newsletter, or webcast */
					if (format_text == "White Paper") {
						var format = "icon-whitepaper.jpg";
						var formatAlt = "whitepaper";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}
					if (format_text == "Webcast") {
						var format = "icon-webcast.jpg";
						var formatAlt = "webcast";
						var formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>"
					}
					if (format_text == "Newsletter") {
						var format = "icon-newsletter.jpg";
						var formatAlt = "newsletter";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}	
					
					
					/* build the HTML string */
					
					x += 1;
					
					strToAppend = "<span " + alertStyle + ">" +
								"<img class='img-left' src='images/" + format + "' alt='" + formatAlt + "'>" + 
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<br>" +
								"<p>" + description_text + "</p>" +
								"<br>" +
								"<div class='link-wrapper'>" + formatLink + "</div>";
								
					/* apply a different style to the last item only: get rid of divider line */
					if (x < total){
						strToAppend += "<div class='rule'></div>" +
								"</span>";
					}
					if (x == total){
						strToAppend += "</span>";
					}					
					
					/* take the entire string and add it to the div on the page */
					$('#exp-fixed-income-insights-events').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/



	/*** ASSET ALLOCATION - Insights & Events ***/
	if (section == "asset-alloc-insights-events"){
				
		$.ajax({
			type: "GET",
			url: "xml/exp_asset_alloc_insights_events.xml",
			dataType: "xml",
			success: function(xml) {
				
				/* count the number of records so we can do a different style for the last item (no divider line) */
				x = 0;
				total = $(xml).find('Expiration_Item').length;
									
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					var format_text = $(this).find('Format').text();
					
					/* set the HTML to display or not based on exp date */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					/* 1 - chose which icon to show with what 'alt' text for that image */
					/* 2 - choose link format from whitepaper, newsletter, or webcast */
					if (format_text == "White Paper") {
						var format = "icon-whitepaper.jpg";
						var formatAlt = "whitepaper";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}
					if (format_text == "Webcast") {
						var format = "icon-webcast.jpg";
						var formatAlt = "webcast";
						var formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>"
					}
					if (format_text == "Newsletter") {
						var format = "icon-newsletter.jpg";
						var formatAlt = "newsletter";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}	
					
					
					/* build the HTML string */
					
					x += 1;
					
					strToAppend = "<span " + alertStyle + ">" +
								"<img class='img-left' src='images/" + format + "' alt='" + formatAlt + "'>" + 
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<br>" +
								"<p>" + description_text + "</p>" +
								"<br>" +
								"<div class='link-wrapper'>" + formatLink + "</div>";
								
					/* apply a different style to the last item only: get rid of divider line */
					if (x < total){
						strToAppend += "<div class='rule'></div>" +
								"</span>";
					}
					if (x == total){
						strToAppend += "</span>";
					}					
					
					/* take the entire string and add it to the div on the page */
					$('#exp-asset-alloc-insights-events').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/

	
	
	/*** ALTERNATIVES - Insights & Events ***/
	if (section == "alternatives-insights-events"){
				
		$.ajax({
			type: "GET",
			url: "xml/exp_alternatives_insights_events.xml",
			dataType: "xml",
			success: function(xml) {
				
				/* count the number of records so we can do a different style for the last item (no divider line) */
				x = 0;
				total = $(xml).find('Expiration_Item').length;
									
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					var format_text = $(this).find('Format').text();
					
					/* set the HTML to display or not based on exp date */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					/* 1 - chose which icon to show with what 'alt' text for that image */
					/* 2 - choose link format from whitepaper, newsletter, or webcast */
					if (format_text == "White Paper") {
						var format = "icon-whitepaper.jpg";
						var formatAlt = "whitepaper";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}
					if (format_text == "Webcast") {
						var format = "icon-webcast.jpg";
						var formatAlt = "webcast";
						var formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>"
					}
					if (format_text == "Newsletter") {
						var format = "icon-newsletter.jpg";
						var formatAlt = "newsletter";
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					}	
					
					
					/* build the HTML string */
					
					x += 1;
					
					strToAppend = "<span " + alertStyle + ">" +
								"<img class='img-left' src='images/" + format + "' alt='" + formatAlt + "'>" + 
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<br>" +
								"<p>" + description_text + "</p>" +
								"<br>" +
								"<div class='link-wrapper'>" + formatLink + "</div>";
								
					/* apply a different style to the last item only: get rid of divider line */
					if (x < total){
						strToAppend += "<div class='rule'></div>" +
								"</span>";
					}
					if (x == total){
						strToAppend += "</span>";
					}					
					
					/* take the entire string and add it to the div on the page */
					$('#exp-alternatives-insights-events').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/
	
	
	/*** MARKET INSIGHTS / Newsletters ***/	
	if (section == "market_insights_newsletters"){
		
		$.ajax({
			type: "GET",
			url: "xml/exp_market_insights_newsletters.xml",
			dataType: "xml",
			success: function(xml) {
				
				/* count the number of records so we can do a different style for the last item (no divider line) */
				x = 0;
				total = $(xml).find('Expiration_Item').length;

				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					var format_text = $(this).find('Format').text();
					
					/* set the HTML to display or not based on exp date */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					
					/* build the HTML string */
					
					x += 1;
					
					strToAppend = "<span " + alertStyle + ">" +
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<p>" + description_text + "</p>" +
								"<div class='link-wrapper'>" + formatLink + "</div>";
									
					/* apply a different style to the last item only: get rid of divider line */
					if (x < total){
						strToAppend += "<div class='rule'></div>" +
								"</span>";
					}
					if (x == total){
						strToAppend += "</span>";
					}		
										
					$('#exp-market-insights-newsletters').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/

	
	/*** NEWS ***/	
	if (section == "pyramis_news"){
		
		$.ajax({
			type: "GET",
			url: "xml/exp_pyramis_news.xml",
			dataType: "xml",
			success: function(xml) {
				
				/* count the number of records so we can do a different style for the last item (no divider line) */
				x = 0;
				total = $(xml).find('Expiration_Item').length;

				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					var format_text = $(this).find('Format').text();
					
					/* set the HTML to display or not based on exp date */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					
					/* build the HTML string */
					
					x += 1;
					
					strToAppend = "<span " + alertStyle + ">" +
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<p>" + description_text + "</p>" +
								"<div class='link-wrapper'>" + formatLink + "</div>";
									
					/* apply a different style to the last item only: get rid of divider line */
					if (x < total){
						strToAppend += "<div class='rule'></div>" +
								"</span>";
					}
					if (x == total){
						strToAppend += "</span>";
					}		
										
					$('#exp-pyramis-news').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/



	/*** MARKET INSIGHTS - WHITE PAPERS ***/	
	if (section == "market_insights_whitepapers"){
		
		$.ajax({
			type: "GET",
			url: "xml/exp_market_insights_whitepapers.xml",
			dataType: "xml",
			success: function(xml) {
				
				/* count the number of records so we can do a different style for the last item (no divider line) */
				x = 0;
				total = $(xml).find('Expiration_Item').length;
				
				/* track total count of items in categories */
				count_E = 0;
				count_ALT = 0;
				count_FI = 0;
				count_AA = 0;
				count_PPA = 0;
				count_RM = 0;
				count_DB = 0;
				
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
					var format_text = $(this).find('Format').text();
					var category_text = $(this).find('Category').text();
					
					/* set the HTML to display or not based on exp date */
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='images/icon-pdf.gif' alt='PDF'></a>";
					
					var backToTop = "<div class='back-to-top'><p>[ <a href='#tabs-2' class='back-to-top'>back to top</a> ]</p></div>";
					
					/* build the HTML string */
					/* current categories are: Equity, Market Neutral, Fixed Income, Lifecycle
												PPA, Risk Management, Defined Benefit */
					
					x += 1;
					
					strToAppend_E = "";
					strToAppend_ALT = "";
					strToAppend_FI = "";
					strToAppend_AA = "";
					strToAppend_PPA = "";
					strToAppend_RM = "";
					strToAppend_DB = "";
										
					basicFormat = 	"<span " + alertStyle + ">" +
									"<h2>" + title_text + "</h2>" +
									"<p><em>" + date_text + "</em></p>" +
									"<p>" + description_text + "</p>" +
									"<div class='link-wrapper'>" + formatLink + "</div>" +
									"<div class='spacer-20'></div>";
	
					
					if (category_text == "Equity") {
						strToAppend_E += basicFormat;
						count_E += 1;
					} 
					
					if (category_text == "Alternatives") {
						strToAppend_ALT += basicFormat;
						count_ALT += 1;
					}
					
					if (category_text == "Fixed Income") {
						strToAppend_FI += basicFormat;		
						count_FI += 1;
					}
					
					if (category_text == "Asset Allocation") {
						strToAppend_AA += basicFormat;		
						count_AA += 1;
					}
					
					if (category_text == "PPA") {
						strToAppend_PPA += basicFormat;	
						count_PPA += 1;
					}
					
					if (category_text == "Risk Management") {
						strToAppend_RM += basicFormat;		
						count_RM += 1;
					}
					
					if (category_text == "Defined Benefit") {
						strToAppend_DB += basicFormat;		
						count_DB += 1;
					}
					
					
					
					/* at the end, if the count of a category is zero, display message */

					var msgNoResearch = "<p><em>No available research at this time</em></p><br>";
					
					var msgArray = new Array('E',
											 'ALT',
											 'FI',
											 'AA',
											 'PPA',
											 'RM',
											 'DB');
					
					if (x == total){
	
						for(i=0;i<msgArray.length;i+=1){
						
							if (eval("count_" + msgArray[i]) == 0) {
								eval("strToAppend_" + msgArray[i] + " += msgNoResearch");
							}	
							
						}
						
					};
					
					
					
					/* at the end, apply a different style to the last item only: get rid of divider line */
					
					if (x == total){
						strToAppend_E += backToTop;
						strToAppend_ALT += backToTop;
						strToAppend_FI += backToTop;
						strToAppend_AA += backToTop;
						strToAppend_PPA += backToTop;
						strToAppend_RM += backToTop;
						strToAppend_DB += backToTop;
					}		
										
					$('#exp-whitepapers-e').append(strToAppend_E);
					$('#exp-whitepapers-alt').append(strToAppend_ALT);
					$('#exp-whitepapers-fi').append(strToAppend_FI);
					$('#exp-whitepapers-aa').append(strToAppend_AA);
					$('#exp-whitepapers-ppa').append(strToAppend_PPA);
					$('#exp-whitepapers-rm').append(strToAppend_RM);
					$('#exp-whitepapers-db').append(strToAppend_DB);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/
	
	
	
	/*** ldi white papers micro page @ http://pyramis.com/ldi-whitepapers ***/	
	if (section == "exp-ldi-whitepapers"){
		
		$.ajax({
			type: "GET",
			url: "../xml/exp_ldi_whitepapers.xml",
			dataType: "xml",
			success: function(xml) {
									
				$(xml).find('Expiration_Item').each(function(){
					
					var title_text = $(this).find('Title').text();
					var date_text = $(this).find('Display_Date').text();
					var description_text = $(this).find('Description').text();
					var url_text = $(this).find('URL').text();
					var expiration_text = $(this).find('Expiration_Date').text();
						
					if (nowDate < expiration_text && expiration_text != "n/a"){
						var alertStyle = "style='display: block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						var alertStyle = "style='display: none'";
					} else {
						var alertStyle = "style='display: block'";
					}
					
					strToAppend = "<span " + alertStyle + ">" +
								"<h2>" + title_text + "</h2>" +
								"<p><em>" + date_text + "</em></p>" +
								"<p>" + description_text + "</p>" +
								"<div class='link-wrapper'><a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='../images/icon-pdf.gif' alt='PDF'></a></div>" +
								"<div class='rule'></div>" +
								"</span>";
										
					$('#exp-ldi-whitepapers').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	}; //close if
	/*****/


	
/* end of expiration section */	
}; //close $(
