var gSlideData = Array();
gSlideData.push([10010, 0, "Cape Reinga", "Also known as Te Reinga, this cape is one of the most sacred Maori places in New Zealand. Tradition says that the spirits of the dead congregate at Cape Reinga before proceeding to their spiritual home in Hawaiki.", "Claudia N."]);
gSlideData.push([10020, 9, "90 Mile Beach", "90 Mile Beach is a public road.", "Bruce Grant"]);
gSlideData.push([10030, 19, "Beach driving", "90 Mile Beach is approximately 55 miles (88km) long. Go figure.", "Scott Markle"]);
gSlideData.push([10040, 28, "Incoming tide", "90 Mile Beach claims many vehicles, Mercedes Benz included.", "Aftab Uzzaman"]);
gSlideData.push([10060, 38, "Rams-horn shells", "White coiled rams-horn shells are internal shells of a small squid.", "Elaine Wan"]);
gSlideData.push([10070, 47, "Bus trip", "Commercial operators offer rides along 90 Mile Beach to Cape Reinga.", "Sarah Stewart"]);
gSlideData.push([10080, 66, "Awanui", "Church at Awanui.", "Bruce Grant"]);
gSlideData.push([10100, 87, "Cable Bay", "Popular Northland holiday destination.", "Bruce Grant"]);
gSlideData.push([10110, 96, "Mangonui", "The world famous Mangonui fish shop.", "Bruce Grant"]);
gSlideData.push([10120, 105, "Derelict house", "", "Bruce Grant"]);
gSlideData.push([10130, 120, "Whangaroa", "Fishing boats moored in Whangaroa Harbour.", "Bruce Grant"]);
gSlideData.push([10140, 127, "Mataurui Bay", "Rainbow Warrior Memorial. In 1985, the Greenpeace flagship was sunk whilst in Auckland Harbour by operatives of the French intelligence service (DGSE).", "Bruce Grant"]);
gSlideData.push([10150, 148, "Kerikeri", "The Stone Store (left) is New Zealand's oldest stone building (1835). The Mission House (right) is New Zealand's oldest wooden building (1822).", "Henk Bokhoven"]);
gSlideData.push([10170, 177, "Kawakawa", "Public toilets in Kawakawa were designed by Austrian-born painter and sculptor Friedensreich Hundertwasser.", "Bruce Grant"]);
gSlideData.push([10200, 212, "Whangarei Falls", "At Whangarei Falls, the Hatea River drops 26 metres (85 ft) over a basalt lava flow.", "Henk Bokhoven"]);
gSlideData.push([10210, 239, "Ruakaka", "The bay has beautiful sandy white beaches looking out towards the Hen and Chicken Islands and Sail Rock.", "Teresa Rogers-Jenner"]);
gSlideData.push([10220, 266, "Kauri Gum", "Kauri gum was used as a resin in the production of varnish and linoleum. From 1850 to 1950 gum exports totalled 450,000 tons.", ""]);
gSlideData.push([10240, 288, "Puhoi pub", "The Puhoi Pub & Hotel is an historic rural pub established in 1879 by Bohemian settlers.", "Eliska Marvanova"]);
gSlideData.push([10250, 310, "Auckland City", "Auckland City is New Zealand's most populous city with a population of approximately half a million.", "Bruce Grant"]);
gSlideData.push([10260, 317, "Sky Tower", "At 328 metres, the Auckland Sky Tower is the tallest man-made structure in New Zealand.", "Bruce Grant"]);
gSlideData.push([10270, 340, "Manukau City", "Manukau is ethnically diverse, and is home to many cultures, especially Maori and members of Polynesian ethnicities.", "Bruce Grant"]);
gSlideData.push([10300, 354, "Pokeno", "Famous for bacon", "Sarah Macmillan"]);
gSlideData.push([10305, 362, "Huntly Power Station", "The Huntly Power Station is the largest thermal power station in New Zealand and supplies around 17% of the country's power.", "Bruce Grant"]);
gSlideData.push([10320, 376, "Hamilton farm", "New Zealand is the world's eighth largest milk producer, with about 2.2% of world production.", "Sarah Macmillan"]);
gSlideData.push([10330, 390, "Relocating stock", "A moooving road block in the Waikato.", "Bruce Grant"]);
gSlideData.push([10350, 408, "Heifers on a hill", "A heifer is a young cow, typically one that has not yet given birth to a calf.", "Bruce Grant"]);
gSlideData.push([10390, 427, "Cambridge stud", "Cambridge Stud is an internationally known thoroughbred stud farm.", "Sarah Macmillan"]);
gSlideData.push([10400, 443, "Lake Karapiro", "Lake Karapiro is an artificial reservoir on the Waikato River and is regarded as one of New Zealand's best rowing venues.", "Sarah Macmillan"]);
gSlideData.push([10410, 448, "Spraying effluent", "Farm south of Putaruru.", "Bruce Grant"]);
gSlideData.push([10420, 459, "Lichfield", "Fontera is a co-operative that is owned by over 10,500 farmers. The company controls around 30% of the world's dairy exports.", "Bruce Grant"]);
gSlideData.push([10460, 518, "Wairaki", "Geothermal power plants provide approximately 10% of the country's electricity.", "Bruce Grant"]);
gSlideData.push([10480, 524, "Lake Taupo", "Lake Taupo was created by a supervolcanic eruption. The most recent erruption (180 CE) turned the sky red over Rome and China.", "Bruce Grant"]);
gSlideData.push([10520, 535, "Poutu Canal", "Part of the Tongariro hydro-electric power scheme.", "Bruce Grant"]);
gSlideData.push([10530, 542, "Mt Ngauruhoe", "Ngauruhoe, while often regarded as a separate mountain, is geologically a vent of Tongariro.", "Bruce Grant"]);
gSlideData.push([10540, 550, "Mt Tongariro", "Tongariro first erupted about 260,000 years ago. The volcano consists of at least 12 cones.", "Bruce Grant"]);
gSlideData.push([10550, 564, "The Desert Road", "Frequently closed in Winter due to snow, the Desert Road crosses the volcanic Central Plateau.", "Bruce Grant"]);
gSlideData.push([10560, 579, "Mt Ruapehu", "Summer in the Rangipo Desert.", "Bruce Grant"]);
gSlideData.push([10565, 593, "Scottish heather", "The Heather Beetle has been introduced as a bio-control against Scottish Heather growing in the Tongariro National Park", "Bruce Grant"]);
gSlideData.push([10570, 605, "Waiouru", "National Army Museum. In 2007, 96 medals were stolen from the museum but they were returned as a result of a NZ$300,000 reward.", "Val Grant"]);
gSlideData.push([10600, 626, "Taihape", "Gumboot capital of New Zealand.", "Bruce Grant"]);
gSlideData.push([10610, 629, "Brown Sugar Cafe", "Taihape's famous Cafe.", "Bruce Grant"]);
gSlideData.push([10620, 640, "Mangaweka", "DC3 Cafe.", "Bruce Grant"]);
gSlideData.push([10630, 644, "Mangaweka", "Mangaweka hosts the controversial annual Fakes & Forgeries Art Exhibition and Festival.", "Bruce Grant"]);
gSlideData.push([10640, 651, "Rangitikei Valley", "The Rangitikei River is one of New Zealand's longest rivers (185 kilometes long).", "Bruce Grant"]);
gSlideData.push([10650, 655, "Makohine", "The Makohine Railway Viaduct, completed in 1902, was an impressive engineering milestone in the construction of the North Island Main Trunk line.", "Bruce Grant"]);
gSlideData.push([10660, 658, "Vinegar Hill", "Named after an incident in early colonial times - a bullock cart carrying barrels of vinegar overturned after the bullocks slipped on the muddy track on the hillside, covering the hillside in vinegar from the broken barrels.", "Bruce Grant"]);
gSlideData.push([10670, 662, "Hunterville", "The Hunterway dog capital of the world.", "Bruce Grant"]);
gSlideData.push([10680, 665, "Shearing Shed", "North of Marton", "Bruce Grant"]);
gSlideData.push([10690, 673, "Farm buildings", "Storage for hay bales near Marton.", "Bruce Grant"]);
gSlideData.push([10710, 684, "Welcome to Bulls", "An Unforget-a-Bull town like no udder", "Bruce Grant"]);
gSlideData.push([10720, 686, "Ohakea", "Landing lights at Ohakea airbase.", "Bruce Grant"]);
gSlideData.push([10730, 689, "Sanson", "Manawatu rugby grandstand", "Val Grant"]);
gSlideData.push([10740, 694, "Hay bales", "South of Sanson", "Bruce Grant"]);
gSlideData.push([10750, 702, "Field of maize", "Oroua Downs", "Bruce Grant"]);
gSlideData.push([10760, 709, "North & South", "Himatangi, West of Palmerston North", "Bruce Grant"]);
gSlideData.push([10780, 711, "Foxton shops", "Foxton has a history of flax stripping. The fibres were used to make rope, baskets and other tools.", "Bruce Grant"]);
gSlideData.push([10800, 716, "Manawatu River", "The river's name comes from the Maori words manawa (heart, spirit) and tu (stand still, or depressed), therefore heart standing still with fear, or depressed spirit.", "Bruce Grant"]);
gSlideData.push([10820, 725, "Levin", "Levin is the largest town in the Horowhenua district.", "Bruce Grant"]);
gSlideData.push([10830, 738, "Otaki", "Roadside fruit and veg", "Bruce Grant"]);
gSlideData.push([10835, 752, "Sweetcorn", "South of Levin", "Bruce Grant"]);
gSlideData.push([10900, 764, "Paekakariki", "Paekakariki Railway Station (pronounced pie-cock-ah-reek-y)", "Bruce Grant"]);
gSlideData.push([10910, 770, "Kapiti Coast", "Home to the Kapiti Island nature and marine reserves.", "Bruce Grant"]);
gSlideData.push([10960, 774, "Gorse", "Hill slopes and riverbeds that are golden with flowering gorse are a familiar sight in the Wellington region.", "Bruce Grant"]);
gSlideData.push([10970, 779, "Porirua", "1950's-era state houses.", "Bruce Grant"]);
gSlideData.push([10980, 788, "Suburban train", "South of Porirua", "Bruce Grant"]);
gSlideData.push([10990, 794, "Wellington", "The Beehive is the common name for the Executive Wing of the New Zealand Parliament Buildings.", "Guto Rhys"]);
gSlideData.push([11000, 796, "Marlborough Sounds", "The total coastline of the Marlborough Sounds has 1/5th of the length of New Zealand's coasts.", "Alexandra Hemmer"]);
gSlideData.push([11040, 810, "Picton", "Roll-on / Roll-off ferry terminal", "Bruce Grant"]);
gSlideData.push([11050, 830, "Blenheim", "Cherry Orchid", "Bruce Grant"]);
gSlideData.push([11060, 856, "Lake Grassmere", "The saltworks at Lake Grassmere have evaporation ponds that turn pink in summer, caused by an alga that accumulates a red pigment.", "Bruce Grant"]);
gSlideData.push([11070, 880, "Kekerengu", "East coast beach", "Bruce Grant"]);
gSlideData.push([11080, 900, "Waipapa Bay", "Crayfish country (no, it's not real).", "Bruce Grant"]);
gSlideData.push([11190, 912, "Kaikoura Coast", "The name 'Kaikoura' translates to 'meal of crayfish' ('kai'- food/meal, 'koura' - crayfish)", "Bruce Grant"]);
gSlideData.push([11200, 924, "Whale Watching", "Sperm Whales are the worlds' largest carnivore. They dive 2km into the dark abyss of the Kaikoura Canyon to hunt prey such as the Giant Squid.", "Bruce Grant"]);
gSlideData.push([11210, 953, "Kaikoura Ranges", "Kaikoura is a special place of lush pastures and towering, snow covered peaks that fall to the sea.", ""]);
gSlideData.push([11220, 978, "Dusky Dolphins", "Large pods of dophins are a conmmon sight off the Kaikoura coast.", "Bruce Grant"]);
gSlideData.push([11225, 1004, "Hanmer Springs", "Cyclist near Hanmer Springs.", ""]);
gSlideData.push([11227, 1028, "Waimakariri River", "The Waimakariri River flows for 151 kilometres from the Southern Alps across the Canterbury Plains to the Pacific Ocean.", "Bruce Grant"]);
gSlideData.push([11230, 1054, "Christchurch", "Cathedral Square in the centre of Christchurch.", "Bruce Grant"]);
gSlideData.push([11250, 1092, "Rakaia", "The Rakaia River crosses the Canterbury Plains and is a celebrated salmon fishery.", "Bruce Grant"]);
gSlideData.push([11260, 1135, "Canterbury Plains", "During summer, a very warm wind known locally as the Nor'wester can blow for days on end across the Canterbury Plains.", "Bruce Grant"]);
gSlideData.push([11270, 1174, "Foothills near Fairlie", "Commonly known as the gateway to the Mackenzie Basin, Fairlie hosts the annual Mackenzie District Agricultural and Pastoral show every Easter Monday.", "Bruce Grant"]);
gSlideData.push([11280, 1188, "Tree House", "Burkes Pass", "Bruce Grant"]);
gSlideData.push([11290, 1206, "McKenzie Country", "Folk hero James Mckenzie was imprissioned in 1855 for stealing 1,000 sheep. He was given an unconditional pardon in 1856, but not before escaping from prison on at least two occasions.", "Bruce Grant"]);
gSlideData.push([11300, 1213, "Lake Tekapo", "Church of the Good Shepherd Lake Tekapo (without 30 tourist busses parked outside).", "Bruce Grant"]);
gSlideData.push([11310, 1225, "Lake Pukaki", "Lake Pukaki and Aoraki, Mt Cook.", "Bruce Grant"]);
gSlideData.push([11320, 1235, "Tasman Glacier", "Dangerous route at Tasman Glacier", "Bruce Grant"]);
gSlideData.push([11330, 1245, "Aoraki, Mt Cook", "Aoraki/Mount Cook is the highest mountain in New Zealand (3,754 metres). In 1991, an avalanche of 10 million cubic metres of snow and rock caused 10 metres to be lost off the top.", "Bruce Grant"]);
gSlideData.push([11340, 1256, "Twizel", "Hydroelectric Memorial at Twizel. Hydroelectric power accounts for 70% of the total primary energy usage in New Zealand.", "Bruce Grant"]);
gSlideData.push([11350, 1264, "Salmon Farm", "A unique form of freshwater salmon farming has been developed in hydroelectric canals in the Mackenzie Basin.", "Bruce Grant"]);
gSlideData.push([11360, 1272, "Road to Omarama", "Omarama is Maori for 'Place of Light', a reference to its extraordinarily pure and clear sky, which also makes it of great interest to astronomers and gliding enthusiasts.", "Bruce Grant"]);
gSlideData.push([11365, 1279, "Omarama", "Quirky roadside rock stacks made by visitors to Omarama.", "Bruce Grant"]);
gSlideData.push([11370, 1295, "Benmore", "The earth dam of the Benmore Hydroelectric Power Station is the largest earth-filled water-retaining structure in New Zealand.", "Bruce Grant"]);
gSlideData.push([11375, 1317, "Central Otago", "Roadside fruit stall", "Bruce Grant"]);
gSlideData.push([11380, 1337, "Rock formations", "Central Otago rock formations", "Bruce Grant"]);
gSlideData.push([11385, 1352, "Waitaki Valley", "According to Lonely Planet, these charcoal-and-ochre paintings date back several centuries, tracing everything from pre-European hunting to sailing ships, as well as tributes to the ancient god Supergroove.", "Bruce Grant"]);
gSlideData.push([11390, 1364, "Oamaru", "Buildings made from Oamaru stone", "Bruce Grant"]);
gSlideData.push([11400, 1384, "Moeraki Boulders", "Created by wave action, the Moeraki Boulders are unusually large and spherical boulders lying along a stretch of Koekohe Beach on the Otago coast.", "Bruce Grant"]);
gSlideData.push([11410, 1404, "Shag Point", "New Zealand Fur Seals were widely hunted from shortly after the European discovery of New Zealand until the late 19th Century.", "Bruce Grant"]);
gSlideData.push([11430, 1423, "Shoe fence", "North of Dunedin. Like the once famous Cadrona bra fence... but with shoes.", "Bruce Grant"]);
gSlideData.push([11440, 1441, "Dunedin", "Scarfie town, the second largest city in the South Island.", "Bruce Grant"]);
gSlideData.push([11445, 1474, "Taieri Plains", "Phil, the programmer behind R2B lives here. The other guy lives in Auckland.", "Bruce Grant"]);
gSlideData.push([11450, 1501, "Balclutha", "", "Bruce Grant"]);
gSlideData.push([11460, 1518, "Nugget Point", "The point is home to many seabirds, including penguins, gannets and spoonbills, and a large breeding colony of fur seals.", "Bruce Grant"]);
gSlideData.push([11470, 1541, "Catlins coast", "There is nothing remotely like this place. It's remote.", "Bruce Grant"]);
gSlideData.push([11475, 1567, "Fossilised Forest", "A petrified forest, 180 million years old, is revealed at low tide at Curio Bay", "Bruce Grant"]);
gSlideData.push([11480, 1600, "Bluff", "CONGRATULATIONS !!! You have completed the 1600km walk from Cape Reinga to Bluff. Thanks for taking part in the R2B walking challenge. We really hope you enjoyed it.", "Bruce Grant"]);
var kMaxImages = 107;

var kCtrlFirst = 0;
var kCtrlLast = 1;
var kCtrlPrev = 2;
var kCtrlNext = 3;
var kCtrlImageDir = "assets/";
var kCtrlImagesEnabled = Array("slidefirstenabled.gif", "slidelastenabled.gif", "slideprevenabled.gif", "slidenextenabled.gif");
var kCtrlImagesDisabled = Array("slidefirstdisabled.gif", "slidelastdisabled.gif", "slideprevdisabled.gif", "slidenextdisabled.gif");
var kSlideDir = "assets/slides/";
var kDefaultImage = "default.jpg";
var gSlideNum = 0;
var gThumbNum = 0;

function EnableNextCtrl() {
  var ctrlHtml = document.getElementById('nextslidectrl');
  if(ctrlHtml)
    ctrlHtml.innerHTML = "<A HREF=\"JavaScript:NextSlide();\"><IMG SRC=\""+ kCtrlImageDir+ kCtrlImagesEnabled[kCtrlNext]+"\" BORDER=0>";
}

function DisableNextCtrl() {
  var ctrlHtml = document.getElementById('nextslidectrl');
  if(ctrlHtml)
    ctrlHtml.innerHTML = "<IMG SRC="+ kCtrlImageDir+ kCtrlImagesDisabled[kCtrlNext]+">";
}

function EnablePrevCtrl() {
  var ctrlHtml = document.getElementById('prevslidectrl');
  if(ctrlHtml)
    ctrlHtml.innerHTML = "<A HREF=\"JavaScript:PrevSlide();\"><IMG SRC=\""+ kCtrlImageDir+ kCtrlImagesEnabled[kCtrlPrev]+"\" BORDER=0>";
}

function DisablePrevCtrl() {
  var ctrlHtml = document.getElementById('prevslidectrl');
  if(ctrlHtml)
    ctrlHtml.innerHTML = "<IMG SRC="+ kCtrlImageDir+ kCtrlImagesDisabled[kCtrlPrev]+">";
}


function EnableNextThumbCtrl() {
  var ctrlHtml = document.getElementById('nextthumbctrl');
  if(ctrlHtml)
    ctrlHtml.innerHTML = "<A HREF=\"JavaScript:NextThumbnail();\"><IMG SRC=\""+ kCtrlImageDir+ kCtrlImagesEnabled[kCtrlNext]+"\" BORDER=0>";
}

function DisableNextThumbCtrl() {
  var ctrlHtml = document.getElementById('nextthumbctrl');
  if(ctrlHtml)
    ctrlHtml.innerHTML = "<IMG SRC="+ kCtrlImageDir+ kCtrlImagesDisabled[kCtrlNext]+">";
}

function EnablePrevThumbCtrl() {
  var ctrlHtml = document.getElementById('prevthumbctrl');
  if(ctrlHtml)
    ctrlHtml.innerHTML = "<A HREF=\"JavaScript:PrevThumbnail();\"><IMG SRC=\""+ kCtrlImageDir+ kCtrlImagesEnabled[kCtrlPrev]+"\" BORDER=0>";
}

function DisablePrevThumbCtrl() {
  var ctrlHtml = document.getElementById('prevthumbctrl');
  if(ctrlHtml)
    ctrlHtml.innerHTML = "<IMG SRC="+ kCtrlImageDir+ kCtrlImagesDisabled[kCtrlPrev]+">";
}


function NextSlide() {
  if(gSlideNum+1 > kMaxImages)
    return;

  gSlideNum++;  
  DisplaySlide(gSlideNum);
}

function PrevSlide() {
  if(gSlideNum-1 < 0)
    return;

  gSlideNum--;  
  DisplaySlide(gSlideNum);
}
  
function NextThumbnail() {
  if(gThumbNum+1 > kMaxImages)
    return;

  gThumbNum++;  
  DisplayThumbnail(gThumbNum);
}


function PrevThumbnail() {
  if(gThumbNum-1 < 0)
    return;

  gThumbNum--;  
  DisplayThumbnail(gThumbNum);
}
  
  

function DisplaySlide(slideNum) {
  gSlideNum = slideNum;
  
  // image
  var slideImage = document.getElementById('slideimage');
  if(slideImage.src)
    slideImage.src = kSlideDir + GetSlideImageId(slideNum) + ".jpg";
  
  // title
  var slideTitle = document.getElementById('slidetitle');
  if(slideTitle)
    slideTitle.innerHTML = GetSlideTitle(slideNum);

  // caption
  var slideCaption = document.getElementById('slidecaption');
  if(slideCaption)
    slideCaption.innerHTML = GetSlideCaption(slideNum);

  // distance
  var slideDistance = document.getElementById('slidedistance');
  if(slideDistance)
    slideDistance.innerHTML = GetSlideDistance(slideNum);

  // credit
  var slideCredit = document.getElementById('slidecredit');
  if(slideCredit)
    slideCredit.innerHTML = GetSlideCredit(slideNum);
    
  // update controls
  if(gSlideNum <= 0)
    DisablePrevCtrl();
  else
    EnablePrevCtrl();
  if(gSlideNum+1 >= kMaxImages)
    DisableNextCtrl();
  else
    EnableNextCtrl();
}
  
  
function DisplayThumbnail(slideNum) {
  gThumbNum = slideNum;
  
  // image
  var thumbImage = document.getElementById('thumbimage');
  if(thumbImage.src)
    thumbImage.src = kSlideDir + GetSlideImageId(slideNum) + ".jpg";
  
  // title
  var thumbTitle = document.getElementById('thumbtitle');
  if(thumbTitle)
    thumbTitle.innerHTML = GetSlideTitle(slideNum);

  // update controls
  if(gThumbNum <= 0)
    DisablePrevThumbCtrl();
  else
    EnablePrevThumbCtrl();
  if(gThumbNum+1 >= kMaxImages)
    DisableNextThumbCtrl();
  else
    EnableNextThumbCtrl();
}
  

function GetSlideImageId(slideNum) {
  return gSlideData[slideNum][0];
}

function GetSlideDistance(slideNum) {
  return gSlideData[slideNum][1];
}

function GetSlideTitle(slideNum) {
  return gSlideData[slideNum][2];
}

function GetSlideCaption(slideNum) {
  return gSlideData[slideNum][3];
}

function GetSlideCredit(slideNum) {
  return gSlideData[slideNum][4];
}

function GetCurrentSlide(distance) {
  var found = false;  
  for(i=0; i < gSlideData.length; i++) {
    if(distance == GetSlideDistance(i))
      return i;
    if(distance <= GetSlideDistance(i))
      return i-1;
  }
  
  return gSlideData.length-1;
}

function ShowLightBox(slideNum) {
  DisplaySlide(slideNum);
  document.getElementById('lightbox').style.display='block';
  var dateSelect = document.getElementById('dateselect');
  if(dateSelect) {
    dateSelect.style.display='none';
    dateSelect.style.visiblity='hidden';
  }
}
  
function HideLightBox() {
  var dateSelect = document.getElementById('dateselect');
  if(dateSelect) {
    dateSelect.style.display='block';
    dateSelect.style.visiblity='visible';
  }
  document.getElementById('lightbox').style.display='none';
} 
     
