/**
 * 
 *  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_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") {
						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_uk_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_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") {
						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_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") {
						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_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: 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_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: 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_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: 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_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: 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_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") {
						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_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") {
						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_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") {
						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-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"){
						var 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
/*****/
	


	
/* end of expiration section */	
}; //close $(
