
/*
SMMiLe JavaScript Object Model
Version 1.0
By Daryl Beattie
Copyright 2000, ScreamingMedia

SAMPLE USAGE [note that "script" tag is broken as "sc ript" so that it does not end this script]:

The code blow goes in the <HEAD> section of your HTML file
replace "JSDir/ContentSetID" with your JavaScript file path and name

	<sc ript language="JavaScript" src="JSDir/ContentSetID.js"></sc ript>
	<sc ript language="JavaScript">
		if(typeof SMChosenContent != \'undefined\') {
			document.write("<scri" + "pt language=\"JavaScript\" src=\"JSDir/ContentSetID" + SMChosenContent + ".js\"></sc" + "ript>");
		}
	</scr ipt>

The JavaScript objects are modelled after the SMMiLe XML structure:

<content-set>
	<content>
		<article>
			<title>...</title>
			<metadata>...</metadata>
			<core>...</core>
			<body>...</body>
		</article>
	</content>
</content-set>

As for the JavaScript, it is structured like this:

contentSet[0](id, name, language, publishedDate, contents)
|--	contents[i](id, revisionId, type, language, role, article) 
	|
	|--	article(title, metadata, core, body)
		|
		|--	metadata(documentMetadata, publicationMetadata, structuralMetadata, subjectMetadata, relatedContentMetadata, processingMetadata)
		|	|--	documentMetadata(storage, publisherReleaseDate)
		|	|--	publicationMetadata(publicationName)
		|	|--	structuralMetadata()
		|	|--	subjectMetadata()
		|	|--	relatedContentMetadata()
		|	|--	processingMetadata()
		|
		|--	core(summaryHeadline, docAbstract, headline, author, copyright, dateLine, dateTime, type)

An example of using this object model to print out the body of the second
article is:

	document.write(SMContentSet[0].contents[1].article.body);

*/


function displayContentPage(url, contentNum) {
	window.location = url + "?SMContentIndex=" + contentNum + "&SMContentSet=" + 0;
}

function displayContentPage(url, contentNum, contentSetNum) {
	window.location = url + "?SMContentIndex=" + contentNum + "&SMContentSet=" + contentSetNum;
}

function getParamValue(matchString, defaultValue) {
	var thisURL = window.location.toString();
	var value = defaultValue;
	if ((thisURL.indexOf("?") != -1) &&
	    (thisURL.indexOf(matchString) != -1) &&
	    (thisURL.charAt(thisURL.indexOf(matchString) + matchString.length) != "&")) {
		start = thisURL.indexOf(matchString) + matchString.length;
		if (thisURL.indexOf("&", start) > -1) {
			value = thisURL.substring(start, (thisURL.indexOf("&", start)));
		}
		else {
			value = thisURL.substring(start, thisURL.length);
		}
	}
	if (value == "NaN") {
		value = devaultValue;
	}
	return value;
}

var SMChosenContent = Number(getParamValue("SMContentIndex=", -1));
var SMChosenContentSet = Number(getParamValue("SMContentSet=", 0));

function prettyDate(date) {
	var result;
	if (date.substring(5,7) == "01") {result = "January ";}
	else if (date.substring(5,7) == "02") {result = "February ";}
	else if (date.substring(5,7) == "03") {result = "March ";}
	else if (date.substring(5,7) == "04") {result = "April ";}
	else if (date.substring(5,7) == "05") {result = "May ";}
	else if (date.substring(5,7) == "06") {result = "June ";}
	else if (date.substring(5,7) == "07") {result = "July ";}
	else if (date.substring(5,7) == "08") {result = "August ";}
	else if (date.substring(5,7) == "09") {result = "September ";}
	else if (date.substring(5,7) == "10") {result = "October ";}
	else if (date.substring(5,7) == "11") {result = "November ";}
	else {result = "December ";}
	if (date.charAt(8) == "0") {result += date.charAt(9);}
	else {result += date.substring(8,10);}
	return result + ", " + date.substring(0,4);
}

// Metadata sub-type element objects.
function MakeDocumentMetadata(myStorage, myPublisherReleaseDate) {
	this.storage = myStorage;
	this.publisherReleaseDate = myPublisherReleaseDate;
}
function MakePublicationMetadata(myPublicationName) {
	this.publicationName = myPublicationName;
}
function MakeStructuralMetadata() { }
function MakeSubjectMetadata() { }
function MakeRelatedContentMetadata() { }
function MakeProcessingMetadata() { }

// Metadata element object (made up of the sub-types).
function MakeMetadata(myDocumentMetadata, myPublicationMetadata, myStructuralMetadata, mySubjectMetadata, myRelatedContentMetadata, myProcessingMetadata) {
	this.documentMetadata = myDocumentMetadata;
	this.publicationMetadata = myPublicationMetadata;
	this.structuralMetadata = myStructuralMetadata;
	this.subjectMetadata = mySubjectMetadata;
	this.relatedContentMetadata = myRelatedContentMetadata;
	this.processingMetadata = myProcessingMetadata;
}

// Core element object
function MakeCore(mySummaryHeadline, myAbstract, myHeadline, myAuthor, myCopyright, myDateLine, myDateTime, myType) {
	this.summaryHeadline = mySummaryHeadline;
	this.docAbstract = myAbstract;
	this.headline = myHeadline;
	this.author = myAuthor;
	this.copyright = myCopyright;
	this.dateLine = myDateLine;
	this.dateTime = myDateTime;
	this.type = myType;
}

// Article element object
function MakeArticle(myTitle, myMetadata, myCore, myBody) {
	this.title = myTitle;
	this.metadata = myMetadata;
	this.core = myCore;
	this.body = myBody;
}

// Content element object
function MakeContent(myId, myRevisionId, myType, myLanguage, myRole, myArticle) {
	this.id = myId;
	this.revisionId = myRevisionId;
	this.type = myType;
	this.language = myLanguage;
	this.role = myRole;
	this.article = myArticle;
}

// Content-set master element object
function MakeContentSet(myId, myName, myLanguage, myPublishedDate, myContents) {
	this.id = myId;
	this.name = myName;
	this.language = myLanguage;
	this.publishedDate = myPublishedDate;
	this.contents = myContents;
}

{ // This block intializes the data objects.

	var Index = -1;
	if (typeof SMContentSet == "undefined") {
		var SMContentSet = new Array();
	}
	var contents = new Array();
//////////////////////// This section is made PER CONTENT (because the actual data is written in here)

	
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-17T23:05:00');
	publicationMetadata = new MakePublicationMetadata('Deutsche Presse-Agentur (dpa)');

	title = 'Even old brains learn new tricks, German scientists say';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Even old brains learn new tricks, German scientists say',
		'Hamburg (dpa) - Even older human brains are adept at learning new tricks, according to research by German scientists who studied a group of over-50 subjects learning new skills - such as juggling.',
		'Even old brains learn new tricks, German scientists say',
		'Ernest Gill, dpa',
		'Copyright 2008 dpa Deutsche Presse-Agentur GmbH',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'deutsche_2008_08_18_eca_0013-1100-.dpa-SPECIAL.Science.',
		'01219074954228',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-17T08:58:20');
	publicationMetadata = new MakePublicationMetadata('The Virginian-Pilot and The Ledger-Star, Norfolk, VA');

	title = 'Good for You';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Good for You',
		'It\'s melon season and time to add fresh cantaloupe to your menu. The sweet fruit truly has a heart of gold. The orange flesh is an excellent source of vitamin C. It also contains beta-carotene, a plant pigment that may protect against cancer and vision...',
		'Good for You',
		'',
		'(C) 2008 The Virginian-Pilot and The Ledger-Star, Norfolk, VA. via ProQuest Information and Learning Company; All Rights Reserved',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'bhsuper_2008_08_18_NFLK_0000-0430-KEYWORD.Missing',
		'01219074322869',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-13T00:00:00');
	publicationMetadata = new MakePublicationMetadata('The Baltimore Sun, Maryland');

	title = 'Pepper power: Punch up your salad with the colorful vegetables that are rich in vitamins and other goodies';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Pepper power: Punch up your salad with the colorful vegetables that are rich in vitamins and other goodies',
		'Aug. 13--They say the more colorful your salad, the more healthful it is. But instead of piling on the shredded carrots this month, try chopping up a bell pepper to decorate your mixed greens.',
		'Pepper power: Punch up your salad with the colorful vegetables that are rich in vitamins and other goodies',
		'Joanna Brenner, The Baltimore Sun',
		'',
		'20080813',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'knightridder_2008_08_13__0000-1142-BZ-Pepper-power-0813',
		'01218729152838',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-12T10:28:22');
	publicationMetadata = new MakePublicationMetadata('Tulsa World');

	title = 'Study Ties Vitamin D, Longevity';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Study Ties Vitamin D, Longevity',
		'Having too little vitamin D in the body might raise the risk of premature death, a study by Johns Hopkins researchers shows.',
		'Study Ties Vitamin D, Longevity',
		'USA TODAY',
		'(C) 2008 Tulsa World. via ProQuest Information and Learning Company; All Rights Reserved',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'bhsuper_2008_08_15_TUL_0000-0527-KEYWORD.Missing',
		'01219074322869',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-11T15:06:50');
	publicationMetadata = new MakePublicationMetadata('Associated Press');

	title = 'Half of overweight adults may be heart-healthy';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Half of overweight adults may be heart-healthy',
		'CHICAGO - You can look great in a swimsuit and still be a heart attack waiting to happen. And you can also be overweight and otherwise healthy.',
		'Half of overweight adults may be heart-healthy',
		'By LINDSEY TANNER (AP Medical Writer)',
		'Copyright 2008 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'ap_2008_08_11_ap.worldstream.english.health_D92G9PCO0_news_ap_org.anpa',
		'01218487245885',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-11T07:00:00');
	publicationMetadata = new MakePublicationMetadata('Canada NewsWire');

	title = 'Adults Who Eat Eggs for Breakfast Lose 65% More Weight';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Adults Who Eat Eggs for Breakfast Lose 65% More Weight',
		'A study published online in the International Journal of Obesity shows that eating two eggs for breakfast, as part of a reduced-calorie diet, helps overweight adults lose more weight and feel more energetic than those who eat a bagel breakfast of equal...',
		'Adults Who Eat Eggs for Breakfast Lose 65% More Weight',
		'',
		'(C) 2008 Canada NewsWire. All Rights Reserved',
		'OTTAWA, Aug. 11, 2008 (Canada NewsWire via COMTEX)',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'comtex_2008_08_11_cn_0000-1847-eggs-and-health-study',
		'01218487245885',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-11T22:13:00');
	publicationMetadata = new MakePublicationMetadata('AScribe News');

	title = 'Low Vitamin D Levels Pose Large Threat to Health : Overall 26 Percent Increased Risk of Death';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Low Vitamin D Levels Pose Large Threat to Health : Overall 26 Percent Increased Risk of Death',
		'BALTIMORE, Aug 11, 2008 (ASCRIBE NEWS via COMTEX) -- Researchers at Johns Hopkins are reporting what is believed to be the most conclusive evidence to date that inadequate levels of vitamin D, obtained from milk, fortified cereals and exposure to sunlight,...',
		'Low Vitamin D Levels Pose Large Threat to Health : Overall 26 Percent Increased Risk of Death',
		'',
		'(C)1999-2008 AScribe News',
		'BALTIMORE, Aug 11, 2008 (ASCRIBE NEWS via COMTEX)',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'comtex_2008_08_11_ms_0000-4723-KEYWORD.Missing',
		'01218729152838',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-07-30T00:00:00');
	publicationMetadata = new MakePublicationMetadata('Knight Ridder/Tribune Business News');

	title = 'TASTE THE BEST: Try it with some zucchini';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'TASTE THE BEST: Try it with some zucchini',
		'Jul. 30--With fall just around the corner, there will be many popular food items popping up in the produce department. One of the late summer favorites is zucchini. One cup of zucchini has about 35 calories. It contains potassium, vitamin A and phosphorus....',
		'TASTE THE BEST: Try it with some zucchini',
		'Laura Gwinn, Crossville Chronicle, Tenn.',
		'',
		'20080730',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'knightridder_2008_07_30__0000-4818-XV-TASTE-THE-BEST-Try-it-with-some-zucchini-0730',
		'01217535255554',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-07-30T00:00:00');
	publicationMetadata = new MakePublicationMetadata('Knight Ridder/Tribune Business News');

	title = 'Mainly meat: Good cuts, right portions secret to enjoying best sources of protein';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Mainly meat: Good cuts, right portions secret to enjoying best sources of protein',
		'Jul. 30--OAK HILL -- Although it\'s a good idea to prepare meals with as little cholesterol and as few saturated fats as possible, there are some easy ways to still enjoy your favorite meat entrees.',
		'Mainly meat: Good cuts, right portions secret to enjoying best sources of protein',
		'Bev Davis, The Register-Herald, Beckley, W.Va.',
		'',
		'20080730',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'knightridder_2008_07_30__0000-3194-WZ-Mainly-meat-0730',
		'01217535255554',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-07-29T11:03:56');
	publicationMetadata = new MakePublicationMetadata('HealthFacts');

	title = 'Vitamin D Research Continues to Show Benefits';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Vitamin D Research Continues to Show Benefits',
		'The importance of vitamin D was featured recently in two medical journals. Archives of Internal Medicine published a study that found low blood levels of vitamin D to be independently associated with a higher death rate, especially from cardiovascular...',
		'Vitamin D Research Continues to Show Benefits',
		'Napoli, Maryann',
		'(C) 2008 HealthFacts. via ProQuest Information and Learning Company; All Rights Reserved',
		'Jul 2008',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'bhsgml_2008_07_29_11602_1518712861-0189-KEYWORD.Missing',
		'01217535255554',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-07-25T00:00:00');
	publicationMetadata = new MakePublicationMetadata('Knight Ridder/Tribune Business News');

	title = 'BRIEF: What\'s fresh? Green beans!';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'BRIEF: What\'s fresh? Green beans!',
		'Jul. 25--When mom said, \'Eat your greens,\' she was onto something.',
		'BRIEF: What\'s fresh? Green beans!',
		'Erin Ryan, The Idaho Statesman, Boise',
		'',
		'20080725',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'knightridder_2008_07_25__0000-3253-ID-BRF-What-s-fresh-Green-beans-0725',
		'01217016505600',
		'article',
		'en-US',
		'',
		article
		);

		
	

//////////////////////// End PER ARTICLE section

	contentSetId = 'DT1126_PURITAN';
	contentSetName = 'PURITAN';
	contentSetLanguage = '';
	contentSetPublishedDate = '2008-08-18T10:56:59';

	id = 'DT1126_PURITAN';
	contentType = '';

} // End data initialization block.

if (typeof ContentIndex == "undefined") {
	ContentIndex = -1;
}

SMContentSet[++ContentIndex] = new MakeContentSet(contentSetId, contentSetName, contentSetLanguage, contentSetPublishedDate, contents);
