

/*
SMMiLe JavaScript Object Model
Version 2.0
By Daryl Beattie, Xiang Chen
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, photo)
        |
        |--metadata(documentMetadata, publicationMetadata, structuralMetadata, subjectMetadata, relatedContentMetadata, processingMetadata)
        |    |--documentMetadata(storage, publisherReleaseDate,player-url)
        |    |--publicationMetadata(publicationName)
        |    |--structuralMetadata(width,height,format,resolution,duration,mimetype)
        |    |--subjectMetadata(featureName)
		|	 |--relatedContentMetadata(relatedContents)
	    |    |    |--relatedContents[type](id, type, refId, refType);
        |    |--processingMetadata()
        |
        |--core(summaryHeadline, docAbstract, headline, author, copyright, dateLine, dateTime, type, caption)
        |-- photo(url, width, height, alt, caption)

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, contentSetNum, targetWindowName) {
    // check the arguments...
    if (displayContentPage.arguments.length == 1 ) {
        contentNum=0;
        contentSetNum=0;
        targetWindowName="_self";
    } else if (displayContentPage.arguments.length == 2 ) {
        contentSetNum=0;
        targetWindowName="_self";
    } else if (displayContentPage.arguments.length == 3 ) {
        targetWindowName="_self";
    }

    window.open(url + "?SMDOCID=" + SMContentSet[contentSetNum].contents[contentNum].id + "&SMContentSet=" + contentSetNum, targetWindowName);
}

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);
        }
    }
    return value;
}

var SMChosenContent = Number(getParamValue("SMContentIndex=", 0));
var SMChosenContentSet = Number(getParamValue("SMContentSet=", 0));
var SMChosenSegment = getParamValue("SMSegment=", "original");
var SMDOCID = getParamValue("SMDOCID=", "");

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, myPlayerUrl) {
    this.storage = myStorage;
    this.publisherReleaseDate = myPublisherReleaseDate;
    this.playerUrl = myPlayerUrl;
}
function MakePublicationMetadata(myPublicationName) {
    this.publicationName = myPublicationName;
}

function MakeStructuralMetadata(myWidth,myHeight,myFormat,myResolution,myDuration,myMimeType) {
    this.width = myWidth;
    this.height= myHeight;
    this.format = myFormat;
    this.resolution = myResolution;
    this.duration = myDuration;
    this.mimetype = myMimeType;
}
function MakeSubjectMetadata(myFeatureName) { 
    this.featureName = myFeatureName;
}

function MakeRelatedContentMetadata(myRelatedContents) {
    this.relatedContents = myRelatedContents;
}

function MakeRelatedContent(myId, myType, myRefId, myRefType) {
    this.id=myId;
    this.type=myType;
    this.refId=myRefId;
    this.refType=myRefType;
}

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, myCaption) {
    this.summaryHeadline = mySummaryHeadline;
    this.docAbstract = myAbstract;
    this.headline = myHeadline;
    this.author = myAuthor;
    this.copyright = myCopyright;
    this.dateLine = myDateLine;
    this.dateTime = myDateTime;
    this.type = myType;
    this.caption = myCaption;
}

function MakePhoto (myURL,myWidth,myHeight,myAlt,myCaption) {
    this.url = myURL;
    this.width = myWidth;
    this.height = myHeight;
    this.alt = myAlt;
    this.caption = myCaption;
}

// Article element object
function MakeArticle(myTitle, myMetadata, myCore, myBody, myPhoto) {
    this.title = myTitle;
    this.metadata = myMetadata;
    this.core = myCore;
    this.body = myBody;
    this.photo = myPhoto;
}

//Segment element object
function MakeSegment (myId,myType,myIndex,myMetadata) {
    this.id = myId;
    this.type = myType;
    this.Index = myIndex;
    this.metadata = myMetadata;
}

// 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();

documentMetadata = new MakeDocumentMetadata('internal', '2007-08-29T13:39:00','');
publicationMetadata = new MakePublicationMetadata('American School & University');


structuralMetadata = new MakeStructuralMetadata(0,0,'','','','');
subjectMetadata = new MakeSubjectMetadata('');
var relatedContents = new Array();

relatedContentMetadata = new MakeRelatedContentMetadata(relatedContents);
processingMetadata = new MakeProcessingMetadata();
metadata = new MakeMetadata(
documentMetadata,
publicationMetadata,
structuralMetadata,
subjectMetadata,
relatedContentMetadata,
processingMetadata);
core = new MakeCore(
'Mold Strikes New Orleans School',
'A mold infestation at Alice Harte Elementary School in the Algiers neighborhood of New Orleans has set off a round of classroom reshuffling. School officials have condemned two classrooms and relocated seventh- and eighth-graders to a church across the...',
'Mold Strikes New Orleans School',
'',
'',
'',
'',
'',
'');

title = 'Mold Strikes New Orleans School';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('primemedia_2007_08_29_eng-primemedia_eng-primemedia_170042_1316639764482791274', '01188493450890', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-29T00:00:00','');
publicationMetadata = new MakePublicationMetadata('Waterloo Courier, Iowa');


structuralMetadata = new MakeStructuralMetadata(0,0,'','','','');
subjectMetadata = new MakeSubjectMetadata('');
var relatedContents = new Array();

relatedContentMetadata = new MakeRelatedContentMetadata(relatedContents);
processingMetadata = new MakeProcessingMetadata();
metadata = new MakeMetadata(
documentMetadata,
publicationMetadata,
structuralMetadata,
subjectMetadata,
relatedContentMetadata,
processingMetadata);
core = new MakeCore(
'River Hills, Iowa, Students Back in School',
'Aug. 29--CEDAR FALLS -- River Hills School students returned to class today after a potential mold problem was found to pose no risk.',
'River Hills, Iowa, Students Back in School',
'Andrew Wind, Waterloo-Cedar Falls Courier, Iowa',
'',
'20070829',
'',
'',
'');

title = 'River Hills, Iowa, Students Back in School';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('knightridder_2007_08_29__0000-3132-OO-River-Hills-students-back-in-school-0829', '01188493450890', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-29T00:00:00','');
publicationMetadata = new MakePublicationMetadata('The Gazette, Colorado Springs, Colo.');


structuralMetadata = new MakeStructuralMetadata(0,0,'','','','');
subjectMetadata = new MakeSubjectMetadata('');
var relatedContents = new Array();

relatedContentMetadata = new MakeRelatedContentMetadata(relatedContents);
processingMetadata = new MakeProcessingMetadata();
metadata = new MakeMetadata(
documentMetadata,
publicationMetadata,
structuralMetadata,
subjectMetadata,
relatedContentMetadata,
processingMetadata);
core = new MakeCore(
'Colorado District Works to Pinpoint Source of Mold',
'Aug. 29--Falcon School District 49 is pulling together volumes of documents and working with several construction experts in the investigation of a mold problem that delayed the opening of three schools and cost thousands of dollars in repairs.',
'Colorado District Works to Pinpoint Source of Mold',
'Brian Newsome',
'',
'20070829',
'',
'',
'');

title = 'Colorado District Works to Pinpoint Source of Mold';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('knightridder_2007_08_29__0000-0996-GT-District-49-works-to-pinpoint-source-of-mold-0829', '01188493450890', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-24T00:00:00','');
publicationMetadata = new MakePublicationMetadata('San Bernardino County Sun, Calif.');


structuralMetadata = new MakeStructuralMetadata(0,0,'','','','');
subjectMetadata = new MakeSubjectMetadata('');
var relatedContents = new Array();

relatedContentMetadata = new MakeRelatedContentMetadata(relatedContents);
processingMetadata = new MakeProcessingMetadata();
metadata = new MakeMetadata(
documentMetadata,
publicationMetadata,
structuralMetadata,
subjectMetadata,
relatedContentMetadata,
processingMetadata);
core = new MakeCore(
'Senior Complex To Be Razed',
'Aug. 24--COLTON -- The 101-unit Colton Palms senior-housing complex will be demolished by early next year, officials said Thursday.',
'Senior Complex To Be Razed',
'Stephen Wall',
'',
'20070824',
'',
'',
'');

title = 'Senior Complex To Be Razed';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('knightridder_2007_08_24__0000-2534-BD-SENIOR-HOUSING-20070824', '01188493450890', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-24T00:00:00','');
publicationMetadata = new MakePublicationMetadata('The Buffalo News, N.Y.');


structuralMetadata = new MakeStructuralMetadata(0,0,'','','','');
subjectMetadata = new MakeSubjectMetadata('');
var relatedContents = new Array();

relatedContentMetadata = new MakeRelatedContentMetadata(relatedContents);
processingMetadata = new MakeProcessingMetadata();
metadata = new MakeMetadata(
documentMetadata,
publicationMetadata,
structuralMetadata,
subjectMetadata,
relatedContentMetadata,
processingMetadata);
core = new MakeCore(
'Mold Prompts Orders for Testing of Residential Towers',
'Aug. 24--The Buffalo Municipal Housing Authority agreed Thursday to conduct environmental tests immediately in Lyndon B. Johnson Towers following complaints of mold, odors and a white substance -- part powdery, part sticky -- that settles on furnitur...',
'Mold Prompts Orders for Testing of Residential Towers',
'Deidre Williams',
'',
'20070824',
'',
'',
'');

title = 'Mold Prompts Orders for Testing of Residential Towers';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('knightridder_2007_08_24__0000-1438-BF-Mold-other-complaints-prompt-order-for-tests-in-Johnson-Towers-0824', '01188493450890', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-24T00:00:00','');
publicationMetadata = new MakePublicationMetadata('Knight Ridder/Tribune Business News');


structuralMetadata = new MakeStructuralMetadata(0,0,'','','','');
subjectMetadata = new MakeSubjectMetadata('');
var relatedContents = new Array();

relatedContentMetadata = new MakeRelatedContentMetadata(relatedContents);
processingMetadata = new MakeProcessingMetadata();
metadata = new MakeMetadata(
documentMetadata,
publicationMetadata,
structuralMetadata,
subjectMetadata,
relatedContentMetadata,
processingMetadata);
core = new MakeCore(
'Teachers, Parents Stay Away from Tainted Classroom',
'DAUFUSKIE ISLAND -- Parents and teachers concerned about mold at Daufuskie Island Elementary aren\'t going to classes today, despite the school district\'s assertion that lessons should go on in the library next door.',
'Teachers, Parents Stay Away from Tainted Classroom',
'Peter Frost, The Island Packet, Hilton Head Island, S.C.',
'',
'20070824',
'',
'',
'');

title = 'Teachers, Parents Stay Away from Tainted Classroom';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('knightridder_2007_08_24__0000-0873-HH-Teachers-parents-stay-away-from-Daufuskie-classroom-tainted-by-mold-0824', '01188493450890', 'article', 'en-US',    '', article);






contentSetId = '2581_Mold';
contentSetName = 'Mold';
contentSetLanguage = '';
contentSetPublishedDate = '2007-08-30T12:05:36';
id = '2581_Mold';
contentType = '';
} // End data initialization block.
if (typeof ContentIndex == "undefined") {
ContentIndex = -1;
}
SMContentSet[++ContentIndex] = new MakeContentSet(contentSetId, contentSetName, contentSetLanguage, contentSetPublishedDate, contents);
