/******************************
* File: nr_data.js
* Desc: Novel Racers' Database.
* Auth: Kevin Machin.
******************************/

/*jsl:import cb.js */

////////////////////////////////////////////////////////////////////
// Func: nrDatabase
// Desc: Initialise an object containing the Novel Racers' database.
// Args: psTables -- Which tables to initialise (besides racers).
// Retn: A reference to the new object
////////////////////////////////////////////////////////////////////

function nrDatabase ()
{
    // Versions
    var sVersionCode = "2.20", sVersionData = "05/02/10";

    // Racer variables
    var aoRacer = new Array, iCountRacers = 0, iCountMale = 0;
    var iCountCurrent = 0, iCountSabbatical = 0, iCountAlumni = 0, iCountWaiting = 0;

    // Coffee variables
    var aoCoffee = new Array, iCountCoffeePost = 0, iCountCoffeeRota = 0;

    // Book variables
    var aoBook = new Array, iCountPublished = 0;

    // Entry variables
    var aoEntry = new Array, iCountEntries = 0;

    // Get parameters
    var psTables = (arguments.length > 0) ? arguments[0] : "";

    // Fill in the Racers' details
    //    Code: Hash based on real name initials. Used for links to other database tables.
    //          Upper case means published.
    //    Nickname: Blogger identity.
    //    Status: A=Alumni  S=Sabbatical  W=Waiting  C=Current (default)
    //            Lower case means real name is public.
    //
    //        Code  Nickname             Real Name              Status  Blogger ID            Web site
    //        ----  --------             ---------              ------  ----------            --------
    racerAdd ("ab1","Amanda",            "Amanda Brittany",        "C","06919354420843737481");
    racerAdd ("ai1","Annieye",           "Anne Ireson",            "c","13466245069641820781");
    racerAdd ("ba1","B",                 "Beth Anderson",          "a","12523875341438470968");
    racerAdd ("bs1","BE Sanderson",      "",                       "S","04336115135400388268");
    racerAdd ("cb1","LilyS",             "Cheryl Bywater",         "C","10653762974885767334");
    racerAdd ("cd1","CC Devine",         "",                       "C","05643697869694982791");
    racerAdd ("ce1","Serendipity",       "Christine Emberson",     "C","18236359929972446079");
    racerAdd ("CS1","Caroline",          "Caroline Smailes",       "a","04470638074202676460","www.carolinesmailes.co.uk");
    racerAdd ("CS2","Mrs Boob Pencil",   "Clare Sudbery",          "s","16104570334290554437","www.boobpencil.co.uk");
    racerAdd ("cs3","ChrisH",            "Christine Stovell",      "C","03741359642268813093");
    racerAdd ("CT1","Calistro",          "Cally Taylor",           "c","04650291635298634215","www.callytaylor.co.uk");
    racerAdd ("cw1","Cathy",             "Catherine Walter",       "c","14103529618681254875");
    racerAdd ("dc1","Debs",              "Deborah Carr",           "c","03223653554549707595");
    racerAdd ("dl1","DK Leather",        "",                       "C","01883507404298948190");
    racerAdd ("dt1","DOT",               "David O'Connor Thompson","c","00719312854612984929");
    racerAdd ("dw1","Denise",            "Denise Watson",          "c","13843258016706999464");
    racerAdd ("er1","The Secret Writer", "Elaine Rosie",           "C","02839111172089462436");
    racerAdd ("es1","Ellie",             "Ellie Steele",           "C","01683908637772154798");
    racerAdd ("FM1","Fia",               "Fiona MacKenzie",        "c","03669889070557241716");
    racerAdd ("GT1","Graeme K Talboys",  "Graeme K Talboys",       "s","00147746990011686351");
    racerAdd ("hh1","HelenMH",           "Helen M Hunt",           "c","16182100572365505905");
    racerAdd ("hr1","Helen",             "Helen Redfern",          "C","13315275929031953790");
    racerAdd ("hs1","Helen Shearer",     "Helen Shearer",          "s","15471996799876515105");
    racerAdd ("jb1","JJ",                "Jenny Beattie",          "c","00640209636605410939");
    racerAdd ("jm1","Juliette M",        "Juliette McAlroy",       "c","18024628240932083512");
    racerAdd ("jm2","Spiral Skies",      "Jenny Maltby",           "s","08781237143187343971");
    racerAdd ("jx1","Jude",              "",                       "A","08580049365535488726");
    racerAdd ("kb1","Kate Lord Brown",   "Kate Lord Brown",        "c","00278515379867576350","katelordbrown.com");
    racerAdd ("kb2","Crystal Jigsaw",    "Kathryn Brown",          "C","00031672605703705469");
    racerAdd ("kc1","Karen",             "Karen Clarke",           "c","05986874444030474719");
    racerAdd ("KH1","Kate",              "Kate Harrison",          "a","18344353468176988063");
    racerAdd ("ki1","Revisionista",      "",                       "C","05785573422454112815");
    racerAdd ("kj1","KayJay",            "",                       "C","02598307484098820912");
    racerAdd ("kk1","Kate.Kingsley",     "Kate Kingsley",          "c","02382512850730256227");
    racerAdd ("kw1","Kate",              "Kate Wheeler",           "C","08175749565666787151");
    racerAdd ("KK2","KeVin K",           "Kevin Killiany",         "s","14792797517571690942","kvaadk.livejournal.com");
    racerAdd ("km1","Captain Black",     "Kevin Machin",           "s","16290852640283747439","www.kevinmachin.pwp.blueyonder.co.uk");
    racerAdd ("lf1","Liz Fenwick",       "Liz Fenwick",            "c","02744937536946299450");
    racerAdd ("lf2","Leigh",             "Leigh Forbes",           "c","01651812577518625326");
    racerAdd ("lm1","Lane",              "Lane Mathias",           "c","08147122748453850264");
    racerAdd ("lr1","Hesitant Scribe",   "Lisa Ratcliffe",         "a","11882920406681074895");
    racerAdd ("LS1","Wordtryst",         "Liane Spicer",           "c","05035607144500219524");
    racerAdd ("ms1","L-Plate Author",    "Melanie Sherratt",       "C","06921930565391929367");
    racerAdd ("nn1","NoviceNovelist",    "",                       "C","08033841321311240951");
    racerAdd ("RC1","Rowan Coleman",     "Rowan Coleman",          "c","01207876813466262196");
    racerAdd ("RG1","LeatherDykeUK",     "Rachel Green",           "c","13048590167153841615");
    racerAdd ("sa1","Un Peu Loufoque",   "Sarah Andrew",           "C","09387826515638192265","www.unpeuloufoque.com");
    racerAdd ("sg1","Sarah*G*",          "Sarah German",           "s","11345739249623483549");
    racerAdd ("sj1","Flowerpot",         "Sue Jackson",            "C","14102679179201725732");
    racerAdd ("sh1","Sheepish",          "Vanessa",                "C","18252518055252342236");
    racerAdd ("SM1","Lucy Diamond",      "Sue Mongredien",         "a","11831060852859704680","www.lucydiamond.co.uk");
    racerAdd ("tm1","Tam",               "Tamsyn Murray",          "c","08041502244181924265","www.tamsynmurray.co.uk");
    racerAdd ("zc1","Zinnia Cyclamen",   "",                       "S","04841314997513292477");
    // Special "developer"
    racerAdd ("000","Captain Black",     "Kevin Machin",           "s","16290852640283747439","www.kevinmachin.pwp.blueyonder.co.uk");
    iCountRacers--;

    // Set sex of racers
    racerSex ("000", -1);
    racerSex ("dt1", 1);
    racerSex ("gt1", 1);
    racerSex ("kk2", 1);
    racerSex ("km1", 1);
    racerSex ("jx1", -1);

    // Previous nicknames
    racerNick ("er1", "Paige", "A Writer");
    racerNick ("es1", "Lazy Perfectionista");
    racerNick ("fm1", "Fiona");
    racerNick ("ki1", "K Imaginelli");
  //racerNick ("zc1", "Queenie"); // Secret!

    // Save counts
    this.iCountMale       = iCountMale;
    this.iCountCurrent    = iCountCurrent;
    this.iCountSabbatical = iCountSabbatical;
    this.iCountAlumni     = iCountAlumni;
    this.iCountWaiting    = iCountWaiting;
    this.iCountRacers     = iCountRacers;

    // Set up coffee table, if required
    this.iCountCoffeePost = 0;
    this.iCountCoffeeRota = 0;
    if (psTables.toLowerCase ().indexOf ("coffee") >= 0)
    {
        coffeeInit ();
        this.iCountCoffeePost = iCountCoffeePost;
        this.iCountCoffeeRota = iCountCoffeeRota;
    }

    // Set up books data, if required
    this.iCountBooks = 0;
    if (psTables.toLowerCase ().indexOf ("books") >= 0)
    {
        this.iCountBooks = booksInit ();
    }
    this.iCountPublished = iCountPublished;

    // Set up race entries, if required
    this.iCountEntries = 0;
    if (psTables.toLowerCase ().indexOf ("entries") >= 0)
    {
        this.iCountEntries = entriesInit ();
    }

    // Return the object references
    this.aoRacer  = aoRacer;
    this.aoCoffee = aoCoffee;
    this.aoBook   = aoBook;
    this.aoEntry  = aoEntry;

    // Versions
    this.sVersionCode = sVersionCode;
    this.sVersionData = sVersionData;

    /////////////////////////////////////////
    // Priv: racerAdd
    // Desc: Add a new Racer.
    // Args: psCode -- Three letter code.
    //       psNick -- Nickname (on Blogger).
    //       psName -- Real name.
    //       psStat -- Status.
    //       psProf -- Blogger profile.
    //       psSite -- [Optional] web site.
    // Retn: Reference to new object.
    /////////////////////////////////////////

    function racerAdd (psCode, psNick, psName, psStat, psProf)
    {
        // Get optional args
        var psSite = (arguments.length > 5) ? arguments[5] : "";
        
        // Add new entry to array
        aoRacer[iCountRacers] = new racer (psCode, psNick, psName, psStat, psProf, psSite);
        iCountRacers++;

        // Constructor
        function racer (psCode, psNick, psName, psStat, psProf, psSite)
        {
            var sTitle, iAdd, oLink;

            // Three character code
            this.sCode = psCode;

            // Default sex is female (as there are so many more)
            this.iSex = 0;

            // Published?
            if (psCode != psCode.toLowerCase ())
            {
                iCountPublished++;
            }

            // Set status
            iAdd = (psCode == "000") ? 0 : 1; // Don't count "developer" racer
            switch (psStat.toUpperCase ())
            {
            case "":
                psStat = "C";
                /*jsl:fallthru*/
            case "C":
                this.sStatus = "Current";
                iCountCurrent += iAdd;
                break;
            case "A":
                this.sStatus = "Alumni";
                iCountAlumni += iAdd;
                break;
            case "S":
                this.sStatus = "Sabbatical";
                iCountSabbatical += iAdd;
                break;
            case "W":
                this.sStatus = "Waiting";
                iCountWaiting += iAdd;
                break;
            default:
                psStat = "?";
                this.sStatus = psStat;
                break;
            }
            this.cStatus = psStat.slice (0, 1);

            // Nickname
            this.asNickName = new Array;
            this.asNickName[0] = psNick;

            // Real name may be private
            var sRealName = psName;
            if (psName === "")
            {
                this.sRealName = "{Unknown}";
            }
            else if (psStat != psStat.toUpperCase ())
            {
                this.sRealName = psName;
            }
            else
            {
                this.sRealName = "{Private}";
            }

            // Blogger details
            this.sBloggerId = psProf;
            this.sBloggerProfile = "";
            if (psProf !== "")
            {
                this.sBloggerProfile = "http://www.blogger.com/profile/" + psProf;
            }

            // Web site
            this.sWebSite = psSite;
            this.sWebURL  = "";
            if (psSite !== "")
            {
                this.sWebURL = "http://" + psSite;
            }

            //////////////////////////////////////////////////////////////////////////
            // Func: nickLink
            // Desc: Create a hyperlink to the blogger ID, using one of the nicknames.
            // Args: iBeg -- } Which nicknames?
            //       iEnd -- }
            // Retn: The hyperlink element.
            //////////////////////////////////////////////////////////////////////////

            this.nickLink = nickLink;
            function nickLink ()
            {
                var oLink, sLink, sTitle, i;

                // Handle parameters
                var iBeg = (arguments.length > 0) ? arguments[0] : 0;
                var iEnd = (arguments.length > 1) ? arguments[1] : 0;
                if (iEnd < iBeg)
                {
                    iEnd = this.asNickName.length - 1;
                }

                // Create text
                sLink = "";
                for (i = iBeg; i <= iEnd; i++)
                {
                    if (i > iBeg)
                    {
                        sLink += ", ";
                    }
                    sLink += this.asNickName[i];
                }

                // Blogger profile exists?
                if (psProf === "")
                {
                    // No profile, so just use the text
                    oLink = sLink;
                }
                else
                {
                    // Create the link
                    sTitle = "title=View Blogger profile for " + this.asNickName[0] + "...";
                    oLink = cbTag ("a", sLink, "target=_blank", sTitle);
                    oLink.href = this.sBloggerProfile;
                }

                return (oLink);
            }
            // End of nickLink

            // Hyperlink to web site
            this.realLink = realLink;
            function realLink ()
            {
                var oLink, sTitle;

                if (this.sWebURL === "")
                {
                    oLink = this.sRealName;
                }
                else
                {
                    sTitle = "title=Visit the web site for " + this.sRealName + "...";
                    oLink = cbTag ("a", this.sRealName, "target=_blank", sTitle);
                    oLink.href = this.sWebURL;
                }

                return (oLink);
            }

            // Associated material
            this.iCountBooks      = 0;
            this.aoBook           = new Array;
            this.iCountCoffeePost = 0;
        }
        // End of racer (constructor)
    }
    // End of racerAdd

    ///////////////////////////////////////////////////
    // Priv: racerSex
    // Desc: Indicate the sex of a racer.
    // Args: psCode -- Racer code.
    //       iSex   -- Sex value: 0 = Female, 1 = Male.
    ///////////////////////////////////////////////////

    function racerSex (psCode, iSex)
    {
        var oRacer;

        // Find the racer in question
        oRacer = racerFind (psCode);
        if (oRacer !== null)
        {
            oRacer.iSex = iSex;
            if (iSex === 1)
            {
                iCountMale++;
            }
        }
    }
    // End of racerSex

    //////////////////////////////////////////////
    // Priv: racerNick
    // Desc: Add previous nickname(s) for a racer.
    // Args: psCode -- Racer's code.
    //       ...    -- The names to add.
    //////////////////////////////////////////////

    function racerNick (psCode)
    {
        var i, oRacer;

        // Find racer
        oRacer = racerFind (psCode);
        if (oRacer !== null)
        {
            // Iterate over arguments
            for (i = 1; i < arguments.length; i++)
            {
                oRacer.asNickName[i] = arguments[i];
            }
        }
    }
    // End of racerNick

    ///////////////////////////////////////
    // Priv: booksInit
    // Desc: Initialise the books database.
    // Retn: Count of all NR books.
    ///////////////////////////////////////

    function booksInit ()
    {
        var iBooks = 0, sShop, sInfo;

        // Set up version info
        sInfo = "NRP Gadget, database " + sVersionCode + " (" + sVersionData + ")";

        // Set up the book array
        bookAdd ("CT1","Heaven Can Wait",              "heaven_can_wait");
        bookAdd ("CS1","In Search Of Adam",            "in_search_of_adam");
        bookAdd ("CS1","Black Boxes",                  "black_boxes");
        bookAdd ("CS1","Disraeli Avenue",              "disraeli_avenue");
        bookAdd ("CS2","The Dying of Delight",         "dying_of_delight");
        bookAdd ("FM1","How to Start and Run a Petsitting Business","petsitting");
        bookAdd ("GT1","Aaargh to Zizz - 135 Drama Games","aaargh_to_zizz");
        bookAdd ("GT1","Arianrhod's Dance",            "arianrhods_dance");
        bookAdd ("GT1","First Class: Early Works of the Nearly Famous","first_class");
        bookAdd ("GT1","Museum Educator's Handbook",   "museum_educators_handbook");
        bookAdd ("GT1","The Path through the Forest",  "path_through_forest");
        bookAdd ("GT1","Using Museums as an Educational Resource","museums_as_educational_resource");
        bookAdd ("GT1","The Voice within the Wind",    "voice_within_wind");
        bookAdd ("GT1","Way of the Druid",             "way_of_druid");
        bookAdd ("GT1","Wealden Hill",                 "wealden_hill");
        bookAdd ("KH1","Old School Ties",              "old_school_ties");
        bookAdd ("KH1","The Secret Shoppers Revenge",  "secret_shoppers_revenge");
        bookAdd ("KH1","The Self Preservation Society","self_preservation_society");
        bookAdd ("KH1","The Starter Marriage",         "starter_marriage");
        bookAdd ("KK2","Wolf Hunters (Mech Warrior: Dark Age)","mech_wolf");
        bookAdd ("KK2","Ride to Chimera (Mech Warrior: Dark Age)","mech_chimera");
        bookAdd ("SM1","Any Way You Want Me",          "any_way_you_want_me");
        bookAdd ("SM1","Over You",                     "over_you");
        bookAdd ("SM1","Hens Reunited",                "hens_reunited");
        bookAdd ("LS1","Caf&eacute; Au Lait",          "cafe_au_lait");
        bookAdd ("RC1","The Accidental Family",        "accidental_family");
        bookAdd ("RC1","The Accidental Mother",        "accidental_mother");
        bookAdd ("RC1","The Accidental Wife",          "accidental_wife");
        bookAdd ("RG1","An Ungodly Child",             "ungodly_child");
        // Special "developer" book
        bookAdd ("000", sInfo,                         "cover.gif");
        iBooks--;

        // Add shopping and additional information
        sShop = "www.amazon.co.uk/gp/product/1409103234?ie=UTF8&amp;tag=twistetheunoffis&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=1409103234";
        sInfo = "Orion, 9781409103233";
        bookInfo ("CT1", 1, sShop, sInfo);

        sInfo =  "The Dying of Delight is about two women whose lives are connected by the solar eclipse of 1999. ";
        sInfo += "Someone will die - but who? \"Pulses with guts, energy and wit\" - Julia Darling.";
        bookInfo ("CS2", 1, "www.thedyingofdelight.co.uk", sInfo);

        sShop = "www.amazon.co.uk/";
        bookInfo ("GT1",1,sShop + "Aaargh-Zizz-135-Drama-Games/dp/0953777057/ref=sr_11_1?ie=UTF8&qid=1226325983&sr=11-1","Dramatic Lines, 9780953777051");
        bookInfo ("GT1",2,sShop + "Arianrhods-Dance-Druid-Ritual-Handbook/dp/0954053125/ref=sr_11_1?ie=UTF8&qid=1226326188&sr=11-1","Grey House in the Woods, 9780954053123");
        bookInfo ("GT1",3,sShop + "First-Class-Nearly-Famous-Station/dp/0955760607/ref=sr_11_1?ie=UTF8&qid=1226326298&sr=11-1","Monkey Business, 9780955760600");
        bookInfo ("GT1",4,sShop + "Museum-Educators-Handbook-Graeme-Talboys/dp/0754644928/ref=sr_11_1?ie=UTF8&qid=1226326415&sr=11-1","Gower, 9780754644927");
        bookInfo ("GT1",5,sShop + "Path-Through-Forest-Druid-Guidebook/dp/0954053141/ref=sr_11_1?ie=UTF8&qid=1226326649&sr=11-1","Grey House in the Woods, 9780954053147");
        bookInfo ("GT1",6,sShop + "Using-Museums-as-Educational-Resource/dp/1857423445/ref=sr_11_1?ie=UTF8&qid=1226326793&sr=11-1","Ashgate, 9781857423440");
        bookInfo ("GT1",7,sShop + "Voice-within-Wind-Becoming-Druid/dp/0954053109/ref=sr_11_1?ie=UTF8&qid=1226326864&sr=11-1","Grey House in the Woods, 9780954053109");
        bookInfo ("GT1",8,sShop + "Way-Druid-Rebirth-Ancient-Religion/dp/1905047231/ref=sr_11_1?ie=UTF8&qid=1226326961&sr=11-1","O Books, 9781905047239");
        bookInfo ("GT1",9,sShop + "Wealden-Hill-Novel-Graeme-Talboys/dp/0954053133/ref=sr_11_1?ie=UTF8&qid=1226327072&sr=11-1","Grey House in the Woods, 9870954053130");

        sShop = "www.amazon.co.uk/s/ref=nb_ss_w_h_?url=search-alias%3Daps&field-keywords=Kevin+Killiany&x=18&y=13";
        bookInfo ("KK2",1,sShop,"Roc, 9780451460950");
        bookInfo ("KK2",2,sShop,"Roc, 9780451461940");

        sInfo =  "An Ungodly Child follows Harold Waterman, an unlikely hero, and his summoned demonic familiar Jasfoup. ";
        sInfo += "When Harold is infected by an incurable disease when he meets Jedith, otherwise known as the Angel of Pestilence, ";
        sInfo += "he turns to the black arts to find a cure. Jasfoup is only too happy to help, as long as Harold can pay for his services. ";
        sInfo += "Meanwhile, the three angels of destruction are out to prove that there could be an antichrist, ";
        sInfo += "if only Harold would believe it. Gillian, Harold's vampire girlfriend, is not so sure.";
        bookInfo ("RG1",1,"www.amazon.co.uk/gp/product/1905108648%3Fie%3DUTF8%26tag%3Dwhthdobi-21%26linkCode%3Das2%26camp%3D1634%26creative%3D19450%26creativeASIN%3D1905108648",sInfo);

        //////////////////////////////////////////////////////////
        // Priv: bookAdd
        // Desc: Constructor for new book.
        // Args: psCode  -- Author code.
        //       psTitle -- Book title.
        //       psFile  -- File base name (for book cover image).
        // Retn: Object reference.
        //////////////////////////////////////////////////////////

        function bookAdd (psCode, psTitle, psFile)
        {
            var oBook;
            
            // Create new book and add it to the array
            oBook = new book (psCode, psTitle, psFile);
            aoBook[iBooks] = oBook; iBooks++;
            
            // Constructor
            function book (psCode, psTitle, psFile)
            {
                var i, oR, oImg, sFile, sTitle;

                // Title
                this.sTitle = psTitle;

                // Image
                if (psFile.indexOf (".") < 0)
                {
                    psFile += ".jpg";
                }
                sFile = "../../Images/NRP/" + psCode.toLowerCase () + "_" + psFile;
                this.sImg = sFile;
                sTitle = "Book cover image for " + psTitle + ".";
                oImg = cbTag ("img");
                oImg.title = sTitle;
                oImg.alt   = sTitle;
                oImg.src = sFile;
                this.oImg = oImg;

                // Shopping details
                this.oShop = null;

                // Information
                this.sInfo = "";

                // Add book to author's array
                this.oAuthor = oR = racerFind (psCode);
                if (oR !== null)
                {
                    oR.iCountBooks++;
                    this.iNumber = oR.iCountBooks;
                    oR.aoBook.push (this);
                }
            }
            // End of book (constructor)
        }
        // End of bookAdd

        ////////////////////////////////////////
        // Priv: bookInfo
        // Desc: Set extra book information.
        // Args: psCode -- Author code.
        //       iBook  -- Book number.
        //       psShop -- Shopping information.
        //       psInfo -- Extra information.
        ////////////////////////////////////////

        function bookInfo (psCode, iBook)
        {
            var i, oB, oBook, sShopDomain, sTitle, oLink;

            // Get arguments
            var psShop = (arguments.length > 2) ? arguments[2] : "";
            var psInfo = (arguments.length > 3) ? arguments[3] : "";

            // Find the book
            oBook = null;
            for (i = 0; i < aoBook.length; i++)
            {
                oB = aoBook[i];
                if ((oB.oAuthor.sCode == psCode) && (oB.iNumber == iBook))
                {
                    oBook = oB;
                    break;
                }
            }
            if (oBook === null)
            {
                return; // Book not found in database!
            }

            // Set the extra information
            sShopDomain = psShop;
            i = psShop.indexOf ("/");
            if (i > 0)
            {
                sShopDomain = psShop.slice (0, i);
            }
            sTitle = "Visit the on-line shop for '" + oB.sTitle + "'...";
            // Long-winded but IE8 seems to have issues with href versus displayed text
            oLink = cbTag ("a");
            oLink.title = sTitle;
            oLink.target = "_blank";
            oLink.href = "http://" + psShop;
            oLink.innerHTML = sShopDomain;
            oB.oShop = oLink;
            oB.sInfo = psInfo;
        }

        // Return the total book count
        return (iBooks);
    }
    // End of booksInit

    ////////////////////////////////////////
    // Priv: coffeeInit
    // Desc: Initialise the coffee database.
    ////////////////////////////////////////

    function coffeeInit ()
    {
        var iPost = 0;

        postAdd (29, 6, 7,"LF1","Is It Coffee Time?","What to blog about and what not to.");
        postAdd ( 6, 7, 7,"LF1","Coffee 2 - Let's Talk about S-x","Sex scenes.","coffee-2-lets-talk-about-s-x");
        postAdd (13, 7, 7,"HR1","Coffee break number 3","How's everyone getting on?");
        postAdd (20, 7, 7,"JM2","Friday! Coffee Break!!","Becoming a bloomin' writer.");
        postAdd (27, 7, 7,"LF1","Coffee Time?","The inner critic.");
        postAdd ( 3, 8, 7,"LF1","Coffee Suggestion","What are you reading?");
        postAdd (10, 8, 7,"ZC1","Coffee Break","Do you carry a notebook?");
        postAdd (17, 8, 7,"ZC1","Coffee Break","Titles.","coffee-break_17");
        postAdd (23, 8, 7,"NN1","Friday Morning Sugar Hit!","Material, genre and flow.");
        postAdd (30, 8, 7,"NN1","Healthy start to the Coffee Morning!","Writing mantras and creative crutches.","healthy-start-to-coffee-morning");
        postAdd ( 7, 9, 7,"HR1","An Inspired Coffee Morning","Who or what inspires you?","inspired-coffee-morning");
        postAdd (13, 9, 7,"HR1","An Ambitious Coffee Morning","Goals for the end of the year.","ambitious-coffee-morning");
        postAdd (20, 9, 7,"CS3","Coffee Break: Maps or Divination?","Writing methodology. What works for you?");
        postAdd (27, 9, 7,"CS3","Coffee Break: Writers' Guides by Users","Recommendations for writing resources.");
        postAdd ( 5,10, 7,"KK2","Weekly Friday coffee ritual","Writing rituals.");
        postAdd (12,10, 7,"KK2","Arts or Crafts","To rewrite or not to rewrite, that is the question.");
        postAdd (19,10, 7,"BS1","Coffee and Community","Getting to know each other.");
        postAdd (26,10, 7,"BS1","Morning Beverage Break: Critters and Readers","Critique Partners and Beta Readers.","morning-beverage-break-critters-and");
        postAdd ( 2,11, 7,"CT1","Coffee with Cally","Various questions.");
        postAdd ( 9,11, 7,"CT1","Late coffee with Cally","What do you do well? What do you struggle with?");
        postAdd (15,11, 7,"RC1","Racers on the Couch","How do you feel? Writing emotional content.","racers-on-couch");
        postAdd (22,11, 7,"RC1","The Pep Rally","Keeping going when things get tough.","good-morning-everyone-i-hope-you-have");
        postAdd (30,11, 7,"RG1","Coffee Morning 30th November","Self disclosure. Revealing secrets.");
        postAdd ( 6,12, 7,"RG1","Mutable Titles","The changing world of story titles.");
        postAdd (14,12, 7,"JM2","Sacrificial Offerings","What do you/would you sacrifice for your writing?","sacrifical-offerings");
        postAdd (21,12, 7,"JM2","Taking Stock. Friday Coffee","Writing achievements of the year.");
        postAdd (28,12, 7,"JB1","End of Year Coffee Break","Readers, teachers & mentors.");
        postAdd ( 4, 1, 8,"JB1","Coffee Break: And they're off...","How do you fit writing in with jobs, social lives, family lives?");
        postAdd (10, 1, 8,"KK1","Coffee Break: Books, books, books...","Reading & book related goals for 2008.");
        postAdd (18, 1, 8,"KK1","Coffee Break: I'm a celebrity, write me a synopsis","Celebrity writers.","coffee-break-im-celebrity-write-me");
        postAdd (25, 1, 8,"ER1","Coffee Break: Wobbles","Coping with wobbles, nerves, doubts & fears.");
        postAdd ( 1, 2, 8,"ER1","Coffee Break: Naming Characters","How to name characters.");
        postAdd ( 7, 2, 8,"FM1","Milestones","Finding points where your writing has improved.");
        postAdd (14, 2, 8,"FM1","Is Writing Just a Gift?","How much can be taught/learned?","is-writing-just-gift");
        postAdd (22, 2, 8,"BS1","Coffee Reflections","Writing experiences.");
        postAdd (29, 2, 8,"BS1","Late Coffee... Sorry","Pseudonyms.");
        postAdd ( 7, 3, 8,"ES1","Coffee break!","Choosing readers for feedback.");
        postAdd (14, 3, 8,"ES1","Coffee break","?","coffee-break_14");
        postAdd (21, 3, 8,"CW1","Easter coffee","What books do you read?");
        postAdd (28, 3, 8,"CW1","Post-Easter coffee","Using experience. Writing as therapy.");
        postAdd ( 4, 4, 8,"LM1","Friday Coffee Morning: Engineering Works","Planning & other disciplines.");
        postAdd (11, 4, 8,"LM1","Friday Coffee Morning: Smile","Publicity.");
        postAdd (18, 4, 8,"KI1","Friday Morning Coffee: The US Cocktail Edition","Drafting & editing. Describing places you've never visited.","friday-morning-coffee-us-cocktail");
        postAdd (25, 4, 8,"KI1","Friday Morning Coffee","Music.");
        postAdd ( 1, 5, 8,"ZC1","Friday Coffee","Confidence building.");
        postAdd ( 9, 5, 8,"ZC1","Friday Coffee: Crystal Tips","Tips for writing.");
        postAdd (16, 5, 8,"LS1","Coffee Break: Don't tell anyone - I'm a writer!","Closet writer or out in the open?","friday-coffee-morning-dont-tell-anyone");
        postAdd (23, 5, 8,"LS1","Coffee Morning: Turning Pro","Techniques for being professional.");
        postAdd (30, 5, 8,"KK1","Coffee Break: Jump starting","Inspiration & getting unstuck.");
        postAdd ( 6, 6, 8,"KK1","Coffee Break: Here comes the sun","Influence of weather.","coffee-break-here-comes-sun");
        postAdd (13, 6, 8,"CS2","Coffee Morning: Direction Angst","Genre.");
        postAdd (20, 6, 8,"CS2","Coffee Morning: What's Your Point of View?","Point(s) of view.");
        postAdd (27, 6, 8,"RG1","Friday Tea Break","Number of main characters. Introducing characters.");
        postAdd ( 4, 7, 8,"RG1","Childhood's Beginning","Influential books from early days.");
        postAdd (11, 7, 8,"GT1","Coffee Morning: Books","Influential fiction & non-fiction books.");
        postAdd (18, 7, 8,"GT1","Coffee Morning: Getting Started","How to begin writing each day.");
        postAdd (25, 7, 8,"FM1","This Time Last Year","How to get started as a writer.");
        postAdd (30, 7, 8,"FM1","As a Mark of Respect","","as-mark-of-respect");
        postAdd ( 8, 8, 8,"KM1","Coffee Break: Multiple Authors","Books with more than one author.");
        postAdd (15, 8, 8,"KM1","Coffee Break: Self-Publishing","SP, POD, Vanity...");
        postAdd (22, 8, 8,"RC1","Coffe Break: Deliverance","How to write when normal life around you is hectic?");
        postAdd (29, 8, 8,"LF1","Apology from Rowan - You're Stuck with Me","Blogs about writing.","huge-apology-from-rowan-who-is-stuck");
        postAdd ( 5, 9, 8,"HS1","Coffee and competition","Competitions.");
        postAdd (12, 9, 8,"HS1","Have coffee, regroup and start again","Trashing and starting again.");
        postAdd (19, 9, 8,"DC1","Strange Mugs & Aspirations","Working day methods: Word count or time limited?","welcome-to-my-first-coffee-morning");
        postAdd (26, 9, 8,"DC1","Naming Characters","Choosing character names.");
        postAdd ( 3,10, 8,"CS3","Coffee Break: Baby, It's Cold Outside","Your favourite piece of work.");
        postAdd (10,10, 8,"CS3","Back to the Future","Timeliness and longevity of your writing.","cofee-break-back-to-future");
        postAdd (17,10, 8,"ZC1","Coffee Break: Stories and Plots","Chronology in story-telling and plotting.");
        postAdd (24,10, 8,"ZC1","Coffee Break: Christmas Is Coming","Achievements 2008 and goals 2009.");
        postAdd (31,10, 8,"CT1","Ideas and Legs","Choosing ideas and turning them into novels.");
        postAdd ( 7,11, 8,"CT1","Coffee Break: Learning Lessons","What lessons have we learned from writing our books?");
        postAdd (14,11, 8,"KJ1","Happy Ending","How to switch off from writing mode?");
        postAdd (21,11, 8,"KJ1","Ta, Cheers, Danke, Gracias, Merci, Arigatou...","What are you thankful for, as a writer?");
        postAdd (28,11, 8,"JB1","Coffee Break from Thailand","Games and tricks to get it done.");
        postAdd ( 5,12, 8,"JB1","Thailand Two...","Blooper confessions.");
        postAdd (12,12, 8,"SG1","How Do You Do It?","How did you start? How do you cope with fear of failure?","coffee-morning-how-do-you-do-it");
        postAdd (19,12, 8,"SG1","Coffee Morning: Want or Chuck?","Celebrity and book games.");
        postAdd ( 2, 1, 9,"LM1","Coffee Break: A Fresh Page","What do you write apart from your main WiP?");
        postAdd ( 9, 1, 9,"LM1","Grammar, Schrammar","Your grammar weak points and irks.","grammar-schrammar");
        postAdd (16, 1, 9,"JM2","Coffee Break", "Film/drama/series you'd like to have written. Celebrity shaped WIPs.");
        postAdd (23, 1, 9,"JM2","Coffee Morning", "Is reality overrated?");
        postAdd (30, 1, 9,"ER1","Coffee Break: Distractions from Writing", "What are your biggest distractions from writing and guilty pleasures?");
        postAdd ( 6, 2, 9,"ER1","To Lisa", "Tribute to Lisa Ratcliffe (Hesitant Scribe).");
        postAdd (13, 2, 9,"JM1","History Lesson", "Character history and back-story.");
        postAdd (20, 2, 9,"JM1","Woof woof argh get off and let me write happy things", "Getting out of writers' gloom.","woof-woof-argh-get-off-and-let-me-write");
        postAdd (27, 2, 9,"SH1","Bonjour et bienvenue","Who or what do you turn to for inspiration?");
        postAdd ( 6, 3, 9,"SH1","Bonjour a tout le monde","Courses and \"how to\" books.","bonjour-tout-le-monde");
        postAdd (13, 3, 9,"CW1","Controversy at Coffee Time","Writing about your own troubled family. Is it exploitation?");
        postAdd (20, 3, 9,"CW1","Coffee Time","Applying techniques to writing.");
        postAdd (27, 3, 9,"ES1","Coffee break","How do you fit it all in?");
        postAdd ( 3, 4, 9,"ES1","Coffee break","Weird and wacky ideas for writing.");
        postAdd (17, 4, 9,"KK2","Thursday night coffee break","What do you do to practice your craftsmanship?");
        postAdd (24, 4, 9,"KK2","Habits","Structures, rituals, location, music, goals...","habits-thursday-night-coffee-break");
        postAdd ( 1, 5, 9,"RG1","Coffee Morning Trailers","What would you want to see in a book trailer?");
        postAdd ( 8, 5, 9,"RG1","The 70% Slump","Losing momentum when writing a book.","coffee-break-70-slump");
        postAdd (15, 5, 9,"KC1","Fly me to the Moon","Writing about places you've never been to.","fly-me-to-moon");
        postAdd (22, 5, 9,"KC1","How soon is too soon?","Seeking early critique.");
        postAdd (29, 5, 9,"SJ1","Conflict","Conflicting aspects of life and writing.");
        postAdd ( 5, 6, 9,"SJ1","Support Systems","Writer's support systems. What are yours?");
        postAdd (12, 6, 9,"KM1","Coffee Break: Racers' Rules","Writer's rules. Follow them or break them?");
        postAdd (19, 6, 9,"KM1","Coffee Break: Racers' Rules Part Two","Rules of the Novel Race.");
        postAdd (26, 6, 9,"BA1","Coffee Break: Introduction and Analogies","Do you use analogy in your writing? Why/why not?");
        postAdd ( 3, 7, 9,"BA1","Coffee Morning: Distancing Yourself","How do you get distance from your work?");
        postAdd (10, 7, 9,"DC1","How Much is Too Much?","How do you know when you are improving your book, or simply ruining it?");
        postAdd (17, 7, 9,"DC1","Confusion and the Synopsis","How do you plan and write something so important and representative of your book?","coffee-break-confusion-and-synopsis");
        postAdd (24, 7, 9,"LF1","Plotting - It's all about Characters","Plotting, characters and exercises.","plotting-its-all-about-characters");
        postAdd (31, 7, 9,"LF1","A Closer Look","Opening paragraphs.","closer-look");
        postAdd ( 7, 8, 9,"LF2","Wake Up and Smell the Coffee","The senses of smell and taste.","wake-up-and-smell-coffee");
        postAdd (14, 8, 9,"LF2","Turned Out Nice Again","The weather.");
        postAdd (21, 8, 9,"GT1","What does your muse look like?","How do you envisage your writing muse?");
        postAdd (28, 8, 9,"GT1","What do you do with your spare time?","What do you do to unwind and get away from writing?");
        postAdd ( 4, 9, 9,"AI1","Coffee Morning: Time Envy and Middles","What's your golden writing time? How do you tackle the all important middle section of your novels?");
        postAdd (11, 9, 9,"AI1","Coffee Morning: Are you a Lurker?","Invitation for lurkers to come and join the NR coffee breaks.","coffee-morning-are-you-lurker");
        postAdd (18, 9, 9,"JB1","Coffee break from Thailand","How do you go about understanding what you've written?");
        postAdd (25, 9, 9,"JB1","Friday Coffee","How do you organise your writing collateral?");
        postAdd ( 2,10, 9,"LM1","Whether Weather Makes a Difference","How does the weather affect your writing?","whether-weather-makes-difference");
        postAdd ( 9,10, 9,"LM1","Platforms and Presence","How strong is your on-line presence?");
        postAdd (16,10, 9,"SH1","Friday Coffee Morning","Research tips.");
        postAdd (23,10, 9,"SH1","Friday Coffee Morning","Male and female writers and bloggers.","friday-coffee-morning_7274");
        postAdd (30,10, 9,"KB1","Coffee Break: Java Jive","Kate's introduction, plus: how do you keep going in the face of obstacles?");
        postAdd ( 6,11, 9,"KB1","Coffee Break: The Glamour, the Glamour ...","How can real authors compete against celebrities? Does good writing even matter any more?","coffee-break-glamour-glamour");
        postAdd (13,11, 9,"SJ1","Endurance","One Day Novels, NaNoWriMo and other speed-writing challenges.");
        postAdd (19,11, 9,"SJ1","Reading Matter","Do you belong to a book group and if so, how does it affect your writing?");
        postAdd (27,11, 9,"RG1","Friday Tea (or, \"Oops - I forgot\")","Thoughts on NaNoWriMo.","friday-tea-or-oops-i-forgot");
        postAdd ( 4,12, 9,"RG1","Morning Coughing","Multiple projects and multi-tasking.");
        postAdd (11,12, 9,"CD1","Edits, Stereotypes and Quality Street","Creating characters with different ethnicity, sexuality etc.");
        postAdd (18,12, 9,"CD1","Finish Line!","Achievements in 2009 and goals for 2010.");
      //postAdd (25,12, 9,"XXX","Xmas Day","");
        postAdd ( 1, 1,10,"CB1","Coffee Break: Experience","How important do you think it is to have first hand experience of something?");
        postAdd ( 8, 1,10,"CB1","Coffee Break: Influences","What influences your writing? What did you do before Google?");
        postAdd (17, 1,10,"ES1","(Slightly Belated) Coffee Break","How do you cope with deadlines?");
        postAdd (22, 1,10,"ES1","Coffee Break","How do you go about the second draft?");
        postAdd (29, 1,10,"FM1","Confess Your (Writing) Sins","Do/did you have any writing sins? How to handle them?");
        postAdd ( 5, 2,10,"FM1","Short Synopses","Do you find synopses useful before or after editing - or both?");
        iCountCoffeePost = iPost;

        // Add rota items
        postAdd (12, 2,10,"DC1","","");
        postAdd (19, 2,10,"DC1","","");
        postAdd (26, 2,10,"RC1","","");
        postAdd ( 5, 3,10,"RC1","","");
        postAdd (12, 3,10,"AI1","","");
        postAdd (19, 3,10,"AI1","","");
        postAdd (26, 3,10,"BA1","","");
        postAdd ( 2, 4,10,"BA1","","");
        iCountCoffeeRota = iPost - iCountCoffeePost;

        /////////////////////////////////
        // Priv: postAdd
        // Desc: Coffee post constructor.
        // Args: Details of posting.
        // Retn: Reference to object.
        /////////////////////////////////

        function postAdd (iDay, iMonth, iYear, psHost, psTitle, psSubject)
        {
            var oPost;
            
            // Obtain URL string
            var psURL = (arguments.length > 6) ? arguments[6] : psTitle;
            
            // Create new post and add it to the array
            oPost = new post (iDay, iMonth, iYear, psHost, psTitle, psSubject, psURL);
            aoCoffee[iPost] = oPost; iPost++;

            // Constructor
            function post (iDay, iMonth, iYear, psHost, psTitle, psSubject, psURL)
            {
                var sDay, sMonth, sYear, oHost, oLink;
                var sURL, iC, iL, sC;

                // Set chronological post number
                this.iNumber = iPost + 1;

                // Set date and build date string
                this.oDate = new Date (iYear + 2000, iMonth - 1, iDay, 23, 59, 59);
                sDay = String (iDay);
                if (iDay < 10)
                {
                    sDay = "0" + sDay;
                }
                sMonth = String (iMonth);
                if (iMonth < 10)
                {
                    sMonth = "0" + sMonth;
                }
                sYear = String (iYear);
                if (iYear < 10)
                {
                    sYear = "0" + sYear;
                }
                this.sDate = sDay + "/" + sMonth + "/" + sYear;

                // Host fields
                this.sHostCode  = psHost;
                oHost = racerFind (psHost);
                this.oHostRacer = oHost;
                if ((oHost !== null) && (psTitle !== ""))
                {
                    oHost.iCountCoffeePost++;
                }

                // Title and subject
                iC = psTitle.indexOf (":");
                if (iC >= 0)
                {
                    this.sTitle = psTitle.slice (iC + 2);
                }
                else
                {
                    this.sTitle = psTitle;
                }
                this.sSubject = psSubject;

                // Now generate URL from date and title
                sURL = "http://novelracers.blogspot.com/";
                sURL += String (iYear + 2000) + "/";
                sURL += sMonth + "/";
                iL = psURL.length;
                for (iC = 0; iC < iL; iC++)
                {
                    sC = psURL.slice (iC, iC + 1);
                    switch (sC)
                    {
                    case ",":
                    case "'":
                    case "\"":
                    case "?":
                    case ":":
                    case "!":
                    case ".":
                    case "(":
                    case ")":
                        break;
                    case " ":
                        sURL += "-";
                        break;
                    default:
                        sURL += sC;
                        break;
                    }
                }
                this.sURL = sURL.toLowerCase () + ".html";
                oLink = cbTag ("a", this.sTitle, "target=_blank", "title=Read the coffee break posting...");
                oLink.href = this.sURL;
                this.oLink = oLink;
            }
            // End of post (constructor)
        }
        // End of postAdd

        // Priv: Compare posts by number
        function coffeeCompare (oA, oB)
        {
            return (oB.iNumber - oA.iNumber);
        }
    }
    // End of coffeeInit

    ////////////////////////////////////
    // Priv: entriesInit
    // Desc: Set up the race entries.
    // Retn: The number of race entries.
    ////////////////////////////////////

    function entriesInit ()
    {
        // Set up the race entry data
        var iCount = 0;

        // Completed 2009
        entryAdd ("AB1","NLB",                   75000, 75000,21, 9, 9);
        entryAdd ("CB1","Confidence in Me",      78760, 78760, 8,10, 9);
        entryAdd ("ES1","Unseen",               100794,100794,10, 7, 9);
        entryAdd ("GT1","Film script novel",     60000, 60000,10, 9, 9);
        entryAdd ("JB1","Polite Lies",          107257,107257,21,12, 9);
        entryAdd ("KC1","MFH",                   80023, 80023,30, 6, 9);
        entryAdd ("LF1","Penderown",             74158, 74158,11,10, 9);
        entryAdd ("LS1","Give Me the Night",     90000, 90000,30, 4, 9);
        entryAdd ("MS1","TC",                   118697,118697, 7, 4, 9);
        entryAdd ("RG1","First Lady",           104000,104000,24,12, 9);
        entryAdd ("SJ1","The Current Beneath",   94000, 94000, 5,11, 9);
        entryAdd ("TM1","HHSB children's novel",  5601,  5601,18, 8, 9);
        entryAdd ("TM1","My So-Called Afterlife",41905, 41905,19, 8, 9);
        entryAdd ("TM1","My So-Called Haunting", 36763, 36763,13,12, 9);

        // Completed 2010
        entryAdd ("CW1","Novel",                 78377, 78377,15, 1,10);

        // In progress
        entryAdd ("AB1","SFSG",                   6500, 75000, 0, 0, 0);
        entryAdd ("AI1","Melody of Raindrops" ,  80000,100000, 0, 0, 0);
        entryAdd ("AI1","Twisted Garlands",      57000,100000, 0, 0, 0);
        entryAdd ("CD1","Novel (rewrite)",       77000,100000, 0, 0, 0);
        entryAdd ("CE1","Finding Ringo",          2500, 90000, 0, 0, 0);
        entryAdd ("CS3","Make, Do and Mend",      8100,100000, 0, 0, 0);
        entryAdd ("CT1","Novel two (edit 1)",    69974, 94831, 0, 0, 0);
        entryAdd ("ES1","Saving so Far",         39687,100000, 0, 0, 0);
        entryAdd ("FM1","The Sergeant's Wife",   60000, 80000, 0, 0, 0);
        entryAdd ("FM1","Novel two",             28000, 80000, 0, 0, 0);
        entryAdd ("HR1","Verity",                 5000,100000, 0, 0, 0);
        entryAdd ("JM1","Queen of Cups",         57081,120000, 0, 0, 0);
        entryAdd ("JM2","Karma Chameleons",       4138, 90000, 0, 0, 0);
        entryAdd ("KC1","AWP",                   13160, 80000, 0, 0, 0);
        entryAdd ("LF2","Waking Up to Jamie (rewrite)",24500, 85000, 0, 0, 0);
        entryAdd ("LM1","Past Tense",            70000, 75000, 0, 0, 0);
        entryAdd ("MS1","TSSOTS",                71485,100000, 0, 0, 0);
        entryAdd ("MS1","TTD",                       0,100000, 0, 0, 0);
        entryAdd ("SG1","A Life Before",         40132, 80000, 0, 0, 0);
        entryAdd ("SH1","Novel",                 70900, 85000, 0, 0, 0);
        entryAdd ("TM1","PML novel",             34564, 80000, 0, 0, 0);

        ////////////////////////////////////////
        // Priv: entryAdd
        // Desc: Constructor for race entry.
        // Args: psCode -- Racer code.
        //       psTitle -- Title of entry.
        //       iVal    -- Word count.
        //       iMax    -- Expected maximum.
        //       iDay    -- Day of completion.
        //       iMonth  -- Month of completion.
        //       iYear   -- Year of completion.
        // Retn: Object reference.
        ////////////////////////////////////////

        function entryAdd (psCode, psTitle, iVal, iMax, iDay, iMonth, iYear)
        {
            var oEntry;
            
            // Create new entry and append it to the array
            oEntry = new entry (psCode, psTitle, iVal, iMax, iDay, iMonth, iYear);
            aoEntry[iCount] = oEntry; iCount++;

            // Actual constructor
            function entry (psCode, psTitle, iVal, iMax, iDay, iMonth, iYear)
            {
                var iPercent;

                // Basic values
                this.sCode  = psCode;
                this.sTitle = psTitle;
                this.iVal   = iVal;
                this.iMax   = iMax;

                // Derived values
                this.sVal = cbStrNum (iVal, cbnum_CSEP);
                this.sMax = cbStrNum (iMax, cbnum_CSEP);

                // Percentage completed
                if (iMax <= 0)
                {
                    iPercent = 0;
                }
                else
                {
                    iPercent = Math.floor ((iVal * 100) / iMax);
                }
                this.iPercent = iPercent;

                // Date
                if ((iYear + iMonth + iDay) === 0)
                {
                    iYear = 3000;
                    iDay = iMonth = 1;
                }
                else
                {
                    iYear += 2000;
                }
                this.oDate = new Date (iYear, iMonth - 1, iDay, 0, 0, 0);

                // Find racer from code
                this.oRacer = racerFind (psCode);
            }
            // End of entry (constructor)
        }
        // End of entryAdd
        
        // Return the number of entries
        return (iCount);
    }
    // End of entriesInit

    /////////////////////////////////////////////////////////
    // Priv: racerFind
    // Desc: Get a racer, given a code.
    // Args: psCode -- Three character racer code.
    // Retn: Reference to racer object, or null if not found.
    /////////////////////////////////////////////////////////

    function racerFind (psCode)
    {
        var i, oR, oRacer;

        // Scan through all racers
        oRacer = null;
        for (i = 0; i < aoRacer.length; i++)
        {
            oR = aoRacer[i];
            if (oR.sCode.toUpperCase () == psCode.toUpperCase ())
            {
                oRacer = oR;
                break;
            }
        }

        // Return result
        return (oRacer);
    }
    // End of racerFind

    // Return database object reference
    return (this);
}
// End of nrDatabase
/* End of file nr_data.js */
