
/*
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', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'Petco Sued by Dog Owners for Grooming Injuries';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('Petco Sued by Dog Owners for Grooming Injuries', 'Petco Sued by Dog Owners for Grooming Injuries', 'Petco Sued by Dog Owners for Grooming Injuries', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('Petco Sued by Dog Owners for Grooming Injuries','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'Settlement Talks Resume in Virginia Tech Shooting Case';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('Settlement Talks Resume in Virginia Tech Shooting Case', 'Settlement Talks Resume in Virginia Tech Shooting Case', 'Settlement Talks Resume in Virginia Tech Shooting Case', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('Settlement Talks Resume in Virginia Tech Shooting Case','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'DC Metro Stipulates Liability for 2009 Train Crash';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('DC Metro Stipulates Liability for 2009 Train Crash', 'DC Metro Stipulates Liability for 2009 Train Crash', 'DC Metro Stipulates Liability for 2009 Train Crash', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('DC Metro Stipulates Liability for 2009 Train Crash','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'Defective Battery Blamed for E-Cigarette Explosion';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('Defective Battery Blamed for E-Cigarette Explosion', 'Defective Battery Blamed for E-Cigarette Explosion', 'Defective Battery Blamed for E-Cigarette Explosion', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('Defective Battery Blamed for E-Cigarette Explosion','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'Bus Company Sued in Student Hazing Death';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('Bus Company Sued in Student Hazing Death', 'Bus Company Sued in Student Hazing Death', 'Bus Company Sued in Student Hazing Death', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('Bus Company Sued in Student Hazing Death','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'Female Employees File Sexual Harassment Suit Against Bar';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('Female Employees File Sexual Harassment Suit Against Bar', 'Female Employees File Sexual Harassment Suit Against Bar', 'Female Employees File Sexual Harassment Suit Against Bar', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('Female Employees File Sexual Harassment Suit Against Bar','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'Four Killed, One Injured in Chicago Drunk Driving Crash';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('Four Killed, One Injured in Chicago Drunk Driving Crash', 'Four Killed, One Injured in Chicago Drunk Driving Crash', 'Four Killed, One Injured in Chicago Drunk Driving Crash', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('Four Killed, One Injured in Chicago Drunk Driving Crash','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'Alligator Attack the Focus of Wrongful Death Suit';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('Alligator Attack the Focus of Wrongful Death Suit', 'Alligator Attack the Focus of Wrongful Death Suit', 'Alligator Attack the Focus of Wrongful Death Suit', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('Alligator Attack the Focus of Wrongful Death Suit','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'S.C. Chemistry Lab Explosion Injures 5';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('S.C. Chemistry Lab Explosion Injures 5', 'S.C. Chemistry Lab Explosion Injures 5', 'S.C. Chemistry Lab Explosion Injures 5', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('S.C. Chemistry Lab Explosion Injures 5','01','article','en-US','',article);documentMetadata = new MakeDocumentMetadata('internal', '%sT09:00:00');publicationMetadata = new MakePublicationMetadata('USA TODAY');title = 'Judge&apos;s Ruling Delays Release of Lung Cancer Study';metadata = new MakeMetadata(documentMetadata, publicationMetadata, '', '', '', '');core = new MakeCore('Judge&apos;s Ruling Delays Release of Lung Cancer Study', 'Judge&apos;s Ruling Delays Release of Lung Cancer Study', 'Judge&apos;s Ruling Delays Release of Lung Cancer Study', '', '', '', '', '');
article = new MakeArticle(title, metadata, core, '');contents[++Index] = new MakeContent('Judge&apos;s Ruling Delays Release of Lung Cancer Study','01','article','en-US','',article);
//////////////////////// End PER ARTICLE section

        contentSetId = 'PROWEB_Legal';
        contentSetName = 'Legal';
        contentSetLanguage = '';
        contentSetPublishedDate = '2010-05-06T17:45:25';

        id = 'PROWEB_Legal';
        contentType = '';

} // End data initialization block.

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

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

