// 
// photo album handling
// copyright 2005, Bob Swanson
// You may use this code for your own
// slideshows, but please retain this
// copyright notice
//
var numbers = Array(
    "100_1751.jpg",
    // Looking at the stern, Waikiki Bar under its cover. [taken in Miami]
    "100_1752.jpg",
    //The Stars and Stripes flies from the stern of a cruise ship, a beautiful sight.
    "100_1759.jpg",
    //    Up forward, near the bow. There is a good view looking down from level 12. This photo was taken in the other direction, looking up at the forward superstructure with radar, ships horn, etc.
    "100_1764.jpg",
    //    The "rubber ducky" shower area is forward on the ship.
    "100_1763.jpg",
    //   Bob with his friend, Mr. Duck
    "100_1804.jpg",
    // Sandi tries out the basketball court, and yes, it works.
    "100_1807.jpg",
    //   The stack with the engine exhaust pipes. From up here, when the Pride was running, you could hear the individual cylinders firing.
    "100_1809.jpg",
    //   Nice logo on the side of the stack
    "100_1810.jpg",
    //  Looking forward at the pool area. There are two bars, a stage for entertainers, and four jacuzzis (two covered). The decking around the pool is HOT, wear your flip-flops!
    "100_1811.jpg",
    //   Closer view of the pool area
    "100_1812.jpg",
    //  More...
    "100_1813.jpg",
    // The ducky-shower in use
    "100_1851.jpg",
    //The Pride of America sits for her portrait at Coxen Hole, island of Roatan
    "100_1883.jpg",
    //   Also taken at Roatan
    "100_1884.jpg",
    //  Looking up at those huge exhaust pipes
    "100_1936.jpg",
    //  Manufacturer clearly marked on her side. We asked the captain, and apparently there is no "name plate" viewable inside the ship.
    "100_1937.jpg",
    //   Stern, with line handlers
    "100_1938.jpg",
    //  Looking up at the stern, you can see the rear-facing balconies.
    "100_2114.jpg",
    //   Stern view of the Pride
    "100_2115.jpg",
    //  More stern views...
    "100_2116.jpg",
    // More...
    "100_2117.jpg",
    //Stars and Stripes flying from the stern
    "100_2118.jpg",
    //   A tender being lowered
    "100_2119.jpg",
    //  Nearly down now
    "100_2139.jpg",
    // Forward superstructure. We were in the Panama Canal when this was taken.       
    "100_2140.jpg",
    //   Closeup, showing the very large ship's horn. Some people tried to view the canal transit from up there; hate to think what would have happened if the Captain decided to blow the horn!
    "100_2142.jpg",
    //   Looking forward near the bow on level 13. You can see the folks viewing the canal transit.
    "100_2143.jpg",
    //   Looking aft over the pool area, also at Panama
    "100_2377.jpg",
    //  A different level of debarking. This higher gangway platform was set up because of the tide. See later pictures...
    "100_2412.jpg",
    //   This gangway rig slowed down people trying to get back aboard.
    "100_2395.jpg",
    //   Looking up toward our cabin, note the inset. The folks nearest the stern would have their view greatly blocked.
    "100_2396.jpg",
    // Closer view of our cabin balcony
    "100_2400.jpg",
    //Stern of the Pride, taken in Puntarenas, Costa Rica
    "100_2399.jpg",
    //Closer view of the stern
    "100_2402.jpg",
    //Distance shot of the Pride at the pier in Puntarenas, next to an Indian freighter
    "100_2403.jpg",
    //   Taken from the beach. Puntarenas is a popular beach with weekenders from the capital San Jose.
    "100_2404.jpg",
    //   Closeup from same location
    "100_2409.jpg",
    //Sandi with Pride in background. Note the stern radar.
    "100_2410.jpg"
    //   Bob with Pride in background
    
);
var total_photos = 39;
var narratives = Array(
    //"100_1751.jpg",
    "Looking at the stern, Waikiki Bar under its cover; this photo was taken in Miami",
    //"100_1752.jpg",
    "The Stars and Stripes flies from the stern of a cruise ship, a beautiful sight.",
    //"100_1759.jpg",
    "Up forward, near the bow; there is a good view looking down from level 12; this photo taken in the other direction, looking up at the forward superstructure with radar, ships horn, etc.",
//    "100_1764.jpg",
   "The 'rubber ducky' shower area is forward on the ship",
    //"100_1763.jpg",
    "Bob with his new friend, Mr. Duck",
    //"100_1804.jpg",
    "Sandi tries out the basketball court, and yes, it works",
    //"100_1807.jpg",
    "The stack with the engine exhaust pipes; from up here, when the Pride was running, you could hear the individual cylinders firing",
    //"100_1809.jpg",
    "Nice logo on the side of the stack",
    //"100_1810.jpg",
    "Looking forward at the pool area; there are two bars, a stage for entertainers, and four jacuzzis (two covered); the decking around the pool is HOT, wear your flip-flops!",
    //"100_1811.jpg",
    "Closer view of the pool area, port side",
    //"100_1812.jpg",
    "Pool area, starboard side",
    //"100_1813.jpg",
    "The ducky-shower in use",
    //"100_1851.jpg",
    "The Pride of America sits for her portrait at Coxen Hole, island of Roatan",
    //"100_1883.jpg",
    "Also taken at Roatan",
    //"100_1884.jpg",
    "Looking up at those huge exhaust pipes",
    //"100_1936.jpg",
    "Manufacturer clearly marked on her side; we asked the captain, and apparently there is no 'name plate' viewable inside the ship",
    //"100_1937.jpg",
    "Stern, with line handlers",
    //"100_1938.jpg",
    "Looking up at the stern, you can see the rear-facing balconies",
    //"100_2114.jpg",
    "Stern view of the Pride",
    //"100_2115.jpg",
    "Another stern views",
    //"100_2116.jpg",
    "You can get a better view of the stern-facing balconies",
    //"100_2117.jpg",
    "Stars and Stripes flying from the stern",
    //"100_2118.jpg",
    "A tender being lowered",
    //"100_2119.jpg",
    "Nearly down now",
    //"100_2139.jpg",
    "Forward superstructure; taken in the Panama Canal",
    //"100_2140.jpg",
    "Closeup, showing the very large ship's horn; some people tried to view the canal transit from up there; hate to think what would have happened if the Captain decided to blow the horn!",
    //"100_2142.jpg",
    "Looking forward near the bow on level 13; you can see the folks viewing the canal transit",
    //"100_2143.jpg",
    "Looking aft over the pool area, also at Panama",
    //"100_2377.jpg",
    "A different level of debarking; this higher gangway platform was set up because of the tide; later, everyone tried to get back onboard",
    //"100_2412.jpg",
    "This gangway rig slowed down people trying to get back aboard",
    //"100_2395.jpg",
    "Looking up toward our cabin, note the inset; the folks nearest the stern would have their view greatly blocked",
    //"100_2396.jpg",
    "Closer view of our cabin balcony",
    //"100_2400.jpg",
    "Stern of the Pride, taken in Puntarenas, Costa Rica",
    //"100_2399.jpg",
    "Closer view of the stern",
    //"100_2402.jpg",
    "Distance shot of the Pride at the pier in Puntarenas, next to an Indian bulk carrier",
    //"100_2403.jpg",
    "Taken from the beach; Puntarenas is a popular beach with weekenders from the capital San Jose",
    //"100_2404.jpg",
    "Closeup from same location",
    //"100_2409.jpg",
    "Sandi with Pride in background; note the stern radar",
    //"100_2410.jpg",
    "Bob with Pride in background"
);
var titles = Array(
    //"100_1751.jpg",
    "Stern and Waikiki Bar",
    //"100_1752.jpg",
    "A Beautiful Sight",
    //"100_1759.jpg",
    "Up Forward",
    //    "100_1764.jpg",
    "'Rubber Ducky' Shower",
    //"100_1763.jpg",
    "Bob and Friend",
    //"100_1804.jpg",
    "Sandi Shoots Hoops",
    //"100_1807.jpg",
    "Large Stack",
    //"100_1809.jpg",
    "Logo",
    //"100_1810.jpg",
    "Pool Area",
    //"100_1811.jpg",
    "Pool Area",
    //"100_1812.jpg",
    "Pool Area",
    //"100_1813.jpg",
    "Ducky-Shower in Use",
    //"100_1851.jpg",
    "The Pride at Coxen Hole",
    //"100_1883.jpg",
    "Pride at Roatan",
    //"100_1884.jpg",
    "Major Exhaust Pipes",
    //"100_1936.jpg",
    "Manufacturer's Mark",
    //"100_1937.jpg",
    "Stern Line Handlers",
    //"100_1938.jpg",
    "Rear-Facing Balconies",
    //"100_2114.jpg",
    "Stern View",
    //"100_2115.jpg",
    "Stern View",
    //"100_2116.jpg",
    "Stern View",
    //"100_2117.jpg",
    "Stars and Stripes",
    //"100_2118.jpg",
    "Tender",
    //"100_2119.jpg",
    "Tender",
    //"100_2139.jpg",
    "Forward Superstructure",
    //"100_2140.jpg",
    "Very Large Ship's Horn",
    //"100_2142.jpg",
    "Bow Area",
    //"100_2143.jpg",
    "Pool Area",
    //"100_2377.jpg",
    "Gangway Platform",
    //"100_2412.jpg",
    "Trying to Get Back Aboard",
    //"100_2395.jpg",
    "Our Cabin",
    //"100_2396.jpg",
    "Our Cabin",
    //"100_2400.jpg",
    "Stern",
    //"100_2399.jpg",
    "Stern",
    //"100_2402.jpg",
    "Pride in Puntarenas",
    //"100_2403.jpg",
    "Pride Viewed from the Beach",
    //"100_2404.jpg",
    "Pride in Puntarenas",
    //"100_2409.jpg",
    "Sandi with Pride",
    //"100_2410.jpg",
    "Bob with Pride"
);

var current = 0;

var first_time = 1;

function first_pass()
{
    if (first_time === 1)
    {
      //  alert("first pass");
        load_picture(0); // load picture zero
        first_time = 0; // prevent re-invocation
    }
}

function build_selector()
{
    var selector = document.getElementById("picture_selector"); 
    
    for (i = 0 ; i < total_photos ; i++)
    {
        newtext = document.createTextNode(i + " - " + titles[i]); // text content
        newoption = document.createElement("option");
        newoption.setAttribute("value",i); // value is pic number only
        newoption.appendChild(newtext); // add text
        selector.appendChild(newoption);
    }
}

function create_selector()
{
    for (i = 0 ; i < total_photos ; i++)
    {
        document.write('<option value="' + i + '">' + 
                       i + " - " + titles[i] + '</option>');
    }
}

function get_thumb_url (position) {

    url = "http://www219.pair.com/swansonr/pics/panama2005/lthumbs/th_" + numbers[position];
    return url;
}

function get_picture_url (position) {

    url = "http://www219.pair.com/swansonr/pics/panama2005/" + numbers[position];
    return url;
}

//
// advance and load next if there is one
//
function load_next() {
    //alert(current);
    current = current + 1;
    if (current < total_photos)
    {
        load_picture(current);
    }
    else
    {
        current = current - 1;
        load_picture(total_photos - 1);
    }
}
//
// pop up window with current big photo
//
function load_current() {
    var the_picture_url = get_picture_url(current);
    window.open(the_picture_url,'panama_canal_photo','resizable=yes,scrollbars=yes');
}

function load_selected()
{
    var selector = document.getElementById("picture_selector"); 
    var cur = selector.options[selector.selectedIndex].value;
    //alert("load: " + cur);
    current = parseInt(cur);
    load_picture(current);
}

//
// decrement and load previous if there is one
//
function load_previous() {
    current = current - 1;
    if (current >= 0)
    {
        load_picture(current);
    }
    else
    {
        current = 0;
        load_picture(0);
    }
}

function load_picture(at)
{
    var ximage = document.getElementById("thumb"); // the IMG tag
    var the_thumb_url = get_thumb_url(at);
    ximage.setAttribute("src",the_thumb_url);
    var the_picture_url = get_picture_url(at);
    set_text(the_picture_url);
    set_head_narrative(at);
}

function removeAllChildren(xxx)
{
    while (xxx.hasChildNodes()) 
    {
        xxx.removeChild(xxx.firstChild);
    }
}

//
// sets the prompt just below the photo with
// an anchor that loads the full-size photo
//
function set_text(text)
{
    var prompt = document.getElementById("prompt");
    removeAllChildren(prompt); // remove all content
    //
    // add back in
    //
    newtext = document.createTextNode("View Larger Photo"); // text for anchor
    newpara = document.createElement("p"); // new wrapper for anchor
    newpara.setAttribute("class","timestamp"); // make it smaller 
    anchor = document.createElement("a"); // new anchor
    anchor.setAttribute("href",text);
    anchor.appendChild(newtext); // add text to anchor
    newpara.appendChild(anchor); // put anchor inside paragraph
    // DO NOT DO THIS FOR NOW  prompt.appendChild(newpara); // put paragraph into div
}


function set_head_narrative(position)
{
    //
    // first the heading
    //
    var subh = document.getElementById("subhead");
    removeAllChildren(subh); // remove all content
    //
    // add back in
    //
    newtext = document.createTextNode(titles[position]); // text for title
    newhead = document.createElement("h2"); 
    newhead.setAttribute("class","heading2");
    newhead.appendChild(newtext); // add text to heading
    subh.appendChild(newhead); // put heading into div
    //
    // now the narrative below
    //
    var narr = document.getElementById("narrative");
    removeAllChildren(narr); // remove all content
    //
    // add back in
    //
    newtext = document.createTextNode("[Image: " + position + "] " + narratives[position]); // text for narrative
    newpara = document.createElement("p"); // new wrapper for narrative
    newpara.setAttribute("class","body"); // make it normal
    newpara.appendChild(newtext); // add text to paragraph
    narr.appendChild(newpara); // put paragraph into div
}
