
/*
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-02-25T23:05:06');
	publicationMetadata = new MakePublicationMetadata('Associated Press');

	title = 'Study Suggests Antibiotics Are Overused';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Study Suggests Antibiotics Are Overused',
		'CHICAGO - A woman dying of Alzheimer\'s has a fever. Should she be given antibiotics? Many people would say yes. But a provocative new study suggests that antibiotics are overused in people dying of dementia diseases and should be considered more carefully...',
		'Study Suggests Antibiotics Are Overused',
		'By CARLA K. JOHNSON (Associated Press 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_02_25_ap.online.all_D8V1P15O0_news_ap_org.anpa.ew',
		'01204040614625',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-26T12:33:32');
	publicationMetadata = new MakePublicationMetadata('Associated Press');

	title = 'Age Bias Case Returned for More Review';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Age Bias Case Returned for More Review',
		'WASHINGTON - The Supreme Court has left the door open for workers in age discrimination cases to present supporting evidence from other employees at a company.',
		'Age Bias Case Returned for More Review',
		'By PETE YOST (Associated Press 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_02_26_ap.online.all_D8V24S4O0_news_ap_org.anpa',
		'01204051301875',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-26T00:00:00');
	publicationMetadata = new MakePublicationMetadata('The Bradenton Herald, Fla.');

	title = 'Americans Save Little but Remain Optimistic';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Americans Save Little but Remain Optimistic',
		'Feb. 26--MANATEE -- American workers continue to skimp on savings yet seem to still be optimistic about their financial future, according to a survey released Monday.',
		'Americans Save Little but Remain Optimistic',
		'Sara Kennedy',
		'',
		'20080226',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'knightridder_2008_02_26__0000-1557-BR-SAVINGS-20080226',
		'01204051475547',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-25T21:00:05');
	publicationMetadata = new MakePublicationMetadata('Associated Press');

	title = 'Lawmakers Propose Health Tracking System';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Lawmakers Propose Health Tracking System',
		'PROVIDENCE, R.I. - Lawmakers have proposed a system to investigate and track medical mistakes and so-called "near misses" after brain surgeons at Rhode Island Hospital operated on the wrong side of patients\' heads last year on three separate occasion...',
		'Lawmakers Propose Health Tracking System',
		'By MICHELLE R. SMITH (Associated Press 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_02_25_ap.online.all_D8V1N6JG0_news_ap_org.anpa.ew',
		'01204041107485',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-26T12:27:20');
	publicationMetadata = new MakePublicationMetadata('Associated Press');

	title = 'Senate Passes Bill on Indian Health Care';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Senate Passes Bill on Indian Health Care',
		'WASHINGTON - The Senate approved legislation Tuesday designed to ease health care problems on American Indian reservations by boosting screening and mental health programs and increasing tribal access to Medicare and Medicaid.',
		'Senate Passes Bill on Indian Health Care',
		'By MARY CLARE JALONICK (Associated Press 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_02_26_ap.online.all_D8V24P801_news_ap_org.anpa',
		'01204051301875',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-25T16:10:00');
	publicationMetadata = new MakePublicationMetadata('New York Times Syndicate');

	title = 'Health Care Spending to Double in a Decade';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Health Care Spending to Double in a Decade',
		'WASHINGTON -- Americans are likely to spend nearly twice as much on health care a decade from now, and the costs will shift from private insurance to Medicare as the baby boomer generation ages, federal analysts are reporting Tuesday.',
		'Health Care Spending to Double in a Decade',
		'LARRY LIPMAN',
		'',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'nytsyn_2008_02_25_medic_3445-0003-pat_nytimes.ew',
		'01204041107485',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-26T09:53:00');
	publicationMetadata = new MakePublicationMetadata('United Press International');

	title = 'Protein Might Aid Cancer Treatments';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Protein Might Aid Cancer Treatments',
		'NASHVILLE, Feb 26, 2008 (UPI via COMTEX) -- U.S. medical scientists said "tagging" tumors that respond to chemotherapy might offer a way of rapidly determining a cancer treatment\'s effectiveness.',
		'Protein Might Aid Cancer Treatments',
		'',
		'Copyright 2008 by United Press International',
		'NASHVILLE, Feb 26, 2008 (UPI via COMTEX)',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'comtex_2008_02_26_up_0000-8683-bc-us-cancer',
		'01204041107485',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-26T00:00:00');
	publicationMetadata = new MakePublicationMetadata('The Miami Herald');

	title = 'AARP Hits The Big 5-0';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'AARP Hits The Big 5-0',
		'Feb. 26--FOR AMERICANS, It Happens -- whether you\'re ready or not -- when you turn 50: You qualify for AARP.',
		'AARP Hits The Big 5-0',
		'Dominick Tao',
		'',
		'20080226',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'knightridder_2008_02_26__0000-1001-MI-AARP-hits-the-big-5-0-0226',
		'01204051475547',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-26T04:00:40');
	publicationMetadata = new MakePublicationMetadata('The Atlanta Journal-Constitution');

	title = 'No Relief for Health Care Costs';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'No Relief for Health Care Costs',
		'Washington --- Americans are likely to spend nearly twice as much on health care a decade from now, and the costs will shift from private insurance to Medicare as the baby boomer generation ages, federal analysts are reporting today.',
		'No Relief for Health Care Costs',
		'LARRY LIPMAN',
		'Copyright 2008 The Atlanta Journal-Constitution',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'ajc_2008_02_26_D_85399811-0052-Main',
		'01204040614625',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2008-02-25T00:00:00');
	publicationMetadata = new MakePublicationMetadata('The News & Observer, Raleigh, N.C.');

	title = 'Study Finds Arthritis Eased With Light Exercise';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Study Finds Arthritis Eased With Light Exercise',
		'Feb. 25--Exercise might seem like the worst thing for stiff, aching joints. But it may be just what people with arthritis need. Completing an eight-week program specially designed for people with arthritis improved range of motion and reduced pain and...',
		'Study Finds Arthritis Eased With Light Exercise',
		'Jean P. Fisher',
		'',
		'20080226',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'knightridder_2008_02_25__0000-0510-RA-Study-finds-arthritis-eased-with-light-exercise-0225',
		'01204041107485',
		'article',
		'en-US',
		'',
		article
		);

		
	

//////////////////////// End PER ARTICLE section

	contentSetId = 'DT1749_SENIORS';
	contentSetName = 'SENIORS';
	contentSetLanguage = '';
	contentSetPublishedDate = '2008-02-26T12:44:38';

	id = 'DT1749_SENIORS';
	contentType = '';

} // End data initialization block.

if (typeof ContentIndex == "undefined") {
	ContentIndex = -1;
}

SMContentSet[++ContentIndex] = new MakeContentSet(contentSetId, contentSetName, contentSetLanguage, contentSetPublishedDate, contents);
