

/*
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-30T11:03:32','');
publicationMetadata = new MakePublicationMetadata('Water Environment Research');


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(
'Two Requirements for Sustainable Wastewater Treatment',
'Interest in global warming is now increasing outside the scientific community, and governments are calling for measures to reduce carbon emissions. One possible solution is the implementation of energy-efficient practices in water and wastewater treatment...',
'Two Requirements for Sustainable Wastewater Treatment',
'Stenstrom, Michael K; Rosso, Diego',
'(C) 2007 Water Environment Research. via ProQuest Information and Learning Company; All Rights Reserved',
'Aug 2007',
'',
'',
'');

title = 'Two Requirements for Sustainable Wastewater Treatment';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('bhsgml_2007_08_30_29081_1327335331-0079-KEYWORD_Missing', '01188494996796', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-30T07:30:17','');
publicationMetadata = new MakePublicationMetadata('Business Week Online');


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(
'Earthlink Needs a Lifeline',
'The advent of broadband has not been kind to companies like Earthlink (ELNK) and Time Warner\'s (TWX) AOL that built their businesses on providing dial-up Internet access. Both former high-fliers have been forced in recent years to change tack and focus...',
'Earthlink Needs a Lifeline',
'Olga Kharif',
'Copyright ??? 2002 The McGraw-Hill Cos. All Rights reserved.',
'',
'',
'',
'');

title = 'Earthlink Needs a Lifeline';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('businessweek_2007_08_30_eng-businessweek_eng-businessweek_073017_287457840768079531', '01188494841968', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-29T13:58:15','');
publicationMetadata = new MakePublicationMetadata('Associated Press');


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(
'Amazon Didn\'t Crack My Eggs',
'SEATTLE - When I heard Amazon.com was testing a fresh grocery delivery service, I had two questions: In this car-centric city of abundant grocery stores, who needs to order online? And, didn\'t another Seattle dot-com grocery service bomb less than a decade...',
'Amazon Didn\'t Crack My Eggs',
'By JESSICA MINTZ (AP Technology Writer)',
'Copyright 2007 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.',
'',
'',
'',
'');

title = 'Amazon Didn\'t Crack My Eggs';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('apdigital_2007_08_29_ap_online_high-tech_D8RAS4D00_news_ap_org_anpa', '01188494996796', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-28T20:11:23','');
publicationMetadata = new MakePublicationMetadata('M2 Communications');


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(
'Japan Radio Introduces New \'Wipas\' Wireless Series',
'Japan Radio (JRC) has launched a series of \'WIPAS\' Wireless System (WIPAS-24, WIPAS-25 and WIPAS-26) for the IP Network being deployed worldwide. WIPAS is a Fixed Wireless Access (FWA) system with Ethernet Interface Radio.',
'Japan Radio Introduces New \'Wipas\' Wireless Series',
'',
'(C)2007 Digitalmediaasia.com (',
'',
'',
'pr',
'');

title = 'Japan Radio Introduces New \'Wipas\' Wireless Series';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('m2c_2007_08_28_DMA_0000-0397-DMA_200708282011231_2', '01188494841968', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-28T04:25:07','');
publicationMetadata = new MakePublicationMetadata('VNUNet.com');


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(
'Sony Caught Playing with Rootkits Again',
'Sony\'s Microvault USB memory key software could render users vulnerable to a malware attack, security vendor F-Secure has claimed.',
'Sony Caught Playing with Rootkits Again',
'Tom Sanders in California',
'Copyright ??? 2007 VNU Business Online Limited (UK) [All rights reserved]',
'2007-08-28',
'',
'',
'');

title = 'Sony Caught Playing with Rootkits Again';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('vnunet_2007_08_28_eng-vnunet_eng-vnunet_042507_7177956246299839304_ew', '01188494996796', 'article', 'en-US',    '', article);



documentMetadata = new MakeDocumentMetadata('internal', '2007-08-28T00:00:00','');
publicationMetadata = new MakePublicationMetadata('Fort Worth Star-Telegram, Texas');


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(
'Verizon Offers Lifetime DSL Rate',
'Aug. 28--Verizon is fighting back in the competitive world of high-speed Internet by letting customers lock in their price for life.',
'Verizon Offers Lifetime DSL Rate',
'David Wethe',
'',
'20070828',
'',
'',
'');

title = 'Verizon Offers Lifetime DSL Rate';

article = new MakeArticle(title, metadata, core, '','');




contents[++Index] = new MakeContent('knightridder_2007_08_28__0000-0859-FT-Verizon-offers-lifetime-DSL-rate-0828', '01188494996796', 'article', 'en-US',    '', article);






contentSetId = '2581_Technology_News';
contentSetName = 'Technology_News';
contentSetLanguage = '';
contentSetPublishedDate = '2007-08-30T12:30:55';
id = '2581_Technology_News';
contentType = '';
} // End data initialization block.
if (typeof ContentIndex == "undefined") {
ContentIndex = -1;
}
SMContentSet[++ContentIndex] = new MakeContentSet(contentSetId, contentSetName, contentSetLanguage, contentSetPublishedDate, contents);
