//-------------------------------------------------------------------------------------------------
// The variables listed below refere to an image, associated caption and global message that 
// are global (i. e. displayed on all web pages).
// ------------------------------------------------------------------------------------------------
var globalImageSource = "Images/2010-03-31-crocuses-.jpg";
var globalImageSourceAlternate = "Spring! Ypsilanti, Michigan, March 31, 2010";
var globalImageSourceCaption = "Spring! Ypsilanti, Michigan, March 31, 2010";
var globalMessage = "Please pray and work for peace through justice: in our church, in our country, in our world";


//-------------------------------------------------------------------------------------------------
// The buildHeadlineData function will contain:
//    - a brief description of the headline
//    - a link (if any) to more information about the headline.
// ------------------------------------------------------------------------------------------------
function buildHeadlineData() {

	headlineListingCount++;
	headlineListing[headlineListingCount - 1] = new HeadlineData("item");
	headlineListing[headlineListingCount - 1].headlineShortDescription = "April Liturgy and Potluck";
	headlineListing[headlineListingCount - 1].headlineLongDescription = "April Liturgy and Potluck";
	headlineListing[headlineListingCount - 1].headlineLink = "UpcomingActivities/2006_April_Gathering.html";
	
	headlineListingCount++;
	headlineListing[headlineListingCount - 1] = new HeadlineData("item");
	headlineListing[headlineListingCount - 1].headlineShortDescription = "April Liturgy and Potluck";
	headlineListing[headlineListingCount - 1].headlineLongDescription = "April Liturgy and Potluck";
	headlineListing[headlineListingCount - 1].headlineLink = "UpcomingActivities/2006_April_Gathering.html";

}

//-------------------------------------------------------------------------------------------------
// The HeadlineData object and its associated prototypes will be used for holding information
// about headlines.  To include on a web page, the web page's <body> tag must include a 
// window_onload function which needs to call the populateWebPageWithHeadlineData function below.
// ------------------------------------------------------------------------------------------------
function HeadlineData(pName){
	this.name = pName;
	this.init();
}

HeadlineData.prototype.init = function() {
	this.headlineShortDescription = "";
	this.headlineLongDescription = "";
	this.headlineLink = "";
	this.headlineKey = 0;
}

HeadlineData.prototype.headlineShortDescription = function(pValue) {this.headlineShortDescription = pValue;}
HeadlineData.prototype.headlineLongDescription = function(pValue) {this.headlineLongDescription = pValue;}
HeadlineData.prototype.headlineLink = function(pValue) {this.headlineLink = pValue;}
HeadlineData.prototype.headlineKey = function(pValue) {this.headlineKey = pValue;}

var headlineListing = new Array(5);
var headlineListingCount = 0;

//-------------------------------------------------------------------------------------------------
// The assignInnerHTML function will build headline information (comprised of the headline 
// description and link to headline detail) within the <div id="headlines"> tag.
// ------------------------------------------------------------------------------------------------
function assignHeadlineInnerHTML(pHeadlineItemNumber) {
			  
	var headlineHTML = new String("");
	
	// Get the <div id="headlines"> object contained within the document.
	var headlineTag = document.getElementById("headlines");

	headlineHTML = '<p>'; 
	headlineHTML += headlineListing[pHeadlineItemNumber].headlineShortDescription;
	
	if (headlineListing[pHeadlineItemNumber].headlineLink.length > 0) {
		headlineHTML += '<a href="' + headlineListing[pHeadlineItemNumber].headlineLink + '"> full story...</a>';
	}
	
	headlineHTML += '</p>';
	
	//alert("1 assignHeadlineInnerHTML headlineHTML=" + headlineHTML);
	
	headlineTag.innerHTML += headlineHTML;
	
	//alert("2 assignHeadlineInnerHTML headlineHTML=" + headlineHTML);

	return;
}

//----------------------------------------------------------------------------------------------------------
// The assignHeadline_AtTop_InnerHTML function will build headline information (comprised of the headline 
// description and link to headline detail) within the <div id="headlines_attop"> tag.
// ---------------------------------------------------------------------------------------------------------
function assignHeadline_AtTop_InnerHTML(pHeadlineItemNumber) {
			  
	var headlineHTML_attop = new String("");
	
	// Get the <div id="headline_attop"> object contained within the document.
	var headlineTag_attop = document.getElementById("headlines_attop");

	headlineHTML_attop = '<div>'; 
	headlineHTML_attop += "===>  ";
	headlineHTML_attop += headlineListing[pHeadlineItemNumber].headlineShortDescription;
	
	if (headlineListing[pHeadlineItemNumber].headlineLink.length > 0) {
		headlineHTML_attop += '<a href="' + headlineListing[pHeadlineItemNumber].headlineLink + '"> <em><strong>full story...</strong></em></a>';
	}
	
	headlineHTML_attop += '</div>';
	
	//alert("1 assignHeadlineInnerHTML headlineHTML_attop=" + headlineHTML_attop);
	
	headlineTag_attop.innerHTML += headlineHTML_attop;
	
	//alert("2 assignHeadlineInnerHTML headlineHTML_attop=" + headlineHTML_attop);

	return;
}


//-------------------------------------------------------------------------------------------------
// Parse through all of the headline data and populate the headline <div> tag
// with the headline data.
// ------------------------------------------------------------------------------------------------
function populateWebPageWithHeadlineData() {
	
	populateWebPageWithFeatureData();
	
	buildHeadlineData2();
	
	var headlineHTML = new String("");
	
	// Get the <div id="headlines"> object contained within the document.
	var headlineTag = document.getElementById("headlines");
	
	headlineHTML = '<h3>Headlines</h3>';
	headlineTag.innerHTML = headlineHTML;
	
	//alert("1 populateWebPageWithHeadlineData headlineTag.innerHTML=" + headlineTag.innerHTML);

	for (var i = 0; i < headlineListingCount; i++) {
		//alert("2 populateWebPageWithHeadlineData headlineTag.innerHTML=" + headlineTag.innerHTML);
		assignHeadlineInnerHTML(i);
		//alert("3 populateWebPageWithHeadlineData headlineTag.innerHTML=" + headlineTag.innerHTML);
	}
	
	//alert("4 populateWebPageWithHeadlineData headlineTag.innerHTML=" + headlineTag.innerHTML);
	
	return;
}


//-------------------------------------------------------------------------------------------------
// Parse through all of the headline data and populate the headline <div> tag
// with the headline data.
// ------------------------------------------------------------------------------------------------
function populateWebPageWithHeadlineData_AtTop() {
	
	//populateWebPageWithFeatureData();
	
	//buildHeadlineData2();
	
	//---------------------------------------------------------------------------------
	// Build the headlines at the top of each page
	//---------------------------------------------------------------------------------
	var headlineHTML_attop = new String("");
	
	// Get the <div id="headlines_attop"> object contained within the document.
	var headlineTag_attop = document.getElementById("headlines_attop");
	
	//headlineHTML_attop = '<div style="font-size:18px"><h3><strong>Headlines </strong><em>(click on full story for details)</em></h3></div><div>&nbsp;</div>';
	headlineTag_attop.innerHTML = headlineHTML_attop;
	
	//alert("5 populateWebPageWithHeadlineData headlineTag_attop.innerHTML=" + headlineTag_attop.innerHTML);

	for (var i = 0; i < headlineListingCount; i++) {
		//alert("6 populateWebPageWithHeadlineData headlineTag_attop.innerHTML=" + headlineTag_attop.innerHTML);
		assignHeadline_AtTop_InnerHTML(i);
		//alert("7 populateWebPageWithHeadlineData headlineTag_attop.innerHTML=" + headlineTag_attop.innerHTML);
	}
	
	//alert("8 populateWebPageWithHeadlineData headlineTag_attop.innerHTML=" + headlineTag_attop.innerHTML);
	
	return;
}


//-------------------------------------------------------------------------------------------------
// Adjust the <div id="advert"> tag with a picture and caption.
// ------------------------------------------------------------------------------------------------
function populateWebPageWithFeatureData() {
	
	var featureHTML = new String("");
	
	// Get the <div id="advert"> object contained within the document.
	var featureTag = document.getElementById("advert");
	
	if (featureTag == null) return;
	
	featureHTML += '<p>'
	 				+ '<span>'
						+ '<img src="' + globalImageSource + '" '
						+ 'alt="' + globalImageSourceAlternate + '" '
						+ '/>'
					+ '</span>'
					+ '<em>' + globalImageSourceCaption + '</em>'
				+ '</p>'
    			+ '<p><font size="2">'
					+ '<strong>' + globalMessage + '</strong>'
				+ '</font></p>';
				
	featureTag.innerHTML = featureHTML;
	//alert("populateWebPageWithFeatureData featureTag.innerHTML=" + featureTag.innerHTML);

	return;
}



