// 
// 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_1776.jpg",
    //Lifeboat drill. Our station was inside the Liberty Restuarant
    "100_1777.jpg",
    //More of the drill
    "100_1800.jpg",
    //Bob and wake
    "100_1814.jpg",
    //Other ships at sea
    "100_1846.jpg",
    //Sandi and Bob at dinner in Liberty Restaurant
    "100_1897.jpg",
    //Pride's bow thrusters move a nearly-1,000-foot ship with ease.
    "100_1904.jpg",
    //Cruisecritic group was invited to the Captain's cocktail party
    "100_1905.jpg",
    //Photo with the Captain himself
    "100_1909.jpg",
    //As Latitudes members (previous NCL cruisers), we attended a special get-together. Over 40% of the cruisers onboard were previous cruisers on NCL. More yet had been on other lines.
    "100_1925.jpg",
    //There were shows every night, including at sea.
    "100_1929.jpg",
    //Sandi in Skyline Restaurant
    "100_2348.jpg",
    //Our teppanyaki chef was from Maui!
    "100_2349.jpg",
    //Enjoying the teppanyaki inside the "East Meets West" restaurant (extra fee).
    "100_2364.jpg",
    //Another ship seen on the way to Puntarenas, Costa Rica
    "100_2363.jpg",
    //Closer look
    "100_2366.jpg",
    //The Pacific Ocean near Costa Rica
    "100_2428.jpg",
    //Jenny, our cabin steward, is from Guam
    "100_2431.jpg",
    //Door all decorated for upcoming July 4th
    "100_2433.jpg",
    //We had a lovely sunset at sea on July 3rd
    "100_2434.jpg",
    //This is a series, so not much to say, but enjoy the view
    "100_2436.jpg",
    //Sandi enjoying what she likes most about cruising: kickin' back!
    "100_2437.jpg",
    //More sunset...
    "100_2438.jpg",
    //More...
    "100_2439.jpg",
    //More...
    "100_2440.jpg",
    //More...
    "100_2441.jpg",
    //More...
    "100_2442.jpg",
    //More...
    "100_2443.jpg",
    //More...
    "100_2454.jpg",
    //Bob posing with the stuffed bear from the Gold Rush Saloon.
    "100_2456.jpg",
    //Sandi and her friend the bear.
    "100_2459.jpg",
    //Bob taking GPS readings; have to help the Captain keep us on course...
    "100_2467.jpg",
    //Our current position and speed, about 20 knots; we are off the coast of Mexico heading for Cabo San Lucas",
    "100_2465.jpg",
    //When at sea for several days, you make your own entertainment.
    "100_2466.jpg",
    //Bob finishes setting up the chess board the 'correct' way.
    "100_2413.jpg",
    //Another 'at sea' activity: stinking up the atmosphere in the Cigar Bar (Really, it's a good cigar, really!).
    "100_2493.jpg",
    //Some people used the promenade deck as a jogging track. There was no alternative, actually.
    "100_2497.jpg",
    //Another 'at sea' activity: waving from your balcony cabin at passers-by.
    "100_2499.jpg",
    //Maybe he should run for office or something...
    "100_2566.jpg"
    //Invite to 'farewell' Captain's party
    );
var total_photos = 39;
var narratives = Array(
    //100_1776.jpg",
    "Lifeboat drill; our station was inside the Liberty Restaurant",
    //100_1777.jpg",
    "Lifeboat drill continues",
    //100_1800.jpg",
    "Bob and wake",
    //100_1814.jpg",
    "Other ships at sea",
    //100_1846.jpg",
    "Sandi and Bob at dinner in Liberty Restaurant",
    //100_1897.jpg",
    "The Pride's bow thrusters move a nearly-1,000-foot ship with ease",
    //100_1904.jpg",
    "Our Cruisecritic group was invited to the Captain's cocktail party",
    //100_1905.jpg",
    "Sandi and Bob with Captain Kjell Nesheim",
    //100_1909.jpg",
    "As Latitudes members (previous NCL cruisers), we attended a special get-together; over 40% of the cruisers onboard were previous cruisers on NCL; more yet had cruised on other lines",
    //100_1925.jpg",
    "There were shows every night, including at sea",
    //100_1929.jpg",
    "Sandi in Skyline Restaurant",
    //100_2348.jpg",
    "Our teppanyaki chef was from Maui!",
    //100_2349.jpg",
    "Enjoying the teppanyaki inside the 'East Meets West' restaurant (definitely worth the extra fee)",
    //100_2364.jpg",
    "Another ship seen on the way to Puntarenas, Costa Rica",
    //100_2363.jpg",
    "Closeup of ship heading for Puntarenas",
    //100_2366.jpg",
    "The Pacific Ocean near Costa Rica",
    //100_2428.jpg",
    "Jenny, our cabin steward, is from Guam",
    //100_2431.jpg",
    "Door all decorated for upcoming July 4th",
    //100_2433.jpg",
    "We had a lovely sunset at sea on July 3rd",
    //100_2434.jpg",
    "More of the sunset on July 3rd",
    //100_2436.jpg",
    "Sandi enjoying what she likes most about cruising: kickin' back!",
    //100_2437.jpg",
    "More of the sunset on July 3rd",
    //100_2438.jpg",
    "More of the sunset on July 3rd",
    //100_2439.jpg",
    "More of the sunset on July 3rd",
    //100_2440.jpg",
    "More of the sunset on July 3rd",
    //100_2441.jpg",
    "More of the sunset on July 3rd",
    //100_2442.jpg",
    "More of the sunset on July 3rd",
    //100_2443.jpg",
    "More of the sunset on July 3rd",
    //100_2454.jpg",
    "Bob posing with the stuffed bear in the Gold Rush Saloon",
    //100_2456.jpg",
    "Sandi and her friend the bear",
    //100_2459.jpg",
    "Bob is taking GPS readings; we have to help the Captain keep us on course!",
    //100_2467.jpg",
    "Our current position and speed, about 20 knots; we are off the coast of Mexico heading for Cabo San Lucas",
    //100_2465.jpg",
    "When at sea for several days, you make your own entertainment",
    //100_2466.jpg",
    "Bob finishes setting up the chess board the 'correct' way",
    //100_2413.jpg",
    "Another 'at sea' activity: stinking up the atmosphere in the Cigar Bar (Really, it's a good cigar, really!)",
    //100_2493.jpg",
    "Some people used the promenade deck as a jogging track; there was no alternative, actually",
    //100_2497.jpg",
    "Another 'at sea' activity: waving from your balcony cabin at passers-by",
    //100_2499.jpg",
    "Maybe he should run for office or something",
    //100_2566.jpg",
    "Invitation to Captain's 'farewell' party"
);
var titles = Array(
    //100_1776.jpg",
    "Lifeboat Drill",
    //100_1777.jpg",
    "Lifeboat Drill",
    //100_1800.jpg",
    "Bob",
    //100_1814.jpg",
    "Ships",
    //100_1846.jpg",
    "Sandi and Bob",
    //100_1897.jpg",
    "Bow Thrusters",
    //100_1904.jpg",
    "Invitation",
    //100_1905.jpg",
    "Bob and Sandi with the Captain",
    //100_1909.jpg",
    "Latitudes Party Invitation",
    //100_1925.jpg",
    "Hollywood Theatre",
    //100_1929.jpg",
    "Sandi",
    //100_2348.jpg",
    "Teppanyaki Chef",
    //100_2349.jpg",
    "'East Meets West' Restaurant",
    //100_2364.jpg",
    "Ship",
    //100_2363.jpg",
    "Ship",
    //100_2366.jpg",
    "Pacific Ocean",
    //100_2428.jpg",
    "Jenny",
    //100_2431.jpg",
    "Decorated Door",
    //100_2433.jpg",
    "Sunset July 3rd",
    //100_2434.jpg",
    "Sunset July 3rd",
    //100_2436.jpg",
    "Sandi",
    //100_2437.jpg",
    "Sunset July 3rd",
    //100_2438.jpg",
    "Sunset July 3rd",
    //100_2439.jpg",
    "Sunset July 3rd",
    //100_2440.jpg",
    "Sunset July 3rd",
    //100_2441.jpg",
    "Sunset July 3rd",
    //100_2442.jpg",
    "Sunset July 3rd",
    //100_2443.jpg",
    "Sunset July 3rd",
    //100_2454.jpg",
    "Bob and Bear",
    //100_2456.jpg",
    "Sandi and Bear",
    //100_2459.jpg",
    "GPS Reading",
    //100_2467.jpg",
    "GPS Display",
    //100_2465.jpg",
    "Self-Entertainment",
    //100_2466.jpg",
    "Chess Board Setup",
    //100_2413.jpg",
    "Cigar Bar",
    //100_2493.jpg",
    "Jogging",
    //100_2497.jpg",
    "Strange Person on Balcony",
    //100_2499.jpg",
    "Strange Person on Balcony",
    //100_2566.jpg",
    "Invitation"
);

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
}
