
/*
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-09-19T11:03:38');
	publicationMetadata = new MakePublicationMetadata('Essence');

	title = 'Energize Your Life 7 Power Foods for Women';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Energize Your Life 7 Power Foods for Women',
		'It\'s so easy to reach for coffee, cola or something sugary when you need a little afternoon pick-me-up. But there are smarter options. We asked nutritionists Constance Brown-Riggs, R.D., spokesperson for the American Dietetic Association, and Rovenia...',
		'Energize Your Life 7 Power Foods for Women',
		'Boone, Sharon',
		'(C) 2008 Essence. via ProQuest Information and Learning Company; All Rights Reserved',
		'Sep 2008',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'bhsgml_2008_09_19_23139_1557160661-0109-KEYWORD.Missing',
		'01221849558956',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-09-12T10:15:02');
	publicationMetadata = new MakePublicationMetadata('Daily Press, Newport News, Va.');

	title = 'How to Eat Good Fats 7 Tips';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'How to Eat Good Fats 7 Tips',
		'Dieters often fear fat, but it actually is crucial to good health. The trick is to eat foods with the right kinds of fat and avoid the others. Some tips from nutritionists:',
		'How to Eat Good Fats 7 Tips',
		'Alison Johnson',
		'(c) 2008, Daily Press (Newport News, Va.). Distributed by Mclatchy-Tribune News Service.',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'krt_2008_09_12_knigt_4430-0071-NTR-GOODFATS.NN',
		'01221243393866',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-09-11T16:40:00');
	publicationMetadata = new MakePublicationMetadata('PR Newswire');

	title = 'E-mergency? Majority of U.S. Consumers Lack Essential Vitamin E';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'E-mergency? Majority of U.S. Consumers Lack Essential Vitamin E',
		'MODESTO, Calif., Sept 11, 2008 /PRNewswire-USNewswire via COMTEX/ -- Journal of Nutrition Cites Almonds as a Rich Source to Fill the "E Gap"',
		'E-mergency? Majority of U.S. Consumers Lack Essential Vitamin E',
		'',
		'Copyright (C) 2008 PR Newswire. All Rights Reserved',
		'MODESTO, Calif., Sept 11, 2008 /PRNewswire',
		'',
		'pr'
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'comtex_2008_09_11_pr_0000-3101-abc-us-lacks-vitamine',
		'01221243214163',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-09-11T13:43:55');
	publicationMetadata = new MakePublicationMetadata('International Herald Tribune');

	title = 'Vitamin B12 And Brain Size';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Vitamin B12 And Brain Size',
		'Failure to properly absorb vitamin B12, found in meat, milk and eggs, has been implicated in various neurological disorders. Now a British study suggests that low levels of the vitamin in older people may cause the brain to shrink.',
		'Vitamin B12 And Brain Size',
		'Nicholas Bakalar The New York Times Media Group',
		'(C) 2008 International Herald Tribune. via ProQuest Information and Learning Company; All Rights Reserved',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'bhsuper_2008_09_11_INHT_0000-0869-KEYWORD.Missing',
		'01221243214163',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-09-08T09:38:00');
	publicationMetadata = new MakePublicationMetadata('Business Wire');

	title = 'Brown Bag Ideas with Whole Grain Goodness';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Brown Bag Ideas with Whole Grain Goodness',
		'SPOKANE, Wash., Sep 08, 2008 (BUSINESS WIRE) -- How can you enjoy lunch that\'s easy on the wallet, provides plenty of whole grain nutrition and keeps your energy up all day long? Brown bag it with barley.',
		'Brown Bag Ideas with Whole Grain Goodness',
		'',
		'Copyright Business Wire 2008',
		'SPOKANE, Wash., Sep 08, 2008 (BUSINESS WIRE)',
		'',
		'pr'
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'comtex_2008_09_08_bw_0000-4004-wa-national-barley-foods',
		'01220991350999',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-09-03T00:00:00');
	publicationMetadata = new MakePublicationMetadata('Knight Ridder/Tribune Business News');

	title = 'TASTE THE BEST: An apple a day keeps the cardiologist away';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'TASTE THE BEST: An apple a day keeps the cardiologist away',
		'Sep. 3--I got the inspiration for this recipe column when my mom said that the apple trees, I believe all eight of them (if that\'s the correct number they have), were dripping with apples. I don\'t know why after years of not producing, they decided to...',
		'TASTE THE BEST: An apple a day keeps the cardiologist away',
		'Laura Gwinn, Crossville Chronicle, Tenn.',
		'',
		'20080903',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'knightridder_2008_09_03__0000-5157-XV-TASTE-THE-BEST-An-apple-a-day-keeps-the-cardiologist-away-0903',
		'01220645787842',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-09-01T11:43:57');
	publicationMetadata = new MakePublicationMetadata('Vibrant Life');

	title = 'Wheat Germ\'s Big Punch';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Wheat Germ\'s Big Punch',
		'Although diminutive in size, the lowly wheat germ is full of fiber and is one of the most nutrient-packed foods available.',
		'Wheat Germ\'s Big Punch',
		'Anonymous',
		'(C) 2008 Vibrant Life. via ProQuest Information and Learning Company; All Rights Reserved',
		'Sep/Oct 2008',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'bhsgml_2008_09_01_36129_1542307431-0167-KEYWORD.Missing',
		'01220377434225',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-28T11:23:31');
	publicationMetadata = new MakePublicationMetadata('Tulsa World');

	title = 'Once a Garnish, Kale Is the Newest Superfood';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Once a Garnish, Kale Is the Newest Superfood',
		'It\'s cabbage\'s cousin, and it belongs in your diet.',
		'Once a Garnish, Kale Is the Newest Superfood',
		'CARY ASPINWALL CARY ASPINWALL World Scene Writer',
		'(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_31_TUL_0000-2694-KEYWORD.Missing',
		'01220377539334',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-27T13:04:02');
	publicationMetadata = new MakePublicationMetadata('Pediatrics for Parents');

	title = 'Vitamin D Deficiency';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Vitamin D Deficiency',
		'Vitamin D deficiency in children increases their risk of serious health problems later in life, including decreased bone density and type 1 (insulin dependent) diabetes, which is why all pregnant and breastfeeding women should take a prenatal vitamin...',
		'Vitamin D Deficiency',
		'Anonymous',
		'(C) 2008 Pediatrics for Parents. via ProQuest Information and Learning Company; All Rights Reserved',
		'Jun 2008',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'bhsgml_2008_08_27_36054_1540567561-0270-KEYWORD.Missing',
		'01220027972843',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-25T08:15:11');
	publicationMetadata = new MakePublicationMetadata('The Kansas City Star, Mo.');

	title = 'Grilled Trout Cuts Down on Saturated Fat';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Grilled Trout Cuts Down on Saturated Fat',
		'From Long John Silver\'s to church fundraisers, frying is the popular way to serve fish.',
		'Grilled Trout Cuts Down on Saturated Fat',
		'Jill Wendholt Silva',
		'(c) 2008, The Kansas City Star. Distributed by Mclatchy-Tribune News Service.',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'krt_2008_08_25_knigb_8420-0077-NTR-EATFORLIFE.KC',
		'01219697077914',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-08-22T16:05:02');
	publicationMetadata = new MakePublicationMetadata('The Sacramento Bee, Calif.');

	title = 'Nutrition Q&A';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Nutrition Q&A',
		'Eating healthfully can improve your overall heart health, says the American Medical Association. Do your dietary choices reflect good habits? Here\'s a quiz from the AMA to find out.',
		'Nutrition Q&A',
		'Gwen Schoen',
		'(c) 2008, The Sacramento Bee (Sacramento, Calif.). Distributed by Mclatchy-Tribune News Service.',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'krt_2008_08_22_knigb_8443-0123-NTR-NUTRITIONIQ-CORRECTION.SA',
		'01219697158774',
		'article',
		'en-US',
		'',
		article
		);

		
	

//////////////////////// End PER ARTICLE section

	contentSetId = 'DT1126_PURITAN';
	contentSetName = 'PURITAN';
	contentSetLanguage = '';
	contentSetPublishedDate = '2008-09-19T13:42:39';

	id = 'DT1126_PURITAN';
	contentType = '';

} // End data initialization block.

if (typeof ContentIndex == "undefined") {
	ContentIndex = -1;
}

SMContentSet[++ContentIndex] = new MakeContentSet(contentSetId, contentSetName, contentSetLanguage, contentSetPublishedDate, contents);

