//globals
var PictureCategories = new Array("All", "Resort", "Rooms", "Banquet_Rooms", "Royal_Palm_Spa", "Trader_Vics")
var PictureCount = 0;
var PictureArray = new Array()
var current = 0;
var CountPics = 0;
var ActiveArray = new Array();
var i = 0;

//prototype for a Picture
function Picture(PicVal, TitVal, CatVal) {
   this.PicVal = PicVal
   this.TitVal = TitVal
   this.CatVal = CatVal
}

PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/1.JPG", "Welcome Sign", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/2.JPG", "From the Air", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/3.JPG", "Playground", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/4.JPG", "Pool at Sunset", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/5.JPG", "Island in the Pool", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/6.JPG", "Resort East Tower", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/7.JPG", "Palm Trees", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/8.JPG", "Waterfall in the Pool", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/9.JPG", "More Palm Trees", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/10.JPG", "Resort West Tower", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/11.JPG", "Pool Deck", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/12.JPG", "Patio Bar", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/13.JPG", "Resort Concourse", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/14.JPG", "Bridges over the main Pool", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/15.JPG", "Resort Refreshments", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/19.JPG", "Outside From Above", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/16.JPG", "Outside From Above", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/18.JPG", "Tennis and Basketball Courts", "Resort")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/Resort/20.JPG", "Jacquizi", "Resort")

PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/1.JPG", "Bed Room", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/3.JPG", "Dining Area", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/5.JPG", "Kitchen", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/6.JPG", "Master Bed Room", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/7.JPG", "Bedroom Flat Screen", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/8.JPG", "Washer and Dryer", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/10.JPG", "Main Flat Screen TV", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/16.JPG", "Living Area", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/25.JPG", "Living Area", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/26.JPG", "Kitchen", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/28.JPG", "Bed Room", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/32.JPG", "Living Area", "Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/2BR/34.JPG", "Pool View", "Rooms")

PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/RPS/1.JPG", "Entrance", "Royal_Palm_Spa")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/RPS/2.JPG", "Salon", "Royal_Palm_Spa")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/RPS/3.JPG", "Chairs", "Royal_Palm_Spa")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/RPS/16.JPG", "Reception Area", "Royal_Palm_Spa")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/RPS/18.JPG", "Massage", "Royal_Palm_Spa")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/RPS/26.JPG", "Fitness Equipment", "Royal_Palm_Spa")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/RPS/28.JPG", "Treadmills", "Royal_Palm_Spa")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/RPS/29.JPG", "Cycles", "Royal_Palm_Spa")

PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/28.JPG", "Lounge Area", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/2.JPG", "Blick Oven", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/3.JPG", "Table for Four", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/4.JPG", "Patio", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/5.JPG", "Patio", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/6.JPG", "Patio", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/7.JPG", "Patio Stage", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/9.JPG", "Place Settings", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/10.JPG", "Bar", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/12.JPG", "Bar", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/14.JPG", "Patio Bar", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/22.JPG", "Dining Room", "Trader_Vics")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/TV/29.JPG", "Dining Room", "Trader_Vics")

PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/1.JPG", "Main Hall Side View", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/2.JPG", "Main Hall Center View", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/3.JPG", "Main Hall Cross View", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/4.JPG", "Breakout (Round Table Setup)", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/5.JPG", "Breakout (Round Table Setup)", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/10.JPG", "Breakout (Round Table Setup)", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/6.JPG", "Breakout (Lecture Setup)", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/7.JPG", "Breakout (Lecture Setup)", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/8.JPG", "Breakout (Lecture Setup)", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/11.JPG", "Breakout (Lecture Setup)", "Banquet_Rooms")
PictureArray[PictureCount++] = new Picture("http://destinpalmsselect.com/gfx/pods/BQR/9.JPG", "Breakout Room Waiting Area", "Banquet_Rooms")



for (var picCount=0; picCount < PictureCount; picCount++) {
  ActiveArray[CountPics++] = new Picture(PictureArray[picCount].PicVal, PictureArray[picCount].TitVal, PictureArray[picCount].CatVal)
}

function DisplayCategories() {
  for (var i=0; i < PictureCategories.length; i++)  {
    document.write("<option value=" + PictureCategories[i] + ">" + ReplaceChars(PictureCategories[i]) + "</option>");
  }
}


function LoadPiclist() { // Loads initial list of pictures on web page.
  for (i=0; i < PictureCount; i++)  {
    document.write("<option value=" + ActiveArray[i].PicVal + ">" + ActiveArray[i].TitVal + "</option>");
  }
}

function LoadNextPic()  { // Loads next picture for faster operation.
	NextImage = new Image();
	NextPic = current + 1;
    if (NextPic>=CountPics) NextPic = 0;
    NextImage.src = ActiveArray[NextPic].PicVal;
}

function NextPic() {
  current++;
  if (current>=CountPics) current = 0;
  ShowPic(current);
}

function PreviousPic() { // Flips to the previous photo.
  current--;
  if(current<0) current = CountPics - 1;
  ShowPic(current);
}

function ReplaceChars(entry) { // Replaces the _'s in cat names to make it pretty.
  out = "_"; // replace this
  add = " "; // with this
  temp = "" + entry; // temporary holder
  while (temp.indexOf(out)>-1) {
    pos= temp.indexOf(out);
    temp = "" + (temp.substring(0, pos) + add +
    temp.substring((pos + out.length), temp.length));
  }
return temp;
// document.subform.text.value = temp;
}

function ShowPictureCategories(picked) { // Shows the pictures in that category.
  ActiveArray.length = 0;
  PicList = "<SELECT size=10 style='width:200px; font:12pt Tahoma' name='TitleDropdown' onChange='ShowPic(document.forms[1].TitleDropdown.options.selectedIndex);'>";
  CountPics = 0;
  current = 0;
  for (i=0; i < PictureCount; i++) {
    if (PictureArray[i].CatVal == picked || picked == "All") {
      ActiveArray[CountPics++] = new Picture(PictureArray[i].PicVal, PictureArray[i].TitVal, PictureArray[i].CatVal)
     PicList = PicList + "<option value=" + PictureArray[i].PicVal + ">" + PictureArray[i].TitVal + "</option>";
	}
  }
  PicList = PicList + "</select>";
  document.getElementById("PicSpot").innerHTML = PicList;
}

function ShowPic(newpic) { // Shows the photo and text on the page.
  current = newpic;
  SelectionBox = document.forms[1].TitleDropdown;
  SelectionBox.options[current].selected = true;
  document.getElementById("Spot").innerHTML = '<img name="PicShowing" src=' + ActiveArray[current].PicVal + ' height=330 border=0>';
}

