﻿    // scripts.js
  
    //////////////////////
    // global variables //
    //////////////////////
    // viewport
    var dx = 0;
    var dy = 0;
    var left_new;
    var top_new;
    var city_cur;
    var city_end;
    var page_cur;
    var photo_cur;
    var disablePrior = 0;
    var photoDisablePrior = 0;
    var disableNext = 0;
    var photoDisableNext = 0;
    var autoPhoto = 0;
    var autoId = 1;

    // initial loading
    var cnt_onLoadAlbum = 0;
    var inital_loading = 1;
    
    // preload support
    var active_album = 0;
    var preload_album_cur = 0;
    var preloadImagesAlbum;
    var active_photos = 0;
    var preload_photos_cur = 0;
    var preloadImagesPhotos;
       
    // objects
    var cities;
    var maxCities = 11;
    var pages;
    var maxPages = 32;
    var photos;
    var maxPhotos = 24;
      
    /////////////
    // objects //
    /////////////
       
    function City(id, name, x, y)
    {
        this.id = id;
        this.name = name;
        this.x = x;
        this.y = y;
    }
    
    function InitCities()
    {
        cities = new Array(maxCities);
        cities[0] = new City(1, "Paris", 0,0);
        cities[1] = new City(2, "Beaune", 199, 208);
        cities[2] = new City(3, "Lauterbrunnen", 418, 240);
        cities[3] = new City(4, "Liechtenstein", 589, 177);
        cities[4] = new City(5, "Lindau", 560, 130);
        cities[5] = new City(6, "Reutte", 658, 148);
        cities[6] = new City(7, "Egna", 754,251);
        cities[7] = new City(8, "Verona", 693, 389);
        cities[8] = new City(9, "Venice", 813, 392);
        cities[9] = new City(10, "Florence", 759, 603);
        cities[10] = new City(11, "Rome", 846, 825);
        city_cur = 1; // init to paris
        var o = document.getElementById("map");
        o.scrollLeft = 0;
        o.scrollTop = 0;
    }
    
    function Page(id, country_id, city_id, desc)
    {
      this.id = id;
      this.country_id = country_id;
      this.city_id = city_id;
      this.desc = desc;
      this.GetPageFile = GetPageFile;
      this.GetSmallPageFile = GetSmallPageFile
    }
    
    function GetPageFile()
    {
      var fileName = "images/page"+this.id+".jpg";
      return fileName;
    }
    
    function GetSmallPageFile()
    {
      var fileName = "images/page"+this.id+"_s.jpg";
      return fileName;
    }
    
    function InitPages()
    {
      pages = new Array(maxPages);
      pages[0] = new Page(1,1,1,"April 27:  Arrived a day early to enjoy Paris!  Luxembourg Gardens was only minutes away from our hotel.  Following a rest, we walked to the Montparnasse tower for great panoramic views of Paris.");
      pages[1] = new Page(2,1,1,"April 28:  We met our tour guide Colleen and our travelling companions for the next two weeks.  After an elegant dinner at the Mortparasse 1900 restaurant, we traveled to the St. Michelle metro stop to take our scenic Seine river cruise.");
      pages[2] = new Page(3,1,1,"April 29:  Despite the cold and rain we managed to see the sights of Paris.  First we visited Ste. Chapelle with amazing stain glass windows.  Next, Colleen gave us a tour of the Notre Dame cahedral and a tour of the Latin quarter including some of the original medieval streets.  After lunch we took a bus to the d'Orsay museum to view impressionalist masterpieces."); 
      pages[3] = new Page(4,1,1,"April 30:  Today we loaded our luggage on a Heidibloom bus and met our driver, Herbie.  We drove to the Louvre and met our museum guide.  Audio headphones allowed us to clearly hear commentary by our guide.");
      pages[4] = new Page(5,1,1,"April 30:  For the next several hours we had a comprehensive tour of the Louvre including ancient statues, royal jewels and the famous Mona Lisa painting.  Following lunch we met in the center hall where the inverted pyramid is located.  Unlike the Da Vinci Code book, the external pyramid is not located directly over the internal pyramid.");
      pages[5] = new Page(6,1,1,"April 30:  A few contrasting photos of Paris as we depart for our next destination - the town of Beaune in the Burgundy region.");
      pages[6] = new Page(7,1,2,"April 30:  Our Beaune hotel had amazing character and the host couple was very friendly. There was a maze of different stairs and hallways to reach our room.  There was also a charming courtyard including vases, flowers, statues and numerous other docorations.");
      pages[7] = new Page(8,1,2,"April 30:  Later we visited the Couvent des Cordeliers (established in 1243) for wine tasting. In the basement were numerous wine barrels and bottles.  Our guide explains the proper technique for wine tasting and informs us of the different local and regional types.");
      pages[8] = new Page(9,1,2,"May 1:  We got up early to explore this interesting countryside town.  Breakfast included croissants, homemade bread and jam and delicious hot chocolate served with hot milk.  While exploring the town we asked a gentleman for directions for the Notre Dame church.  To our surprise, he stopped what he was doing and walked with us for several blocks until we arrived.");
      pages[9] = new Page(10,2,3,"May 1:  Our next stop was Switzerland.  When we arrived in Lauterbrunnen, we were struck by the breath taken scenery.  Lauterbrunnen is a quant village located in a valley of majestic mountains.  There is also an amazing waterfall.  The views from our hotel were fantastic.");
      pages[10] = new Page(11,2,3,"May 2:  After boarding the bus for a quick trip to Murren we took a gondola through a number of villages to reach the peak of the Schilthorn at 10,000 feet.  The whole trip took less than an hour.  The views were incredible.  At the top was a rotating restaurant.  Temperature was 33 degrees.  A few snow boarders took off from the top of the mountain!");
      pages[11] = new Page(12,2,3,"May 2:  After a snack we took the gondola back to Murren.  We then  walked the remaining 3 miles in the valley back to Lauterbrunnen.  This path was very scenic, following a river with mountain views, numerous waterfalls, rustic barns and Swiss cows.  We had an amazing day!");
      pages[12] = new Page(13,3,4,"May 3:  Next we travelled to Austria.  On the way we visited the country of Liechtenstein.  Litechtenstein is one of the smallest countries in the world.  Some interesting sites included a number of bronze horse statues, a model of a fortress, a visitor's train and a Custom house that will stamp your passport for a couple of Euros");
      pages[13] = new Page(14,4,5,"May 3:  We then traveled to Lindau, Germany where we had time for lunch and for exploring.  Colleen provided a map of the town.  Following lunch we had time to visit an ancient church and then climb the stairs of an old lighthouse with a great view of the harbor.");
      pages[14] = new Page(15,5,6,"May 3:  In the late afternoon we arrived at our hotel in Austria near Ruette and German border.  The hotel is a farmhouse style inn complete with horses, ducks, deer and views of the alps.  A washing machine was available for 7 Euros a load (very popular!).  This was another chance to just relax and enjoy the countryside.  Moutain bikes were also available.");
      pages[15] = new Page(16,4,6,"May 4:  This morning we met our fellow travellers for a three mile walk starting from our hotel and through the woods on an ancient Roman road.  Along the way, we left Austria and entered Germany.  After 1.25 hours, the path opened up to the Neuschwanstein castle.  What a view!  Following a walk to a scenic bridge overlooking the castle, we met in the courtyard for our English tour.");
      pages[16] = new Page(17,4,6,"May 4:  Once we met up with our tour group, we had a picnic along the adjacent lake.  Colleen provided sandwiches, drinks, chips and cookies.  While we ate lunch, about 40 handgliders flew over us!  Later we boarded the bus and stopped at an alpine slide.  We all enjoyed several runs down the slide.  Back at the hotel, another feast awaited us.");
      pages[17] = new Page(18,4,6,"May 4:  This evening's feast was buffet style.  Following dinner, we had a chance to catch up on post cards.  What a fun day!");
      pages[18] = new Page(19,6,7,"May 5:  After a hearty breakfast, we boarded the bus for Venice.  For lunch we stopped at a small village in the Dolomites known by two names, Italian Egna and German Neumarkt.  The restaurant was expecting us.  Each table was served four types of incredible pizza including ham & mushroom, spicy, pepperoni and cheese.  Our table was served an extra vegetarian pizza.");
      pages[19] = new Page(20,6,9,"May 5:  We arrived in Venice on the mainland where we left our bus.  A water taxi brought us within minutes of our hotel.  Our hotel was near the Academia Museum and only 10 minutes away from St. Marks square.  After we had settled in, Colleen gave us a introductionary tour of St. Marks square, the Doge's Palace, bell tower and the bridge of sighs.");
      pages[20] = new Page(21,6,9,"May 6:  Today we met a Venician guide for a detailed tour of this amazing city.  An interesting site we visited was where they construct gondolas.  Following the tour we visited St. Marks and the bell tower.  We tried to leave the bell tower at 11:45 a.m. but a large group of school kids were waiting for the elevator.  The ringing of the bells directly above our heads was an event we will not forget!");
      pages[21] = new Page(22,6,9,"May 6:  Once our hearing returned, we walked out to the famous Rialto bridge where Cyndi shopped at shop '79' for some jewelry.  Colleen recommended this store for its friendly owners and reasonable prices.  She provided great advice.");
      pages[22] = new Page(23,6,9,"May 6:  After taking a water taxi to go to San Giorgio Maggiore island, we climbed to the top of the church tower for fantastic views of Venice and St. Marks square.  At sunset we joined our group for a romantic gondola ride complete with two musicians.  It was very magical to pass through dimly lit canals under the stars, especially with the singing.  It was a special moment, one we will always remember.");
      pages[23] = new Page(24,6,9,"May 7:  Our next stop was Regallo, Tuscany.  Several of us enjoyed a last walk around Venice before our departure.  Venice was definitely one of the highlights of our tour!");
      pages[24] = new Page(25,6,10,"May 7:  We arrive at our Tuscan villa, originally a convent in the 12th century.  It was later renovated as a farmhouse during the 1400s.  Today it is an agricultural villa compete with horses, chickens, ducks, vineyards, olive trees and a swimming pool.  Dinner consists of a multi course feast that gives new meaning to the phrase house wine!");
      pages[25] = new Page(26,6,10,"May 8:  Breakfast was amazing.  Our hosts brought out hot rolls and croissants filled with a honey, berry filling and covered with confectionary sugar.  Our Tuscan villa was a great place to relax and explore the scenic countyside.  Our bus driver Herbie enjoyed a bike ride.");
      pages[26] = new Page(27,6,10,"May 8:  We boarded the bus for a trip to nearby Florence.  A local guide brought us to the city square, Academia and Ufuzzi galleries.  The guide provided fascinating insight into many of the famous paintings and sculptures such as Michelangelo's David.  We then had free time to explore the city and enjoy some incredible gelato.");
      pages[27] = new Page(28,6,11,"May 9:  Our last stop was Rome.  We took the metro to the Colosseum where a local guide spent several hours giving us a detailed tour of the Coloseum, the Forum and the Pantheon.  It was amazing to think about the history all around us.");
      pages[28] = new Page(29,6,11,"May 9:  Our local guide effectively explained how the ruins would have appeared 2000 years ago.  Incredibly, the Pantheon is still intact.  The dome shaped ceiling allowed rays of light to illuminate the richly detailed floors and walls.");
      pages[29] = new Page(30,6,11,"May 9-10:  After dinner, Colleen took us on a night walk through Rome back to our hotel.  Along the way we stopped at the Trevi fountain and ate some more gelato.  The next morning we slept in!  We met at 11:00 a.m. to travel to St. Peters for a tour of the Vatican Museum and Sistine Chapel.");
      pages[30] = new Page(31,6,11,"May 10:  Following the tour, Cyndi and I took an elevator up to the dome and then climbed up the remaining 350 steps to the top for a magnificent view of St. Peters and Rome.  We actually walked up a very confined spiral staircase between the inner and outer domes.");
      pages[31] = new Page(32,6,11,"May 10:  After leaving St. Peters we shopped and then stopped for our last gelato.  Later we met our tour group for a final farewell dinner.  Although the food was great, it was sad to say goodbye to all of our new friends.  Tomorrow we depart Europe for our return flight back to the U.S.  We are already thinking about our next European vacation!");
      page_cur = 1;
      
      // load images
      document.getElementById('img_page').src = "images/page1.jpg";
      document.getElementById('img_herby').src = "images/Herby.jpg";
      document.getElementById('img_page_s').src = "images/page1_s.jpg";
      document.getElementById('img_map').src = "images/map.jpg";
      
      // preload support
      preloadImagesAlbum = new Array(maxPages);
      for (ndx=0; ndx<maxPages; ndx++)
      {
       preloadImagesAlbum[ndx] = new Image();
      }
    }
    
    function Photo(id, orientation, desc)
    {
      this.id = id;
      this.orientation = orientation;
      this.desc = desc;
      this.GetPhotoId = GetPhotoId;
      this.GetPhotoFile = GetPhotoFile;
      this.GetMicroPhotoFile = GetMicroPhotoFile;
    }
    
    function GetPhotoId()
    {
      var photoId = 'img_p' + this.id;
      return photoId;
    }
    
    function GetPhotoFile()
    {
      var fileName = "images/photo"+this.id+".jpg";
      return fileName;
    }
    
    function GetMicroPhotoFile()
    {
      var fileName = "images/photo"+this.id+"_m.jpg";
      return fileName;
    }
    
    function InitPhotos()
    {
       photos = new Photo(maxPhotos);
       photos[0] = new Photo(1,"h","Group photo in front of our Tuscan villa");
       photos[1] = new Photo(2,"h","Amazing views in Lauterbrunnen, Switzerland");
       photos[2] = new Photo(3,"h","View of Neuschwanstein castle following a three mile walk from our Austrian hotel"); 
       photos[3] = new Photo(4,"h","We stopped at the Italian Dolomites town of Egna for delicious Pizza");
       photos[4] = new Photo(5,"v","Venice Siesta");
       photos[5] = new Photo(6,"v","Eiffel Tower during our river seine cruise");
       photos[6] = new Photo(7,"h","In Paris, we visited Ste. Chapelle with amazing stain glass windows");
       photos[7] = new Photo(8,"h","Looking down at our hotel in Ruette Austria");
       photos[8] = new Photo(9,"h","Horses at our Austrian hotel");
       photos[9] = new Photo(10,"v","A view from inside the Neuschwanstein castle");
       photos[10] = new Photo(11,"h","The canals of Venice near the Rialto bridge");
       photos[11] = new Photo(12,"h","Architecture and sunset patterns on the Doge's Palace");
       photos[12] = new Photo(13,"v","Venetian cat and dog observing people on the bridge");
       photos[13] = new Photo(14,"v","A decorative window in Venice near our hotel");
       photos[14] = new Photo(15,"h","St Mark's square at sunset prior to our romantic gondola ride");
       photos[15] = new Photo(16,"h","Sunset at our Tuscan villa");
       photos[16] = new Photo(17,"v","Wild flowers and an old church near our Tuscan villa");
       photos[17] = new Photo(18,"h","Vineyards at sunrise");
       photos[18] = new Photo(19,"v","Colorful Tuscan landscape");
       photos[19] = new Photo(20,"v","Our tour guide Colleen and bus driver Herbie");
       photos[20] = new Photo(21,"h","Relaxing by the pool in the Tuscan countryside");
       photos[21] = new Photo(22,"h","Enjoying gelato in Florence");
       photos[22] = new Photo(23,"v","Illumination at the Pantheon in Rome");
       photos[23] = new Photo(24,"h","The view after climbing 350 steps to the top of St Peters");
       photo_cur = 1;
       
       // load images 
       document.getElementById('img_p1').src = "images/photo1_m.jpg";
       document.getElementById('img_p2').src = "images/photo2_m.jpg";
       document.getElementById('img_p3').src = "images/photo3_m.jpg";
       document.getElementById('img_p4').src = "images/photo4_m.jpg";
       document.getElementById('img_p5').src = "images/photo5_m.jpg";
       document.getElementById('img_p6').src = "images/photo6_m.jpg";
       document.getElementById('img_p7').src = "images/photo7_m.jpg";
       document.getElementById('img_p8').src = "images/photo8_m.jpg";
       document.getElementById('img_p9').src = "images/photo9_m.jpg";
       document.getElementById('img_p10').src = "images/photo10_m.jpg";
       document.getElementById('img_p11').src = "images/photo11_m.jpg";
       document.getElementById('img_p12').src = "images/photo12_m.jpg";
       document.getElementById('img_p13').src = "images/photo13_m.jpg";
       document.getElementById('img_p14').src = "images/photo14_m.jpg";
       document.getElementById('img_p15').src = "images/photo15_m.jpg";
       document.getElementById('img_p16').src = "images/photo16_m.jpg";
       document.getElementById('img_p17').src = "images/photo17_m.jpg";
       document.getElementById('img_p18').src = "images/photo18_m.jpg";
       document.getElementById('img_p19').src = "images/photo19_m.jpg";
       document.getElementById('img_p20').src = "images/photo20_m.jpg";
       document.getElementById('img_p21').src = "images/photo21_m.jpg";
       document.getElementById('img_p22').src = "images/photo22_m.jpg";
       document.getElementById('img_p23').src = "images/photo23_m.jpg";
       document.getElementById('img_p24').src = "images/photo24_m.jpg";
       document.getElementById('img_photo').onload = OnLoadPhoto;
       document.getElementById("img_photo").src = "images/photo1_s.jpg";
       
       // preload support
       preloadImagesPhotos = new Array(maxPhotos);
       for (ndx=0; ndx<maxPhotos; ndx++)
       {
        preloadImagesPhotos[ndx] = new Image();
       }
    }
    
    function InitAbout()
    {
      // load image
      document.getElementById('img_about').onload = OnLoadAbout;
      document.getElementById("img_about").src = "images/about_s.jpg";
    }
       
    ///////////////////////
    // viewport function //
    ///////////////////////
    function scroll(city_id) {
    
        if (city_id == city_cur)
        {
          return;   // nothing to do
        }
        var o = document.getElementById("map");
        var left = o.scrollLeft;
        var top = o.scrollTop;
  
        // initial method call for new city destination
        if (city_id != 0)
        {
            city_end = city_id;
            if (city_end > city_cur)
            {
              city_cur++;
            }
            else
            {
              city_cur--;
            }
            left_new = cities[city_cur-1].x;
            top_new = cities[city_cur-1].y;
            dx = left_new-left;
            dy = top_new-top;
        }
        // shift 1 pixel right or left
        if (dx != 0)
        {
          if (dx > 0)
          {
            dx--;
            left++;
          }
          else
          {
            dx++;
            left--;
          }
          o.scrollLeft = left;
        }
        // shift 1 pixel down or up
        if (dy != 0)
        {
          if (dy > 0)
          {
            dy--;
            top++;
          }
          else
          {
            dy++;
            top--;
          }
          o.scrollTop = top;
        }
        
        // have we reached waypoint?
        if (dx ||dy)
        {
          // no call this function again - up to 50 times / second
          setTimeout("scroll(0);",20);
        }
        else // have reached city point
        {
          // at final destination?
          if (city_cur != city_end)
          {
            // no, next city
            if (city_end > city_cur)
            {
              city_cur++;
            }
            else
            {
              city_cur--;
            }
            left_new = cities[city_cur-1].x;
            top_new = cities[city_cur-1].y;
            dx = left_new-left;
            dy = top_new-top;
            setTimeout("scroll(0);",40);
          }
        }
        // else have reached final destination
    }
    
    function changeOpac(opacity, id)
    {
	    var object = document.getElementById(id).style; 
	    object.opacity = (opacity / 100);
	    object.MozOpacity = (opacity / 100);
	    object.KhtmlOpacity = (opacity / 100);
	    object.filter = "alpha(opacity=" + opacity + ")";
    } 
      
    ///////////////
    // functions //
    ///////////////
    
    function Onload()
    {
      InitCities();
      InitPages();
    }
    
    function OnLoadAlbum()
    {
       cnt_onLoadAlbum++;
       if (cnt_onLoadAlbum == 1) return;
       
       // display album divs
       ShowObject('page_s',1);
       ShowObject('button_album',1);
       ShowObject('map',1);
          
       // disable load method
       document.getElementById('img_map').onload = "";
       
       // load photo divs
       document.getElementById('wait').innerText = "Loading 'Additional Photos' components...";
       document.getElementById('wait').textContent = "Loading 'Additional Photos' components...";
       setTimeout('InitPhotos();',10);
     }
     
     function OnLoadPhoto()
    {
      if (inital_loading == 1)
      {
          // display photo divs
          ShowObject('photo',1);
          ShowObject('button_photo',1);
          document.getElementById('wait').innerText = "Loading 'About this Site' components...";
          document.getElementById('wait').textContent = "Loading 'About this Site' components...";
          setTimeout('InitAbout();',10);
      }
      else
      {
          if (active_photos && document.getElementById('img_photo').style.width > '200px')
          {
             if (autoPhoto == 1)
              {
                new Effect.Appear('img_photo',{duration: .75, from: .25});
              }
              else
              {
                new Effect.Appear('img_photo',{duration: .10, from: .25});
              }
              DisplayPhotoDesc();
              ValidatePhotoPriorNextButton();
          }
      }
    }
       
    function OnLoadAbout()
    {
      // display about divs
      ShowObject('about',1);
      ShowObject('button_about',1);
      ShowObject('wait',0);
      
      // disable load method
      document.getElementById('img_about').onload = "";
      
      inital_loading = 0;
    }
    
    function PageOn()
    {
        active_album = 1;
        ShowObject("photo",0);
        ShowObject("about",0);
        ShowObject("button_about",0);
        ShowObject("button_photo",0);
        ShowObject("button_album",0);
        new Effect.DropOut("page_s");
        document.getElementById("album_page").style.display = 'none';
        ShowObject("album_page",1);
        //if(navigator.userAgent.indexOf("Firefox") != -1)
        //{
         new Effect.Appear("album_page");
        //}
        //else
        //{
         // new Effect.Grow("album_page");
        //}
        setTimeout("DisplayPage();",500);
        setTimeout("ShowObject('toolbar_album',1);", 700);
        setTimeout("ShowObject('desc',1);", 700);

        // preload images
        setTimeout("PreloadAlbum();",50);
   }       
       
    function PageOff()
    {
        ShowObject("toolbar_album",0);
        ShowObject("desc",0);
        new Effect.BlindUp("album_page");
        DisplaySmallPage();
        new Effect.Grow("page_s");
        setTimeout("ShowObject('button_album',1);",1000);
        
        setTimeout("ShowObject('photo',1);",1000);
        setTimeout("ShowObject('about',1);",1000);
        setTimeout("ShowObject('button_about',1);",1100);
        setTimeout("ShowObject('button_photo',1);",1100);
        active_album = 0;
    }
    
    function ShowObject(id, show)
    {
      var obj = document.getElementById(id);
      if (show == 1)
      {
          obj.style.visibility = "visible";
      }
      else
      {
          obj.style.visibility = "hidden";
      }
    }
    
    function DisplayPage()
    {
       var file = pages[page_cur-1].GetPageFile();
       // set div background to original image
       // load new image with 0 opacity
	   document.getElementById("album_page").style.backgroundImage = "url(" + document.getElementById("img_page").src + ")";
	   changeOpac(0, "img_page");
	   document.getElementById("img_page").src = file;
       new Effect.Appear("img_page",{duration: .5});
       setTimeout("DisplayDesc();",250);
       ValidatePriorNextButton();
       
       // Herby's ride
       if (page_cur == 26)
       {
         setTimeout("AnimateHerby();",2000);
       }
    }
    
    function AnimateHerby()
    {
        document.getElementById('herby').style.left = 788;
        ShowObject("herby",1);
        new Effect.Morph('herby',{style:'left: -125px;', delay: 0, duration:4});
    }
    
    function DisplayDesc()
    {
      document.getElementById("desc").innerText = pages[page_cur-1].desc;
      document.getElementById("desc").textContent = pages[page_cur-1].desc;
    }
    
    function DisplaySmallPage()
    {
       var file = pages[page_cur-1].GetSmallPageFile();
       document.getElementById("img_page_s").src = file;
    }
    
    function PriorPage()
    {
      if (page_cur > 1)
      {
        page_cur--;
        DisplayPage();
        scroll(pages[page_cur-1].city_id);
      }
    }
    
    function NextPage()
    {
       if (page_cur < maxPages)
       {
        page_cur++;
        DisplayPage();
        scroll(pages[page_cur-1].city_id);
       }
    }
    
    function EnableButton(id,state)
    {
      if (state == 1)
      {
        changeOpac(100,id);
        document.getElementById(id).disabled = "";
      }
      else if (state == 0)
      {
        changeOpac(25,id);
        document.getElementById(id).disabled = "disabled";
      }
    }
    
    function ValidatePriorNextButton()
    {
      if (page_cur == 1 && disablePrior == 0)
      {
        EnableButton("prior",0);
        disablePrior = 1;
      }
      if (page_cur != 1 && disablePrior == 1)
      {
        EnableButton("prior",1);
        disablePrior = 0;
      }
      if (page_cur == maxPages && disableNext == 0)
      {
        EnableButton("next",0);
        disableNext = 1;
      }
      if (page_cur != maxPages && disableNext == 1)
      {
        EnableButton("next",1);
        disableNext = 0;
      }
    }
    
    function SelectCountry(country_id)
    {
        for (i = 0; i < maxPages; i++)
        {
            if (pages[i].country_id == country_id)
            {
              page_cur = i+1;
              DisplayPage();
              scroll(pages[i].city_id);
              return;
            }
        } 
    }
    
    function PhotoOn()
    {
      if (active_photos == 1) return;
      
      photo_cur = 1;
      active_photos = 1;

      // hide other containers
      ShowObject("map",0);
      ShowObject("page_s",0);
      ShowObject("button_album",0);
      ShowObject("about",0);
      ShowObject("button_about",0);
      ShowObject("button_photo",0);
      obj = document.getElementById('desc_photo');
      obj.style.width = '700px';
      obj.style.left = '45px';
      obj.style.top = '130px';
      
      // replace image with higher resoluton version
      document.getElementById("img_photo").src = "images/photo1.jpg";

      // animate into larger image      
      new Effect.Morph('photo',{style:{left: '45px', top: '150px', width:'700px', height:'456px'}, delay: 0, duration:1});
      new Effect.Morph('img_photo',{style:{width:'700px', height:'456px'}, delay:0, duration:1});
      
      setTimeout("ShowObject('micro_photo',1);",1100);
      EnableButton('auto_photo',1);
      setTimeout("ShowObject('toolbar_photo',1);",1100);
      setTimeout("ShowObject('desc_photo',1);",1100);
      setTimeout("DisplayPhotoDesc();",1150);
      setTimeout("HighlightPhoto(1,1);",1200);
      ValidatePhotoPriorNextButton();
      
      // preload images
      setTimeout("PreloadPhotos();",50);
    }  
    
    function PhotoOff()
    {
      autoPhoto = 0;
      autoId = 1;
      active_photos = 0;
      ShowObject("micro_photo",0);
      ShowObject("toolbar_photo",0);
      ShowObject("desc_photo",0);
      HighlightPhoto(photo_cur,0);
      
      // animate into smaller image
      new Effect.Morph('photo',{style:{left: '260px', top: '280px', width:'200px', height:'130px'}, delay: 0, duration:1});
      new Effect.Morph('img_photo',{style:{width:'200px', height:'130px'}, delay:0, duration:1});

      // enable other containers
      setTimeout("ShowObject ('map',1);",1100);
      setTimeout("ShowObject ('page_s',1);",1100);
      setTimeout("ShowObject ('button_album',1);",1100);
      setTimeout("ShowObject ('button_about',1);",1100);
      setTimeout("ShowObject ('about',1);",1100);
      setTimeout("ShowObject ('button_photo',1);",1100);
      setTimeout("document.getElementById('img_photo').src = 'images/photo1_s.jpg';",1100);
     }  
    
    function DisplayPhotoDesc()
    {
      document.getElementById("desc_photo").innerText = photos[photo_cur-1].desc;
      document.getElementById("desc_photo").textContent = photos[photo_cur-1].desc;
      ShowObject("desc_photo",1);
    }
     
    function SelectPhoto(id)
    {
      if (id == photo_cur) return;
      HighlightPhoto(photo_cur,0);
      var fileName = photos[id-1].GetPhotoFile();
      SetPhotoOrientation(id);
      changeOpac(0,"img_photo");
      ShowObject('desc_photo',0);
      photo_cur = id;
      document.getElementById("img_photo").src = fileName;
      HighlightPhoto(photo_cur,1);
    } 
    
    function HighlightPhoto(id,state)
    {
      var photoId = photos[id-1].GetPhotoId();
      
      if (state == 1)
      {
         var obj = document.getElementById(photoId).style.borderColor = 'activeBorder';
      }
      else
      {
         var obj = document.getElementById(photoId).style.borderColor = '#2D221C';
      }
    }
    
    function SetPhotoOrientation(id)
    {
     // see if orientation has changed
      if (photos[id-1].orientation != photos[photo_cur-1].orientation)
      {
        if (photos[id-1].orientation == 'v')
        {
            // vertical photo
            var obj = document.getElementById('photo');
            obj.style.left = '330px';
            obj.style.top = '65px';
            obj.style.width = '367px';
            obj.style.height = '550px';
            obj = document.getElementById('img_photo');
            obj.style.width = '367px';
            obj.style.height = '550px';
            // desc
            obj = document.getElementById('desc_photo');
            obj.style.width = '367px';
            obj.style.left = '330px';
            obj.style.top = '45px';
        }
        else 
        {
            // horizontal photo
            var obj = document.getElementById('photo');
            obj.style.left = '45px';
            obj.style.top = '150px';
            obj.style.width = '700px';
            obj.style.height = '456px';
            obj = document.getElementById('img_photo');
            obj.style.width = '700px';
            obj.style.height = '456px';
            // desc
            obj = document.getElementById('desc_photo');
            obj.style.width = '700px';
            obj.style.left = '45px';
            obj.style.top = '130px';
        }
      }     
    }
    
    function AutoPhoto()
    {
      if (autoPhoto == 1)
      {
        if (autoId == 1)
        {
          EnableButton('auto_photo',0);
        }
        SelectPhoto(autoId);
        if (autoId < maxPhotos)
        {
          autoId++;
          setTimeout('AutoPhoto();',4000);
        }
        else
        {
           autoPhoto = 0;
           autoId = 1;
           EnableButton('auto_photo',1);
        }
      }
      else 
      {
        autoId = 1;
        EnableButton('auto_photo',1);
      }
    }
    
    function PriorPhoto()
    {
        if (photo_cur > 0)
        {
          autoPhoto = 0;
          SelectPhoto(photo_cur -1);
        }
    }
    
    function NextPhoto()
    {
        if (photo_cur < maxPhotos)
        {
            autoPhoto = 0;
            SelectPhoto(photo_cur +1);
        }
    }
    
    function ValidatePhotoPriorNextButton()
    {
      if (photo_cur == 1 && photoDisablePrior == 0)
      {
        EnableButton("prior_photo",0);
        photoDisablePrior = 1;
      }
      if (photo_cur != 1 && photoDisablePrior == 1)
      {
        EnableButton("prior_photo",1);
        photoDisablePrior = 0;
      }
      if (photo_cur == maxPhotos && photoDisableNext == 0)
      {
        EnableButton("next_photo",0);
        photoDisableNext = 1;
      }
      if (photo_cur != maxPhotos && photoDisableNext == 1)
      {
        EnableButton("next_photo",1);
        photoDisableNext = 0;
      }
    }
     
    function AboutOn()
    {
      // hide other containers
      ShowObject("map",0);
      ShowObject("page_s",0);
      ShowObject("button_album",0);
      ShowObject("photo",0);
      ShowObject("button_about",0);
      ShowObject("button_photo",0);
      
      // replace image with higher resoluton version
      document.getElementById("img_about").src = "images/about.jpg";

      // animate into larger image      
      new Effect.Morph('about',{style:{left: '35px', top: '150px', width:'700px', height:'456px'}, delay: 0, duration:1});
      new Effect.Morph('img_about',{style:{width:'700px', height:'456px'}, delay:0, duration:1});
      setTimeout("ShowObject('toolbar_about',1);",1100);
      setTimeout("ShowObject('desc_about',1);",1100);
    }  
    
    function AboutOff()
    {
      // animate into smaller image
      ShowObject('toolbar_about',0);
      ShowObject('desc_about',0);
      document.getElementById("img_about").src = "images/about.jpg";
      new Effect.Morph('about',{style:{left: '540px', top: '280px', width:'200px', height:'130px'}, delay: 0, duration:1});
      new Effect.Morph('img_about',{style:{width:'200px', height:'130px'}, delay:0, duration:1});

      // enable other containers
      setTimeout("ShowObject ('map',1);",1100);
      setTimeout("ShowObject ('page_s',1);",1100);
      setTimeout("ShowObject ('button_album',1);",1100);
      setTimeout("ShowObject ('button_about',1);",1100);
      setTimeout("ShowObject ('photo',1);",1100);
      setTimeout("ShowObject ('button_photo',1);",1100);
      setTimeout("document.getElementById('img_about').src = 'images/about_s.jpg';",1100);
    } 
    
    function PreloadAlbum()
    {
      var imagefile;
      
      while(active_album == 1 && preload_album_cur < maxPages)
      {
        imagefile = pages[preload_album_cur].GetPageFile();
        preloadImagesAlbum[preload_album_cur].src = imagefile;
        preload_album_cur++;
      }
    }
    
     function PreloadPhotos()
    {
      var imagefile;
      
      while(active_photos == 1 && preload_photos_cur < maxPhotos)
      {
        imagefile = photos[preload_photos_cur].GetPhotoFile();
        preloadImagesPhotos[preload_photos_cur].src = imagefile;
        preload_photos_cur++;
      }
    }  
