

self.name = "main"; // If you are using frames, change "main" to the name of the frame that the photoalbum is in.

// PpCategory:  Add your new category names.  Be sure to leave in the 'all' category!
PpCategory = new Array("todas", "con_amigos")

MainVar = 0; // Sets up the variable that counts the pictures.
function Fix(DatVal, PicVal, TitVal, CatVal, TxtVal) { // Allows you to use variables for the array instead of numbers.
   this.DatVal = DatVal 
   this.PicVal = PicVal 
   this.TitVal = TitVal 
   this.CatVal = CatVal
   this.TxtVal = TxtVal 
} 
var MainArray = new Array() // Sets up the main array.
// MainArray[MainVar++] = new Fix("date", "picname.jpg", "pic title", "category", "pic description")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/01.jpg", "Bienvenidos ",     "Bienvenidos",   "BIENVENIDOS al Album de FOTOS de Erick Sánchez.")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/02gerardoalfonso_erick.jpg", "con Gerardo Alfonso",  "con_amigos",   "Erick Sánchez con Gerardo Alfonso.")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/03conPedroLuisFerrer.jpg", "con Pedro Luis Ferrer", "con_amigos",   "Erick Sánchez y Pedro Luis Ferrer")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/04ConDiegoCano_ErnestroPostrova_WilliamVivanco.jpg", "con varios",     "con_amigos",   "Erick Sánchez, Diego Cano, Ernesto (Dúo Postrova), William Vivanco ")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/05gieco_erick_diegocano.jpg", "con Gieco",     "con_amigos",   "Erick Sánchez con León Gieco y Diego Cano")
MainArray[MainVar++] = new Fix("13/11/2004",   "./album/06erickyarieldiaz.jpg", "con Ariel Díaz", "con_amigos", "Erick Sánchez y Ariel Díaz")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/07ericksanchezypepeordaz.jpg", "con Pepe Ordás", "con_amigos",    "Erick Sánchez y Pepe Ordás")
MainArray[MainVar++] = new Fix("13/11/2004",   "./album/08ericksanchez_kelvisochoa.jpg", "con Kelvis",     "con_amigos", "Erick Sánchez y Kelvis Ochoa")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/09IhosvanyBernal_MarianaLuna_Erick.jpg", "con Ihosvany y Mariana",        "con_amigos",   "Ihosvany Bernal, Mariana y Erick Sánchez")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/10carloslage_erick_diegocano.jpg", "Lage, Cano y Sánchez",        "con_amigos",   "Carlos Lage, Erick Sánchez y Diego Cano ")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/11Con_Pancho_Amat.jpg", "Pancho Amat y Erick",        "con_amigos",   "Pancho Amat y Erick Sánchez")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/12conpanchoamat049.jpg", "Frank Pancho y Erick",        "con_amigos",   "Frank Delgado, Pancho Amat y Erick Sánchez")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/13conpanchoamat046.jpg", "con Pancho Amat",        "con_amigos",   "Pancho Amat y Erick Sánchez guitarreando")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/14diegocao_vicentefeliu_ericksanchez.jpg", "con Diego Cano y Feliu",        "con_amigos",   "Diego Cano, Vicente Feliú y  Erick Sánchez")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/15fndobecquer_elplatano_ericksanchez.jpg", "con Becquer y el plátano",        "con_amigos",   "Fernando Becquer, el plátano y Erick Sánchez")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/16IhosvanyBernal_ErickSanchez_SamuelAguila.jpg", "con Ihosvany y Samuel Aguila",        "con_amigos",   "Ihosvany Bernal, Erick Sánchez y Samuel Aguila cantando en 7a cuerda")

MainArray[MainVar++] = new Fix("13/11/2004",  "./album/17FrankDelgado_Erick1.jpg", "con Frank",        "con_amigos",   "Erick y Frank tocando zampoñas")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/18FrankDelgado_Erick2.jpg", "con Frank 02",        "con_amigos",   "Frank Delgado con charango y Erick Sánchez con zampoña")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/19FrankDelgado_Erick.jpg", "con Frank 03",        "con_amigos",   "Con Frank Delgado en concierto en Casa de las Américas")
MainArray[MainVar++] = new Fix("13/11/2004",  "./album/20confrankyamiga.jpg", "con Frank y amiga",        "con_amigos",   "Erick Sánchez con Frank Delgado y una amiga")

current = 0; // Sets the current picture being shown to the first one.

ActiveVar = 0; // Sets up the variable that counts the pictures.
var ActiveArray = new Array() // Sets up the active array.
for (loop=0; loop < MainVar; loop++) {
  ActiveArray[ActiveVar++] = new Fix(MainArray[loop].DatVal, MainArray[loop].PicVal, MainArray[loop].TitVal, MainArray[loop].CatVal, MainArray[loop].TxtVal)
}


function FindPic() { // The search for a photo feature.
  TotalFound = 0;
  SearchString = document.PpForm.SearchWord.value;
  SearchString = SearchString.toLowerCase();
  WriteResults = window.open("","resultwindow","height=300, width=300, toolbar=0, status=0, menubar=0, resizable=1, scrollbars=1");
  WriteResults.document.open();
  WriteResults.document.write('<div style="text-align:center; font:8pt verdana">'
    + 'You searched for:<br><i>' + SearchString + '</i><br><b>Results:</b><br>');
  for (loop=0; loop < MainVar ; loop++) {
    Keyword = ActiveArray[loop].TxtVal;
    Keyword = Keyword.toLowerCase();
    URL = ActiveArray[loop].PicVal;
    title = ActiveArray[loop].TitVal;
    title = title.toLowerCase();
    SearchResult = Keyword.indexOf(SearchString);
    SearchResult2 = title.indexOf(SearchString);
    if (SearchResult != "-1" || SearchResult2 != "-1") {
      WriteResults.document.write('<br><a href=javascript:ShowPpPic(' + loop + '); target="main">' + title + '</a>');
      TotalFound++;
    }
  }
  WriteResults.document.write('<p><b>Returned ' + TotalFound + ' results.</b><p><a href="javascript:window.close();">close window</a>');
  WriteResults.document.close();
} 

function NextPpPic() { // Flips to the next photo.
  TotalImages = document.PpForm.PpDropdown.options.length;
  current++;
  if (current>=ActiveVar) current = 0;
  ShowPpPic(current);
}

function PreviousPpPic() { // Flips to the previous photo.
  current--;
  if(current<0) current = ActiveVar - 1;
  ShowPpPic(current);
}

function RandomPpPic() { // Shows a random photo.
  randompic = Math.floor(Math.random()*ActiveVar);
  ShowPpPic(randompic);
}

function RunSlideShow() { // Shuffles the photos in a slide show.
    timerSlideShow = setTimeout("NextPpPic();",document.PpForm.Timer.value*1000)
}

function ShowPpCategory(picked) { // Shows the pictures in that category.
  ActiveArray.length = 0;
  PicList = "<SELECT size=10 style='font:8pt verdana' name='PpDropdown' onChange='ShowPpPic(PpForm.PpDropdown.options.selectedIndex);'>";
  ActiveVar = 0;
  current = 0;
  for (loop=0; loop < MainVar; loop++) {
    if (MainArray[loop].CatVal.toLowerCase() == picked.toLowerCase() || picked == "todas") {
      ActiveArray[ActiveVar++] = new Fix(MainArray[loop].DatVal, MainArray[loop].PicVal, MainArray[loop].TitVal, MainArray[loop].CatVal, MainArray[loop].TxtVal)
     PicList = PicList + "<option value=" + MainArray[loop].PicVal + ">" + MainArray[loop].TitVal + "</option>"; 
	} 
  }
  PicList = PicList + "</select>";
  document.getElementById("PicSpot").innerHTML = PicList;
}

function ShowPpPic(newpic) { // Shows the photo and text on the page.
  current = newpic;
  SelectionBox = document.PpForm.PpDropdown;
  SelectionBox.options[current].selected = true;
  document.getElementById("PpSpot").innerHTML = '<a href=javascript:PpPicRemote("' + ActiveArray[current].PicVal + '");><img name="PicShowing" src=' + ActiveArray[current].PicVal + ' height=200 border=0></a>';
  document.getElementById("Journal").outerHTML = '<div id=journal><br>' + ActiveArray[current].DatVal + '<p style="text-align:justify; text-indent:25px">' + ActiveArray[current].TxtVal + '</div>';
  if (document.PpForm.WhereView[1].checked) {
    timerID = setTimeout("PpPicRemote(ActiveArray[current].PicVal)",1000)
  }
  if (document.PpForm.SelectedMode[0].checked) {
    timerSlideShow = setTimeout("NextPpPic();",document.PpForm.Timer.value*1000)
	NextImage = new Image();
	NextPic = current + 1;
    if (NextPic>=ActiveVar) NextPic = 0;
    NextImage.src = ActiveArray[NextPic].PicVal;
  }
}


function PpPicRemote(picName) { // Pops up the photo in a remote window.
    ShowingImage = new Image();
    ShowingImage.src = picName;
    wid = ShowingImage.width + 50;
    hei = ShowingImage.height + 60;
  if (wid < 30 || hei < 30) {
    wid=650;
    hei=490;
  }
  if (screen.width < wid || screen.height < hei) {
    wid = screen.width - 50;
    hei = screen.height - 50;
  }
  OpenWindow = window.open("", "remoteWin", "resizable=1, scrollbars=1, toolbar=0, left=15, top=10, width=" + wid + ", height=" + hei);
  OpenWindow.document.open();
  OpenWindow.document.write('<html><head><title>' + ActiveArray[current].TitVal + '</title></head>'
    + '<body style="background:url(parchment.jpg); font:8pt verdana; margin:2px"><center>' + ActiveArray[current].DatVal + '<br>'
    + '<img src=' + picName + '><br>' + ActiveArray[current].TxtVal
	+ '<br><a href="javascript:window.close();">close window</a></center></body></html>');
  OpenWindow.document.close();
}

