// 
// 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_1792.jpg",
    //"Our first get-together of the Cruisin' Eagles: on John and Nancy's spacious balcony.
    "100_1789.jpg",
    //"That's us, with the Miami cruise pier in the background.
    "100_1788.jpg",
    //"The Pride of America sailed from this cruise pier. The photo was also taken from John and Nancy's balcony.
    "100_1778.jpg",
    //"The balcony is located at level 10, the same level as the bridge. The pilot and officers are guiding the Pride out of Miami.
    "100_1910.jpg",
    //"A small party for the Eagles, again at John and Nancy's place.
    "100_1911.jpg",
    //"Same party, more CC'ers.
    "100_1912.jpg",
    //"Signing the new guestbook. We put this CruiseCritic guestbook in the ship's library for all future CC'ers.
    "100_1913.jpg",
    //"More of party...
    "100_1916.jpg",
    //"Watching a DVD about the Panama Canal.
    "100_1919.jpg",
    //"The Crusin' Eagles get acquainted.
    "100_1920.jpg",
    //"Watching the DVD
    "100_1921.jpg",
    //"More of the party.
    "100_1922.jpg",
    //"Nancy, our charming hostess, is facing us, just left of center in this photo.
    "100_1923.jpg",
    //"More...
    "100_1958.jpg",
    //"Later in the cruise, on our Tortuguero Canal boat trip, who should we see but more Cruisin' Eagles, out on their own tour!
    "100_2120.jpg",
    //"More CC'ers at the Captain's Reception
    "100_2121.jpg",
    //"John and Nancy's son Michael and his lovely fiancee, Missy.
    "100_2124.jpg",
    //"Cruisecritic folks are quick to provide feedback to the NLC staff.
    "100_2125.jpg",
    //"Having fun with the Cruisin' Eagles.
    "100_2127.jpg",
    //"Hobnobbin' with the Pride staff.
    "100_2128.jpg",
    //"More deep conversations.
    "100_2129.jpg",
    //"Gratuitous photo of us.
    "100_2348.jpg",
    //"Our teppanyaki chef took good care of our small Cruisin' Eagles group.
    "100_2349.jpg",
    //"Our group ready for dinner.
    "100_2350.jpg",
    //"Another gratuitous photo of us.
    "100_2351.jpg",
    //"Gosh, do we have to eat all of those scallops?
    "100_2357.jpg",
    //"John watches as our dinner gets prepared.
    "100_2566.jpg",
    //"Our Cruisin' Eagles are invited to the Captain's Farewell reception.
    "100_2567.jpg",
    //"It's also a "formal" night, so everyone is dressed up nicely.
    "100_2568.jpg",
    //"More CC'ers.
    "100_2569.jpg",
    //"Things got a bit crowded around the champagne.
    "100_2570.jpg",
    //"Who is that handsome gentleman?
    "100_2572.jpg",
    //"We all crowd together for a group photo on the grand staircase.
    "100_2573.jpg",
    //"Still getting it together...
    "100_2574.jpg",
    //"Some of us are having a great time, and others, well...
    "100_2575.jpg",
    //"The Cruisin' Eagles get together for a last-night's dinner.
    "100_2576.jpg",
    //"More happy diners.
    "100_2577.jpg",
    //"More...
    "100_2578.jpg",
    //"And More...
    "100_2579.jpg",
    //"Sorry, couldn't get everyone in the picture. Fire the camera-man!
    "100_2581.jpg"
    //"Ah good, Nancy will take the photos from now on!
    );
var total_photos = 41;
var narratives = Array(
    //"100_1792.jpg",
    "Our first get-together of the Cruisin' Eagles, enjoying the view from John and Nancy's spacious balcony as we leave Miami",
    //"100_1789.jpg",
    "Bob and Sandi, with the Miami cruise pier in the background",
    //"100_1788.jpg",
    "The Pride of America sailed from this cruise pier; this photo also taken from John and Nancy's balcony",
    //"100_1778.jpg",
    "Their balcony is located at level 10, the same level as the bridge; the pilot and officers are guiding the Pride out of Miami",
    //"100_1910.jpg",
    "A small party for the Eagles, again at John and Nancy's place",
    //"100_1911.jpg",
    "Same party, more CC'ers",
    //"100_1912.jpg",
    "Signing the new guestbook; we put this CruiseCritic guestbook in the ship's library for all future CC'ers",
    //"100_1913.jpg",
    "More of the CC party",
    //"100_1916.jpg",
    "Watching a DVD about the Panama Canal",
    //"100_1919.jpg",
    "The Crusin' Eagles get acquainted",
    //"100_1920.jpg",
    "Watching the Panama Canal DVD",
    //"100_1921.jpg",
    "More of the party",
    //"100_1922.jpg",
    "Nancy, our charming hostess, is facing us, just left of center in this photo",
    //"100_1923.jpg",
    "More party photos",
    //"100_1958.jpg",
    "Later in the cruise, on our Tortuguero Canal boat trip, who should we see but more Cruisin' Eagles, out on their own tour!",
    //"100_2120.jpg",
    "More CC'ers at the Captain's Reception",
    //"100_2121.jpg",
    "John and Nancy's son Michael and his lovely fiancee, Missy",
    //"100_2124.jpg",
    "Cruisecritic folks are quick to provide feedback to the NLC staff",
    //"100_2125.jpg",
    "Having fun with the Cruisin' Eagles",
    //"100_2127.jpg",
    "Hobnobbin' with the Pride staff",
    //"100_2128.jpg",
    "More deep conversations",
    //"100_2129.jpg",
    "Gratuitous photo of Bob and Sandi",
    //"100_2348.jpg",
    "Our teppanyaki chef took good care of our small Cruisin' Eagles group",
    //"100_2349.jpg",
    "Our group ready for dinner",
    //"100_2350.jpg",
    "Another gratuitous photo of Bob and Sandi",
    //"100_2351.jpg",
    "Gosh, do we have to eat all of those scallops?",
    //"100_2357.jpg",
    "John watches as our dinner gets prepared",
    //"100_2566.jpg",
    "Our Cruisin' Eagles are invited to the Captain's Farewell reception",
    //"100_2567.jpg",
    "It's also a 'formal' night, so everyone is dressed up nicely",
    //"100_2568.jpg",
    "More CC'ers",
    //"100_2569.jpg",
    "Things got a bit crowded around the champagne",
    //"100_2570.jpg",
    "Who is that handsome gentleman?",
    //"100_2572.jpg",
    "We all crowd together for a group photo on the grand staircase",
    //"100_2573.jpg",
    "Getting everyone ready to pose on the grand staircase",
    //"100_2574.jpg",
    "Some of us are having a great time, and others, well...",
    //"100_2575.jpg",
    "The Cruisin' Eagles get together for a last-night's dinner",
    //"100_2576.jpg",
    "More Cruisin' Eagles",
    //"100_2577.jpg",
    "Another table-full; the Liberty Restaurant staff was very helpful to seat our group at the 6-person tables",
    //"100_2578.jpg",
    "More Crusin' Eagles",
    //"100_2579.jpg",
    "Last table; sorry, couldn't get everyone in the picture; fire that photographer!",
    //"100_2581.jpg",
    "Ah good, Nancy will take the photos from now on!"
);
var titles = Array(
    //"100_1792.jpg",
    "First Cruisin' Eagles Party",
    //"100_1789.jpg",
    "Bob and Sandi",
    //"100_1788.jpg",
    "Miami Cruise Pier",
    //"100_1778.jpg",
    "Guiding the Pride",
    //"100_1910.jpg",
    "Crusin' Eagles Party",
    //"100_1911.jpg",
    "More CC'ers",
    //"100_1912.jpg",
    "Signing the Guestbook",
    //"100_1913.jpg",
    "More Party",
    //"100_1916.jpg",
    "Learning About the Panama Canal",
    //"100_1919.jpg",
    "The Crusin' Eagles",
    //"100_1920.jpg",
    "Watching the DVD",
    //"100_1921.jpg",
    "More Party",
    //"100_1922.jpg",
    "Nancy",
    //"100_1923.jpg",
    "More Party",
    //"100_1958.jpg",
    "Crusin' Eagles at the Tortuguero Canal",
    //"100_2120.jpg",
    "Captain's Reception",
    //"100_2121.jpg",
    "Michael and Missy",
    //"100_2124.jpg",
    "Cruisecritic Feedback",
    //"100_2125.jpg",
    "Having Fun",
    //"100_2127.jpg",
    "Hobnobbin'",
    //"100_2128.jpg",
    "Deep Conversations",
    //"100_2129.jpg",
    "Bob and Sandi",
    //"100_2348.jpg",
    "Teppanyaki Chef",
    //"100_2349.jpg",
    "Ready for Dinner",
    //"100_2350.jpg",
    "Bob and Sandi",
    //"100_2351.jpg",
    "Scallops, Anyone?",
    //"100_2357.jpg",
    "John Watches",
    //"100_2566.jpg",
    "Invite",
    //"100_2567.jpg",
    "'Formal' Dress-up",
    //"100_2568.jpg",
    "More CC'ers",
    //"100_2569.jpg",
    "Crowds",
    //"100_2570.jpg",
    "More Formal",
    //"100_2572.jpg",
    "Group Photo",
    //"100_2573.jpg",
    "Posing",
    //"100_2574.jpg",
    "More Posing",
    //"100_2575.jpg",
    "Last-Night's Dinner",
    //"100_2576.jpg",
    "Happy Diners",
    //"100_2577.jpg",
    "CC'ers",
    //"100_2578.jpg",
    "Crusin' Eagles",
    //"100_2579.jpg",
    "Photo Problems",
    //"100_2581.jpg",
    "New Photog"
);

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
}
