(function() {
    var Event = YAHOO.util.Event,
        Dom   = YAHOO.util.Dom,
        lang  = YAHOO.lang,
        slider, 
        bg="slider-bg", thumb="slider-thumb", 
        valuearea="slider-value", textfield="slider-converted-value"
        contentarea="the-content"        

    // The slider can move 0 pixels up
    var topConstraint = 0;

    // The slider can move 200 pixels down
    var bottomConstraint = 200;

    // Custom scale factor for converting the pixel offset into a real value
    var scaleFactor = 0.5;

    // The amount the slider moves when the value is changed with the arrow
    // keys
    var keyIncrement = 20;

    var tickSize = 20;

    var maxPosts = 104;

    var theURLs = new Array();
    theURLs[0] = "";
    theURLs[1] = "http://boldlentil.wordpress.com/2007/05/05/hello-world/";
    theURLs[2] = "http://boldlentil.wordpress.com/2007/05/05/cetacean-mutation/";
    theURLs[3] = "http://boldlentil.wordpress.com/2007/05/06/four-things-about-the-new-r2d2-mailboxes/";
    theURLs[4] = "http://boldlentil.wordpress.com/2007/05/09/domestic-politics/";
    theURLs[5] = "http://boldlentil.wordpress.com/2007/05/10/two-hundred-and-thirty-one-things-i-learned-using-the-internets/";
    theURLs[6] = "http://boldlentil.wordpress.com/2007/05/10/still-havent-finished-my-post-on-prcrastination/";
    theURLs[7] = "http://boldlentil.wordpress.com/2007/05/10/kimchi-chili/";
    theURLs[8] = "http://boldlentil.wordpress.com/2007/05/11/barcode-break-out/";
    theURLs[9] = "http://boldlentil.wordpress.com/2008/01/14/a-few-things-not-to-do-on-your-first-post/";
    theURLs[10] = "http://boldlentil.wordpress.com/2008/01/14/almost-perfectly-circular-holes/";
    theURLs[11] = "http://boldlentil.wordpress.com/2008/01/15/singing-songs-and-slitting-throats/";
    theURLs[12] = "http://boldlentil.wordpress.com/2008/01/16/cant-remember-the-spelling-of-mnemonic/";
    theURLs[13] = "http://boldlentil.wordpress.com/2008/01/17/no-sponsored-links-for-qdonut/";
    theURLs[14] = "http://boldlentil.wordpress.com/2008/01/18/macworld-meat-hat/";
    theURLs[15] = "http://boldlentil.wordpress.com/2008/01/19/unlikely-mechanisms/";
    theURLs[16] = "http://boldlentil.wordpress.com/2008/01/20/ulysses-and-his-ulysses/";
    theURLs[17] = "http://boldlentil.wordpress.com/2008/01/21/the-questions-die-and-new-ones-take-their-place/";
    theURLs[18] = "http://boldlentil.wordpress.com/2008/01/22/penrose-stamps/";
    theURLs[19] = "http://boldlentil.wordpress.com/2008/01/23/sortafunny/";
    theURLs[20] = "http://boldlentil.wordpress.com/2008/01/24/only-half-duck/";
    theURLs[21] = "http://boldlentil.wordpress.com/2008/01/25/banana-sushi/";
    theURLs[22] = "http://boldlentil.wordpress.com/2008/01/26/stone-rivers/";
    theURLs[23] = "http://boldlentil.wordpress.com/2008/01/27/okra-bag/";
    theURLs[24] = "http://boldlentil.wordpress.com/2008/01/28/stolen-salt-shakers/";
    theURLs[25] = "http://boldlentil.wordpress.com/2008/01/29/equinox-at-avebury/";
    theURLs[26] = "http://boldlentil.wordpress.com/2008/01/30/eyes-opened-eyes-closed/";
    theURLs[27] = "http://boldlentil.wordpress.com/2008/01/31/the-noodle-shop-and-city-hall/";
    theURLs[28] = "http://boldlentil.wordpress.com/2008/02/03/how-and-why-to-use-parentheses/";
    theURLs[29] = "http://boldlentil.wordpress.com/2008/02/04/a-screw-is-a-bottle-opener/";
    theURLs[30] = "http://boldlentil.wordpress.com/2008/02/05/close-enough/";
    theURLs[31] = "http://boldlentil.wordpress.com/2008/02/06/walrus-skulls/";
    theURLs[32] = "http://boldlentil.wordpress.com/2008/02/07/andre-the-giant-has-an-oboe/";
    theURLs[33] = "http://boldlentil.wordpress.com/2008/02/08/lemon-in-denial/";
    theURLs[34] = "http://boldlentil.wordpress.com/2008/02/10/lentils-versus-lintels/";
    theURLs[35] = "http://boldlentil.wordpress.com/2008/02/12/anatomy-of-a-1k-post/";
    theURLs[36] = "http://boldlentil.wordpress.com/2008/02/13/holzers-twitterings/";
    theURLs[37] = "http://boldlentil.wordpress.com/2008/02/15/how-to-get-dressed-in-the-morning/";
    theURLs[38] = "http://boldlentil.wordpress.com/2008/02/16/probably-not-a-banksy/";
    theURLs[39] = "http://boldlentil.wordpress.com/2008/02/16/fortunes-wheel-and-clean-lyrics/";
    theURLs[40] = "http://boldlentil.wordpress.com/2008/02/18/reindeer-tails/";
    theURLs[41] = "http://boldlentil.wordpress.com/2008/02/19/make-a-toilet-plunger-storage-thingy/";
    theURLs[42] = "http://boldlentil.wordpress.com/2008/02/20/no-one-has-a-monopoly-on-gorgeous/";
    theURLs[43] = "http://boldlentil.wordpress.com/2008/02/21/blognails/";
    theURLs[44] = "http://boldlentil.wordpress.com/2008/02/21/roll-your-own-blognails/";
    theURLs[45] = "http://boldlentil.wordpress.com/2008/02/24/the-ording-room/";
    theURLs[46] = "http://boldlentil.wordpress.com/2008/02/25/descartes-highlands/";
    theURLs[47] = "http://boldlentil.wordpress.com/2008/02/26/just-say-maybe-to-blog-jewelry/";
    theURLs[48] = "http://boldlentil.wordpress.com/2008/02/27/questions-about-furry-frames/";
    theURLs[49] = "http://boldlentil.wordpress.com/2008/02/29/how-to-deal-with-a-robot-manager/";
    theURLs[50] = "http://boldlentil.wordpress.com/2008/03/01/picking-unlucky-numbers/";
    theURLs[51] = "http://boldlentil.wordpress.com/2008/03/03/blognails-increase-page-views/";
    theURLs[52] = "http://boldlentil.wordpress.com/2008/03/04/if-james-joyce-had-had-access-to-the-internet/";
    theURLs[53] = "http://boldlentil.wordpress.com/2008/03/05/tsankawi-petroglyphs/";
    theURLs[54] = "http://boldlentil.wordpress.com/2008/03/07/personalized-styrofoam-cups/";
    theURLs[55] = "http://boldlentil.wordpress.com/2008/03/09/contraceptive-crafting/";
    theURLs[56] = "http://boldlentil.wordpress.com/2008/03/09/pi-vs-pii/";
    theURLs[57] = "http://boldlentil.wordpress.com/2008/03/10/harlem-before-daybreak/";
    theURLs[58] = "http://boldlentil.wordpress.com/2008/03/10/notions-of-marriage/";
    theURLs[59] = "http://boldlentil.wordpress.com/2008/03/11/the-inflammable-vapors-of-the-dictamnus-fraxinella/";
    theURLs[60] = "http://boldlentil.wordpress.com/2008/03/12/audition-to-become-a-commenter/";
    theURLs[61] = "http://boldlentil.wordpress.com/2008/03/13/4-lines-and-3-dots-from-bristol/";
    theURLs[62] = "http://boldlentil.wordpress.com/2008/03/14/quater-of-a-billion-in-unredeemed-california-crv/";
    theURLs[63] = "http://boldlentil.wordpress.com/2008/03/17/muse-rhymes-with-bruise/";
    theURLs[64] = "http://boldlentil.wordpress.com/2008/03/18/shame-on-yuh/";
    theURLs[65] = "http://boldlentil.wordpress.com/2008/03/20/bottom-posts/";
    theURLs[66] = "http://boldlentil.wordpress.com/2008/03/21/fake-coyotes/";
    theURLs[67] = "http://boldlentil.wordpress.com/2008/03/22/john-mccain-stencil/";
    theURLs[68] = "http://boldlentil.wordpress.com/2008/03/25/stencil-of-john-roberts-chief-justice/";
    theURLs[69] = "http://boldlentil.wordpress.com/2008/03/25/to-blind-eve/";
    theURLs[70] = "http://boldlentil.wordpress.com/2008/03/26/75-in-2012/";
    theURLs[71] = "http://boldlentil.wordpress.com/2008/03/27/rush-limbaugh-stencil/";
    theURLs[72] = "http://boldlentil.wordpress.com/2008/03/28/screen-shot-to-bmp-file-for-windows/";
    theURLs[73] = "http://boldlentil.wordpress.com/2008/03/29/ceci-nest-pas-une-spost/";
    theURLs[74] = "http://boldlentil.wordpress.com/2008/03/30/morro-rock/";
    theURLs[75] = "http://boldlentil.wordpress.com/2008/04/03/tintin-in-la/";
    theURLs[76] = "http://boldlentil.wordpress.com/2008/04/05/excuses-for-not-posting-in-a-while/";
    theURLs[77] = "http://boldlentil.wordpress.com/2008/04/06/quotes-from-dellillos-underworld/";
    theURLs[78] = "http://boldlentil.wordpress.com/2008/04/07/if-you-blog-just-one-thing-today/";
    theURLs[79] = "http://boldlentil.wordpress.com/2008/04/08/commentcaching/";
    theURLs[80] = "http://boldlentil.wordpress.com/2008/04/09/seductive-sed-awesome-awk/";
    theURLs[81] = "http://boldlentil.wordpress.com/2008/04/10/feral-pumpkins/";
    theURLs[82] = "http://boldlentil.wordpress.com/2008/04/11/trans-pacific-peat-pellet/";
    theURLs[83] = "http://boldlentil.wordpress.com/2008/04/12/another-day-another-donut/";
    theURLs[84] = "http://boldlentil.wordpress.com/2008/04/13/copying-and-gender/";
    theURLs[85] = "http://boldlentil.wordpress.com/2008/04/14/it-can-injure-you-to-write-too-quickly/";
    theURLs[86] = "http://boldlentil.wordpress.com/2008/04/17/incomprehensible-post-7/";
    theURLs[87] = "http://boldlentil.wordpress.com/2008/04/17/incomprehensible-post-8/";
    theURLs[88] = "http://boldlentil.wordpress.com/2008/04/17/incomprehensible-post-9/";
    theURLs[89] = "http://boldlentil.wordpress.com/2008/04/17/incomprehensible-post-10/";
    theURLs[90] = "http://boldlentil.wordpress.com/2008/04/17/incomprehensible-post-11/";
    theURLs[91] = "http://boldlentil.wordpress.com/2008/04/20/the-blog-post-that-got-me-kicked-off-google/";
    theURLs[92] = "http://boldlentil.wordpress.com/2008/04/21/karl-attacks/";
    theURLs[93] = "http://boldlentil.wordpress.com/2008/04/23/toxoplasmosis-choose-your-own-post-ending/";
    theURLs[94] = "http://boldlentil.wordpress.com/2008/04/24/lenigme-by-gustave-dore/";
    theURLs[95] = "http://boldlentil.wordpress.com/2008/05/01/gm-to-cut-1000s-announces-failed-business-plan/";
    theURLs[96] = "http://boldlentil.wordpress.com/2008/05/01/dont-something-the-elephant-seals/";
    theURLs[97] = "http://boldlentil.wordpress.com/2008/05/05/tubes-no-more/";
    theURLs[98] = "http://boldlentil.wordpress.com/2008/05/06/google-app-engine-randomish-numbers-generator/";
    theURLs[99] = "http://boldlentil.wordpress.com/2008/05/08/google-app-engine-twice-as-many-randomish-numbers-with-webapp-framework/";
    theURLs[100] = "http://boldlentil.wordpress.com/2008/05/08/google-app-engine-the-users-api/";
    theURLs[101] = "http://boldlentil.wordpress.com/2008/05/09/google-app-engine-basic-form-handling/";
    theURLs[102] = "http://boldlentil.wordpress.com/2008/05/12/google-app-engine-fun-with-the-datastore/";
    theURLs[103] = "http://boldlentil.wordpress.com/2008/05/15/google-app-engine-adding-javascript-and-images/"    

    var theTitles = new Array();
    theTitles[0] = "";
    theTitles[1] = "Remembering Gerald";
    theTitles[2] = "Cetacean Mutation";
    theTitles[3] = "Review of the new R2D2 Mailboxes";
    theTitles[4] = "Domestic Politics";
    theTitles[5] = "(n+1)(n/2) Things I Learned Using the Internets";
    theTitles[6] = "Still Haven\'t Finished my Post on Procrastination";
    theTitles[7] = "Kimchi Chili Recipe";
    theTitles[8] = "Barcode Break Out";
    theTitles[9] = "A Few Things Not To Do On Your First Post";
    theTitles[10] = "Almost Perfectly Circular Holes";
    theTitles[11] = "Singing Songs and Slitting Throats";
    theTitles[12] = "Can\'t Remember the Spelling of Mnemonic?";
    theTitles[13] = "No Sponsored Links for q=Donut?";
    theTitles[14] = "MacWorld Meat Hat";
    theTitles[15] = "Unlikely Mechanisms";
    theTitles[16] = "Ulysses and His Ulysses";
    theTitles[17] = "\"The questions die and new ones take their place\"";
    theTitles[18] = "Penrose Stamps";
    theTitles[19] = "sortaFunny++";
    theTitles[20] = "Only Half Duck";
    theTitles[21] = "Banana Sushi";
    theTitles[22] = "Stone Rivers";
    theTitles[23] = "Okra Bag";
    theTitles[24] = "Stolen Salt Shakers";
    theTitles[25] = "Equinox at Avebury";
    theTitles[26] = "Eyes Opened, Eyes Closed";
    theTitles[27] = "The Noodle Shop and City Hall";
    theTitles[28] = "How (and Why) To Use Parentheses";
    theTitles[29] = "A Screw is a Bottle Opener";
    theTitles[30] = "Close Enough";
    theTitles[31] = "Walrus Skulls";
    theTitles[32] = "Andre the Giant has an Oboe";
    theTitles[33] = "Lemon in Denial";
    theTitles[34] = "Lentils versus Lintels";
    theTitles[35] = "Anatomy of a 1K Post";
    theTitles[36] = "HOLZER\'S TWITTERINGS";
    theTitles[37] = "How to Get Dressed in the Morning";
    theTitles[38] = "Probably Not a Banksy";
    theTitles[39] = "Fortune\'s Wheel and Clean Lyrics";
    theTitles[40] = "Reindeer Tails";
    theTitles[41] = "Make a Toilet Plunger Storage Thingy";
    theTitles[42] = "No One Has a Monopoly on Gorgeous";
    theTitles[43] = "Blognails";
    theTitles[44] = "Roll Your Own Blognails";
    theTitles[45] = "The Ording Room";
    theTitles[46] = "Descartes Highlands";
    theTitles[47] = "Just Say Maybe to Blog Jewelry";
    theTitles[48] = "Questions About Furry Frames";
    theTitles[49] = "How to Deal With a Robot Manager";
    theTitles[50] = "Picking Unlucky Numbers";
    theTitles[51] = "Blognails Increase Page Views";
    theTitles[52] = "If James Joyce had had access to the internet...";
    theTitles[53] = "Tsankawi Petroglyphs";
    theTitles[54] = "Personalized Styrofoam Cups";
    theTitles[55] = "Contraceptive Crafting";
    theTitles[56] = "Pi vs. PII";
    theTitles[57] = "Harlem, Before Daybreak";
    theTitles[58] = "Notions of Marriage";
    theTitles[59] = "The Inflammable Vapors of the Dictamnus Fraxinella";
    theTitles[60] = "Audition to become a commenter!";
    theTitles[61] = "4 Lines and 3 Dots from Bristol";
    theTitles[62] = "Quarter of a Billion in Unredeemed California CRV?";
    theTitles[63] = "Muse Rhymes with Bruise";
    theTitles[64] = "Shame On Yuh";
    theTitles[65] = "Bottom Posts";
    theTitles[66] = "Fake Coyotes";
    theTitles[67] = "John McCain Stencil";
    theTitles[68] = "Stencil of John Roberts, Chief Justice";
    theTitles[69] = "To Blind Eve";
    theTitles[70] = "75 in 2012";
    theTitles[71] = "Rush Limbaugh Stencil";
    theTitles[72] = "Screen Shot to BMP File for Windows";
    theTitles[73] = "Ceci N\'est Pas Une Spost";
    theTitles[74] = "Morro Rock";
    theTitles[75] = "Tintin in L.A.";
    theTitles[76] = "Excuses for not Posting in a While";
    theTitles[77] = "Quotes from DeLillo\'s Underworld";
    theTitles[78] = "If You Blog Just One Thing Today";
    theTitles[79] = "Commentcaching";
    theTitles[80] = "Seductive Sed & Awesome Awk";
    theTitles[81] = "Feral Pumpkins";
    theTitles[82] = "Trans-Pacific Peat Pellet";
    theTitles[83] = "Another Day, Another Donut";
    theTitles[84] = "Copying and Gender";
    theTitles[85] = "\"It can injure you to write too quickly\"";
    theTitles[86] = "Incomprehensible Post #7";
    theTitles[87] = "Incomprehensible Post #8";
    theTitles[88] = "Incomprehensible Post #9";
    theTitles[89] = "Incomprehensible Post #10";
    theTitles[90] = "Incomprehensible Post #11";
    theTitles[91] = "The Post that got me Kicked Off Google";
    theTitles[92] = "Karl Attacks";
    theTitles[93] = "Toxoplasmosis: Choose Your Own Post Ending";
    theTitles[94] = "L\'Enigme by Gustave Dore";
    theTitles[95] = "GM to Cut 1000\'s, Announces Failed Business Plan";
    theTitles[96] = "Don\'t Something the Elephant Seals";
    theTitles[97] = "TUBES NO MORE";
    theTitles[98] = "Google App Engine: Randomish Numbers Generator";
    theTitles[99] = "Google App Engine: Twice as Many Randomish Numbers with webapp Framework";
    theTitles[100] = "Google App Engine: the Users API";
    theTitles[101] = "Google App Engine: Basic Form Handling";
    theTitles[102] = "Google App Engine: Fun with the Datastore";
    theTitles[103] = "Google App Engine: Adding JavaScript and Images";

    Event.onDOMReady(function() {

        slider = YAHOO.widget.Slider.getHorizSlider(bg, 
                         thumb, topConstraint, bottomConstraint, 10);

        slider.getRealValue = function() {
            return Math.round(this.getValue() * scaleFactor);
        }

        slider.subscribe("change", function(offsetFromStart) {

            var valnode = Dom.get(valuearea);
            var fld = Dom.get(textfield);

            // Display the pixel value of the control
            valnode.innerHTML = offsetFromStart;

            // use the scale factor to convert the pixel offset into a real
            // value
            var actualValue = slider.getRealValue();

            // update the text box with the actual value
            fld.value = actualValue;

            // Update the title attribute on the background.  This helps assistive
            // technology to communicate the state change
            Dom.get(bg).title = "slider value = " + actualValue;


        });

        // slider.subscribe("slideEnd", function() { 
        //   alert("slideEnd"); 
        // }); 

        slider.subscribe("slideStart", function() {
                YAHOO.log("slideStart fired", "warn");
            });

        slider.subscribe("slideEnd", function() {
                 YAHOO.log("slideEnd fired", "warn");
                 var endvalue = Dom.get(contentarea);
                 var i = slider.getRealValue();
                 if (i == 0) i = 1;
                 if (i > 90) i = 90;
                 endvalue.innerHTML = '';
                 for (j = 0; j < 10; j++) 
                 {
                   if ((i+j) < maxPosts) {
                     // This doesn't seem to work unless it's all on one line.
                     endvalue.innerHTML += '<a class="rt" href="' + theURLs[i+j] + '" target="_blank">' + theTitles[i+j] + '</a><br>';
                   }
                 }
           });

        // Listen for keystrokes on the form field that displays the
        // control's value.  While not provided by default, having a
        // form field with the slider is a good way to help keep your
        // application accessible.
        Event.on(textfield, "keydown", function(e) {

            // set the value when the 'return' key is detected
            if (Event.getCharCode(e) === 13) {
                var v = parseFloat(this.value, 10);
                v = (lang.isNumber(v)) ? v : 0;

                // convert the real value into a pixel offset
                slider.setValue(Math.round(v/scaleFactor));
            }
        });
        
        // Use setValue to reset the value to white:
        Event.on("putval", "click", function(e) {
            slider.setValue(100, false); //false here means to animate if possible
        });
        
        // Use the "get" method to get the current offset from the slider's start
        // position in pixels.  By applying the scale factor, we can translate this
        // into a "real value
        Event.on("getval", "click", function(e) {
            YAHOO.log("Current value: "   + slider.getValue() + "\n" + 
                      "Converted value: " + slider.getRealValue(), "info", "example"); 
        });
    });
})();
