
/*
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', '2004-03-23T06:10:08');
	publicationMetadata = new MakePublicationMetadata('The Miami Herald');

	title = 'Life Is Good for Spain\'s Prince of Pop, David Bisbal';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Life Is Good for Spain\'s Prince of Pop, David Bisbal',
		'David Bisbal was an unknown just two years ago, a college dropout figuring out how to become a successful singer, one more Andalusian kid trying to make it in Madrid. Today, at 24, Bisbal has released two CDs with total sales at two million and counting. And he\'s just getting going.',
		'Life Is Good for Spain\'s Prince of Pop, David Bisbal',
		'Octavio Roca',
		'(c) 2004, The Miami Herald. Distributed by Knight Ridder/Tribune News Service.',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'krt_2004_03_23_knigb_6921-0036-MUS-BISBAL.MI.ew',
		'01080058328758',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2004-03-15T18:16:29');
	publicationMetadata = new MakePublicationMetadata('Press Association');

	title = 'Baby Joy for Charlie Sheen';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Baby Joy for Charlie Sheen',
		'Actor Charlie Sheen and his wife Denise Richards are celebrating the birth of a baby daughter.',
		'Baby Joy for Charlie Sheen',
		'',
		'&Acirc;&copy; Copyright Press Association Ltd 2003, All Rights Reserved.',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'pressassociation_2004_03_15_eng-pressassociation_entertainment_long_eng-pressassociation_entertainment_long_181629_6515784586467092819',
		'01080058328758',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2004-03-08T13:45:05');
	publicationMetadata = new MakePublicationMetadata('The Kansas City Star, Mo.');

	title = 'Smithsonian\'s Hispanic Ballads Cross Many Borders';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Smithsonian\'s Hispanic Ballads Cross Many Borders',
		'The Smithsonian Institution\'s "Corridos sin Fronteras: A New World Ballad Tradition," is a sophisticated exhibition about ballads without borders touring nine U.S. cities.',
		'Smithsonian\'s Hispanic Ballads Cross Many Borders',
		'Paul Horsley',
		'(c) 2004, The Kansas City Star. Distributed by Knight Ridder/Tribune News Service.',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'krt_2004_03_08_knigb_4303-0190-NEWVOICES-MUS-CORRIDO.KC',
		'01080058328758',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2004-03-08T15:46:33');
	publicationMetadata = new MakePublicationMetadata('Livedaily.com');

	title = 'Christina Aguilera Launches New North American Tour';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Christina Aguilera Launches New North American Tour',
		'Christina Aguilera kicks off a spring/summer tour of the U.S. and Canada in May, with rapper Chingy holding down the opening slot in all cities.',
		'Christina Aguilera Launches New North American Tour',
		'by Rob Evans',
		'&copy;2004 Livedaily.com. All Rights Reserved.',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'livedaily_2004_03_08_eng-livedaily_eng-livedaily_154633_5225106680544989909',
		'01080058328758',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2004-03-05T00:00:00');
	publicationMetadata = new MakePublicationMetadata('washingtonpost.com');

	title = 'Hello, \'Dora,\' Hola';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Hello, \'Dora,\' Hola',
		'Her name is Dora, "Dora the Explorer," and she is, for the uninitiated, the star character in a Nickelodeon-created cartoon of the same name that is enjoying a zenith of popularity, ranking first on commercial television among the 2-to-5-year-old set.',
		'Hello, \'Dora,\' Hola',
		'Jennifer Frey',
		'Copyright 2004 washingtonpost.com',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'washingtonpost_2004_03_05_eng-washingtonpost_wpni_eng-washingtonpost_wpni_003915_747992929458891196',
		'01080058328758',
		'article',
		'en-US',
		'',
		article
		);

		
	documentMetadata = new MakeDocumentMetadata('internal', '2004-03-04T18:35:32');
	publicationMetadata = new MakePublicationMetadata('Evening Standard - London');

	title = 'Benicio Del Toro: Hollywood Icon';
	metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');

	core = new MakeCore(
		'Benicio Del Toro: Hollywood Icon',
		'Like Marlon Brando, to whom he is frequently compared, Del Toro\'s approach to Hollywood is almost suicidally nonchalant. But when he dives into a project it\'s with both feet, turning out performances which range from brave and uncompromising to bordering on the insane.',
		'Benicio Del Toro: Hollywood Icon',
		'DAMON SYSON',
		'(C) 2004 Evening Standard - London. via ProQuest Information and Learning Company; All Rights Reserved',
		'',
		'',
		''
		);

	article = new MakeArticle(title, metadata, core, '');

	contents[++Index] = new MakeContent(
		'bhsuper_2004_03_04_TEVS_0000-5119-KEYWORD.Missing',
		'01080058328758',
		'article',
		'en-US',
		'',
		article
		);

		
	

//////////////////////// End PER ARTICLE section

	contentSetId = '6920_Entertainment';
	contentSetName = 'Entertainment';
	contentSetLanguage = '';
	contentSetPublishedDate = '2004-03-23T11:12:24';

	id = '6920_Entertainment';
	contentType = '';

} // End data initialization block.

if (typeof ContentIndex == "undefined") {
	ContentIndex = -1;
}

SMContentSet[++ContentIndex] = new MakeContentSet(contentSetId, contentSetName, contentSetLanguage, contentSetPublishedDate, contents);
