/**
 * 
 *  Common used functions for JQuery
 *
 */

function expiration(section) {
		
	var nowDate = new Date();
	
	nowDate = JSDateToExcelDate(nowDate);
	
	/*** us home, featured markets insights in center column ***/	
	if (section == "featured_market_insights"){
		
		$.ajax({
			type: "GET",
			url: "xml/exp_uk_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") {
						alertStyle = "style='display: none'";
					} else {
						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") {
						format = "icon-webcast.jpg";
						formatAlt = "webcast";
						formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>";
					}
					if (format_text == "Newlsetter") {
						format = "icon-newsletter.jpg";
						formatAlt = "newsletter";
						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_uk_home_pyramis_glance.xml",
			dataType: "xml",
			fail: function() { alert("can't find " + url); },
			success: function(xml) {

				var strToAppend_factsheet = "";
				var strToAppend_timeline = "";

				$(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") {
						alertStyle = "style='display: none'";
					} else {
						alertStyle = "style='display: block'";
					}
					
					strToAppend_factsheet = "<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-02').append(strToAppend_factsheet);
					
					
				}); //close each(
				
				strToAppend_timeline += "<div class='timeline-event y2010'><p class='marker-year'>2010</p><p class='marker-title'>Pyramis Expands to Asia</p><p>Pyramis opens distribution office in Hong Kong.</p></div>";
				strToAppend_timeline += "<div class='timeline-event y2009'><p class='marker-year'>2009</p><p class='marker-title'>Pyramis Grows Global Distribution</p><p>Pyramis adds distribution presence in Europe and the Middle East.</p></div>";
				strToAppend_timeline += "<div class='timeline-event y2008'><p class='marker-year'>2008</p><p class='marker-title'>Pyramis Expands</p><p>Pyramis opens offices in Canada and the United Kingdom.</p></div>";
				strToAppend_timeline += "<div class='timeline-event y2005'><p class='marker-year'>2005</p><p class='marker-title'>Pyramis Formed</p><p>Pyramis Global Advisors is formed to focus on institutional investing.</p></div>";
				strToAppend_timeline += "<div class='timeline-event y1981'><p class='marker-year'>1981</p><p class='marker-title'>Fidelity Management Trust Company Established</p><p>Fidelity Management Trust Company is established to offer trustee and investment management services to institutional clients.</p></div>";
				strToAppend_timeline += "<div class='timeline-event y1969'><p class='marker-year'>1969</p><p class='marker-title'>FIL Limited is Founded</p><p>FIL Limited, a leading asset manager in Europe and the Asia-Pacific region, is founded.</p></div>";
				strToAppend_timeline += "<div class='timeline-event y1964'><p class='marker-year'>1964</p><p class='marker-title'>Fidelity Investments Establishes FMR Investment Management Service, Inc.</p><p>Created to provide investment advisory services to large corporate pension clients.</p></div>";
				strToAppend_timeline += "<div class='timeline-event marker-first'><p class='marker-year'>1946</p><p class='marker-title'>Fidelity Investments is Founded</p><p>Established Fidelity Management &amp; Research Company (FMRCo.), which is now the investment advisor to one of the largest mutual fund companies in the US.</p></div>";
				
				$('#pyramis-glance-01').append(strToAppend_timeline);
				
			} //close success:			
		}); //close $.ajax(
		
	} //close XML section	
	/*****/
	
	
	
	/*** pyramis in the news ***/
	if (section == "news"){
			
		$.ajax({
			type: "GET",
			url: "xml/exp_uk_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") {
						alertStyle = "style='display: none'";
					} else {
						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_uk_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") {
						alertStyle = "style='display: none'";
					} else {
						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>" +
								"<div class='link-wrapper'><a href='" + url_text + "' target='_blank' class='button-silver'>View webcast &raquo; </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_uk_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: inline-block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						alertStyle = "style='display: none'";
					} else {
						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") {
						format = "icon-webcast.jpg";
						formatAlt = "webcast";
						formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>";
					}
					if (format_text == "Newsletter") {
						format = "icon-newsletter.jpg";
						formatAlt = "newsletter";
						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_uk_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: inline-block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						alertStyle = "style='display: none'";
					} else {
						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") {
						format = "icon-webcast.jpg";
						formatAlt = "webcast";
						formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>";
					}
					if (format_text == "Newsletter") {
						format = "icon-newsletter.jpg";
						formatAlt = "newsletter";
						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_uk_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: inline-block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						alertStyle = "style='display: none'";
					} else {
						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") {
						format = "icon-webcast.jpg";
						formatAlt = "webcast";
						formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>";
					}
					if (format_text == "Newsletter") {
						format = "icon-newsletter.jpg";
						formatAlt = "newsletter";
						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_uk_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: inline-block'";
					} else if (nowDate >= expiration_text && expiration_text != "n/a") {
						alertStyle = "style='display: none'";
					} else {
						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") {
						format = "icon-webcast.jpg";
						formatAlt = "webcast";
						formatLink = "<a href='" + url_text + "' class='button-silver'>View this webcast &raquo;</a>";
					}
					if (format_text == "Newsletter") {
						format = "icon-newsletter.jpg";
						formatAlt = "newsletter";
						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_uk_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") {
						alertStyle = "style='display: none'";
					} else {
						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_uk_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") {
						alertStyle = "style='display: none'";
					} else {
						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_uk_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;

				$(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") {
						alertStyle = "style='display: none'";
					} else {
						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-whitepapers').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	} //close if
	/*****/
	/*****/
	


/*** Campaign Defined Benefits ***/	
	if (section == "campaign_defined_benefits"){
		
		$.ajax({
			type: "GET",
			url: "../../xml/exp_uk_campaign_defined_benefits.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();
					var section_text = $(this).find('Section').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") {
						alertStyle = "style='display: none'";
					} else {
						alertStyle = "style='display: block'";
					}
					
					if (section_text == "White Papers" || section_text == "Whitepapers"){
						var formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='../../images/icon-pdf.gif' alt='PDF'></a>";
					}
					
					if (section_text == "Webcasts"){
						formatLink = "<a href='" + url_text + "' target='_blank' class='button-silver'>View this Webcast &raquo;</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-campaign').append(strToAppend);
						 
				}); //close each(
			} //close success:			
		}); //close $.ajax(
		
	} //close if
/*****/
	
	/*** CAMPAIGN - QUARTERLY CONSULTANT UPDATE ***/	
	if (section == "consultant_update"){


		$.ajax({
			type: "GET",
			url: "../../xml/exp_uk_campaign_consultant.xml",
			dataType: "xml",
			success: function(xml) {


			/*$.get('../../xml/exp_uk_campaign_consultant.xml', function(xml){ */


				/* var miwp = $.xml2json(xml); */

				/* count the number of records processed so we can do a different style for the last item (no divider line) */
				x = 0;
			/*	total = miwp.Expiration_Item.length; // find number of records*/
				total = $(xml).find('Expiration_Item').length; // find number of records
				
				/* track total count of items in categories */
				var count_webcast = 0;
				var count_whitepaper = 0;
				var count_newsletter = 0;
				var count_performance = 1;
				var count_economic_update = 0;
				var count_event = 0;
				
				var strToAppend_webcast = "";
				var strToAppend_whitepaper = "";
				var strToAppend_newsletter = "";
				var strToAppend_performance = "";
				var strToAppend_economic_update = "";
				var strToAppend_event = "";

				
				var backToTop = "<div class='back-to-top'><p>[ <a href='#'>back to top</a> ]</p></div>";
				var msgNoResearch = "<p><em>No available material at this time.</em></p><br>";
				var msgArray = new Array('webcast',
										 'whitepaper',
										 'newsletter',
										 'performance',
										 'economic_update',
										 'event');

			/*	$.each(miwp.Expiration_Item, function(i, Expiration_Item){ */
				
				$(xml).find('Expiration_Item').each(function(){
	
					var basicFormat = "";
					var basicFormat_webcast = "";
					var basicFormat_event = "";
					var formatLink = "";
					var formatLink_webcast = "";
					var formatLink_performance = "";
					var formatLink_performance_exp = "";
					
					var image_webcast = "";
					var image_whitepaper = "";
					var image_economic_update = "";
					var image_newsletter = "";
					

			/*		var title_text = Expiration_Item.Title;
					var date_text = Expiration_Item.Display_Date;
					var description_text = Expiration_Item.Description;
					var url_text = Expiration_Item.URL;
					var expiration_text = Expiration_Item.Expiration_Date;
					var format_text = Expiration_Item.Format;
					var section_text = Expiration_Item.Section;
*/

					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 section_text = $(this).find('Section').text();

					/* alert(description_text); */
					
					x += 1; //count this record
					
					formatLink 					= "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='../../images/icon-pdf.gif' alt='PDF'></a>";
					
					
					formatLink_webcast 			= "<a href='" + url_text + "' target='_blank' class='button-silver'>View Webcast</a>";
					
					
					formatLink_performance 		= "<a href='" + url_text + "' target='_blank'>" + title_text + "</a>";
					
					
					formatLink_performance_exp 	= "<span class='expired'>" + title_text + "</span>";

					
					image_webcast			= '<img class="image-acc" alt="webcast" src="../../images/icon-webcast.jpg">';
					image_whitepaper		= '<img class="image-acc" alt="whitepaper" src="../../images/icon-whitepaper.jpg">';
					image_newsletter		= '<img class="image-acc" alt="newsletter" src="../../images/icon-newsletter.jpg">';
					image_economic_update	= '<img class="image-acc" alt="economic_update" src="../../images/icon-economic-update.jpg">';

					
					/* build the HTML string  if the item is not expired */
					/* current categories are: Equity, Market Neutral, Fixed Income, Lifecycle
												PPA, Risk Management, Defined Benefit */
					if (expiration_text > nowDate) {
						
						basicFormat 			= 	"<div class='text-indent'><h4>" + title_text + "</h4>" + "<p><p>" + description_text + "</p>" + "<div class='link-wrapper'>" + formatLink + "</div></div>" + "<div class='rule'></div>";
						
						
						basicFormat_webcast 	= 	"<div class='text-indent'><h4>" + title_text + "</h4>" + "<p><p>" + description_text + "</p>" + "<div class='link-wrapper'>" + formatLink_webcast + "</div></div>" + "<div class='rule'></div>";
						
						basicFormat_event 	= 	description_text + "<div class='rule'></div>";
				
						if (section_text == "Webcast") {
							strToAppend_webcast += image_webcast + basicFormat_webcast;
							count_webcast += 1;
						} 
							
						if (section_text == "Whitepaper") {
							strToAppend_whitepaper += image_whitepaper + basicFormat;
							count_whitepaper += 1;
						}
							
						if (section_text == "Newsletter") {
							strToAppend_newsletter += image_newsletter + basicFormat;		
							count_newsletter += 1;
						}
							
						if (section_text == "Performance Review") {
							strToAppend_performance = formatLink_performance;		
							count_performance += 1;
						}
						
						if (section_text == "Economic Update") {
							strToAppend_economic_update += image_economic_update + basicFormat;		
							count_economic_update += 1;
						}
						
						if (section_text == "Events") {
							strToAppend_event += basicFormat_event;		
							count_event += 1;
						}
							
					}
					
					if (expiration_text <= nowDate) {
							
						if (section_text == "Performance Review") {
							strToAppend_performance = formatLink_performance_exp;		
							count_performance += 1;
						}
							
					}
					
						
					/* at the end of xml file */
					if (x == total){
						/* alert("Webcasts: " + count_webcast);
						alert("Whitepapers: " + count_whitepaper);
						alert("Performance: " + count_performance);
						alert("Economic Updates: " + count_economic_update);
						alert("Events: " + count_event); 
						
						
						
						alert("Msg Array Lngth:" + msgArray.length); */
						
						/* at the end, if the count of a category is zero, display message */
				 		for(i=0;i<msgArray.length;i+=1){
							
							/* alert("count_" + msgArray[i] + ": " + eval("count_" + msgArray[i]));  */
							
							/* alert("str for event: " + strToAppend_event); */
							
				 			if (eval("count_" + msgArray[i]) === 0) {
								/*alert("there are no counts for " + msgArray[i]);*/
				 				eval("strToAppend_" + msgArray[i] + " += msgNoResearch");
								/* alert("Hello: str for event: " + strToAppend_event); */
				 			}	
				 		}
											
						/* at the end, apply a different style to the last item only: get rid of divider line */
						strToAppend_webcast += backToTop;
						strToAppend_whitepaper += backToTop;
						strToAppend_newsletter += backToTop;
						strToAppend_economic_update += backToTop;
						strToAppend_event += backToTop;

										
						$('#exp-campaign-webcast').append(strToAppend_webcast);
						$('#exp-campaign-whitepaper').append(strToAppend_whitepaper);
						$('#exp-campaign-newsletter').append(strToAppend_newsletter);
						$('#exp-campaign-performance').append(strToAppend_performance);
						$('#exp-campaign-economic-update').append(strToAppend_economic_update);
						$('#exp-events').append(strToAppend_event);

					}

				}); //close each
				
		/*	});//close $get */
			} //close success:			
		}); //close $.ajax(
	} //close if
	/***** close CAMPAIGN - QUARTERLY CONSULTANT UPDATE *****/





	/*** db research version 2 micro page @ http://pyramis.com/campaigns/dbresearch_v2 ***/	
	if (section == "exp-campaign-db-v2"){
			
			
		$.ajax({
			type: "GET",
			url: "../../xml/exp_uk_campaign_db_v2.xml",
			dataType: "xml",
			success: function(xml) {

		/*	$.get('../../xml/exp_uk_campaign_db_v2.xml', function(xml){  */
						
			/*	var xmlItems = $.xml2json(xml); */

				/* count the number of records processed so we can do a different style for the last item (no divider line) */
				x = 0;
				/* total = xmlItems.Expiration_Item.length; */ // find number of records
				
				total = $(xml).find('Expiration_Item').length; // find number of records
				
				
				/* track total count of items in categories */
				var count_webcast = 0;
				var count_overview = 0;
				var count_press = 0;
				var count_article = 0;
								
				var strToAppend_webcast = "";
				var strToAppend_overview = "";
				var strToAppend_press = "";
				var strToAppend_article = "";
				
				var backToTop = "<div class='back-to-top'><p>[ <a href='#'>back to top</a> ]</p></div>";
				var msgNoResearch = "<p><em>No available research at this time</em></p><br>";
				var msgArray = new Array('webcast',
										 'overview',
										 'press',
										 'article');

				/* $.each(xmlItems.Expiration_Item, function(i, Expiration_Item){ */
				$(xml).find('Expiration_Item').each(function(){
					var basicFormat = "";
					var formatLink = "";

			/*		var title_text = Expiration_Item.Title;
					var date_text = Expiration_Item.Display_Date;
					var description_text = Expiration_Item.Description;
					var url_text = Expiration_Item.URL;
					var expiration_text = Expiration_Item.Expiration_Date;
					var section_text = Expiration_Item.Section;
			*/		
					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 section_text = $(this).find('Section').text();

					x += 1; //count this record
					
					formatLink 					= "<a href='" + url_text + "' target='_blank' class='button-silver'>Download PDF &raquo; <img src='../../images/icon-pdf.gif' alt='PDF'></a>";
					formatLink_webcast 			= "<a href='" + url_text + "' target='_blank' class='button-silver'>View Webcast</a>";
					
					image_webcast			= '<img class="image-acc" alt="webcast" src="../../images/icon-webcast.jpg">';
					image_overview		= '<img class="image-acc" alt="whitepaper" src="../../images/icon-whitepaper.jpg">';
					image_press	= '<img class="image-acc" alt="economic_update" src="../../images/icon-economic-update.jpg">';
					image_article		= '<img class="image-acc" alt="whitepaper" src="../../images/icon-whitepaper.jpg">';
					
					/* build the HTML string  if the item is not expired */
					if (expiration_text > nowDate) {
						
						basicFormat 			= 	"<div class='text-indent'><h4>" + title_text + "</h4>" + "<p><p>" + description_text + "</p>" + "<div class='link-wrapper'>" + formatLink + "</div></div>" + "<div class='rule'></div>";
						basicFormat_webcast 	= 	"<div class='text-indent'><h4>" + title_text + "</h4>" + "<p><p>" + description_text + "</p>" + "<div class='link-wrapper'>" + formatLink_webcast + "</div></div>" + "<div class='rule'></div>";
				
						if (section_text == "Webcast") {
							strToAppend_webcast += image_webcast + basicFormat_webcast;
							count_webcast += 1;
						} 
							
						if (section_text == "Overview") {
							strToAppend_overview += image_overview + basicFormat;
							count_overview += 1;
						}
							
							
						if (section_text == "Press") {
							strToAppend_press += image_press + basicFormat;		
							count_press += 1;
						}
						
						if (section_text == "Article") {
							strToAppend_article += image_article + basicFormat;		
							count_article += 1;
						}	
					}
					

					
						
					/* at the end of xml file */
					if (x == total){
						
						/* at the end, if the count of a category is zero, display message */
				 		for(i=0;i<msgArray.length;i+=1){
				 			if (eval("count_" + msgArray[i]) === 0) {
								/*alert("there are no counts for " + msgArray[i]);*/
				 				eval("strToAppend_" + msgArray[i] + " += msgNoResearch");
				 			}	
				 		}
											
						/* at the end, apply a different style to the last item only: get rid of divider line */
						strToAppend_webcast += backToTop;
						strToAppend_overview += backToTop;
						strToAppend_press += backToTop;
						strToAppend_article += backToTop;

										
						$('#exp-campaign-webcast').append(strToAppend_webcast);
						$('#exp-campaign-overview').append(strToAppend_overview);
						$('#exp-campaign-press').append(strToAppend_press);
						$('#exp-campaign-article').append(strToAppend_article);

					}


				}); //close each
				
		/*	});//close $get */
			} //close success:			
		}); //close $.ajax(
	} //close if




			//	}); //close each
				
			//});//close $get
		
	//} //close if
	/***** close db research version 2 micro page *****/


	
/* end of expiration section */	
} //close $(

