        //<![CDATA[
        // variables referencing the HTML elements which
        // we modify dynamically.  They get initialized by
        // the initialize() function, which is called once
        // the browser has loaded the full page.
        var language_link, language_image;

        // mapping from each language's name to the URI of its
        // script image.
        var images =
        {
            '/images/main/mep1.gif':   'epiq',
            '/images/main/mep2.gif':   'epiq',
            '/images/main/mgw1.gif':   'gweydr',
            '/images/main/mgw2.gif':   'gweydr',
            '/images/main/mka1.gif':   'kamakawi',
            '/images/main/mka2.gif':   'kamakawi',
            '/images/main/mka3.gif':   'kamakawi',
            '/images/main/mka4.gif':   'kamakawi',
            '/images/main/mkn1.gif':   'knsl',
            '/images/main/mme1.gif':   'megdevi',
            '/images/main/mnj1.gif':   'njaama',
            '/images/main/mnj2.gif':   'njaama',
            '/images/main/mnj3.gif':   'njaama',
            '/images/main/mnj4.gif':   'njaama',
            '/images/main/mpe1.gif':   'petersonian',
            '/images/main/mpe2.gif':   'petersonian',
            '/images/main/msa1.gif':   'sathir',
            '/images/main/msa2.gif':   'sathir',
            '/images/main/msa3.gif':   'sathir',
            '/images/main/msh1.gif':   'sheli',
            '/images/main/msh2.gif':   'sheli',
            '/images/main/msi1.gif':   'sidaan',
            '/images/main/msi2.gif':   'sidaan',
            '/images/main/mta1.gif':   'tantyls',
            '/images/main/mx1.gif':    'x',
            '/images/main/mzh1.gif':   'zhyler',
            '/images/main/mzh2.gif':   'zhyler',
            '/images/main/mzh3.gif':   'zhyler',
            '/images/main/mzh4.gif':   'zhyler',
            '/images/main/mzh5.gif':   'zhyler'
        }

        function language_for(image_url)
        {
             return images[image_url]
        }
    
        // mapping from each language's name to the URI of its
        // main page.  Since it's completely predictable from the
        // name of the language, we don't need a map like the one
        // for images.
        function page_for(language_name)
        {
            return '/' + language_name + '/main.html'
        }
    
        // ditto for each language's style sheet.
        function css_for(language_name)
        {
            return '/' + language_name + '/index.css'
        }
    
        // randomly pick a language and set up the page to
        // feature its script and style.
        function pick_a_language()
        {
            var picked_image;

            // one-pass random element selection algorithm from Perl Cookbook
            // recipe 8.6:  Basically, we go through the list of languages, and
            // as we are considering the Nth one in the list, we roll an
            // N-sided die (computers are great at supplying dice with any

            // desired number of sides!) if we roll a 1 (or actually, a 0,
            // since a computerized six-sider is numbered 0-5), we tentatively
            // select the current language - but we don't stop, so that can
            // change later.   This is fair because:

            //      the 1st language has a 1/1 chance of being picked
            //          while we're looking at it, so it always gets picked.
            //      the 2nd language has a 1/2 chance of being picked
            //          while we're looking at it, so half the time we pick
            //          it and half the time we don't (which means the 
            //          choice is still #1).
            //      the 3rd language has a 1/3 chance of being picked
            //          while we're looking at it, so 1/3 of the time we
            //          pick it.  The other 2/3 of the time we leave whatever
            //          we had picked coming in - which half of that time
            //          will be 1 and the other half 2.  Since 1/2 of 2/3 is
            //          1/3, all 3 possibilities are equally likely going into
            //          number 4. 
            //      etc.
             
            // i is the number of the language we're currently considering.
            var i = 0

            // loop through all the keys in our images map
            for (var image in images)
            {
                // keep track of what number we're on
                i++

                // roll the die
                if (Math.random() * i < 1)
                {
                    // tentatively pick this language if we rolled < 1
                    picked_image = image;
                }
            }

            // now that we've picked a language, update the page to
            // feature it
            var language_name = language_for(picked_image)
            language_image.src = picked_image
            language_image.alt = "Example of " + language_name + " orthography"
            language_link.href = page_for(language_name)
        }
    
        // This function does our one-time setup; it's called as an
        // onload handler once the body of the page has fully loaded,
        // as specified in the <body> tag in the HTML.  
        //     It looks up the HTML elements we need to modify and remembers
        // pointers to them in the global variables we declared above,
        // calls pick_a_language() once to get the first script displayed
        // (note that in the HTML the image and link are empty!), and calls
        // the set_interval method on the browser Window object to arrange
        // for pick_a_language to be called every 5 seconds (5000
        // milliseconds) thereafter.

        function initialize()
        {
            language_link = document.getElementById("language_link")
            language_image = language_link.childNodes[0]
            pick_a_language()
            window.setInterval("pick_a_language()", 5000)
        }
  // ]]>