var galleriesName = new Array();
var galleriesGroupCount = new Array();
var groupsDescription = new Array();
var groupsImageCount = new Array();
var imagesDescription = new Array();
var imagesWidth = new Array();
var imagesHeight = new Array();

function showGalleryName() {
  var galleryNumber = "";
  var qs = location.search.substr(1).split("=");
  if (qs[0] == "gal")
    galleryNumber = qs[1];
  else if (qs[0] == "img")
    galleryNumber = qs[1].substr(0,2);
  if (galleryNumber != "")
    document.write(galleriesName[galleryNumber]);
}

function showGallery() {
  var qs = location.search.substr(1).split("=");
  if (qs[0] == "gal")
    showGalleryImages(qs[1]);
  else if (qs[0] == "img")
    showGalleryImage(qs[1]);
  else
    location.href = "index.htm";
}

function showGalleryImage(imageName) {
  document.write("<table align=\"center\"><tr><td colspan=\"5\" style=\"text-align:center\">")
  showImageNavigationLinks(imageName);
  document.write("<br><span class=\"bold\">" + imagesDescription[imageName] + "</span>")
  document.write("</td></tr><tr>")
  document.write("<td style=\"text-align:center\">");
  document.write("<img src=\"images/galeria/g" + imageName + ".jpg\" style=\"border: double 3px #990000;\">")
  document.write("</td>");
  document.write("</tr></table>");
  document.close();
}

function showGalleryImages(galleryNumber) {
  var i, j;
  var imageNumber, groupNumber;
  showGalleryNavigationLinks(galleryNumber);
  for (i = 1; i <= galleriesGroupCount[galleryNumber]; i++) {
    if (i < 10) groupNumber = "0"; else groupNumber = "";
    groupNumber = groupNumber + i;
    document.write("<table align=\"center\"><tr><td colspan=\"5\" style=\"text-align:center\">")
	document.write("<span class=\"bold\">" + groupsDescription[galleryNumber + groupNumber] + "</span></td></tr><tr>")
    for (j = 1; j <= groupsImageCount[galleryNumber + groupNumber]; j++) {
      if (j < 10) imageNumber = "0"; else imageNumber = "";
      imageNumber = imageNumber + j;
	  document.write("<td style=\"text-align:center\">");
      showImageLink(galleryNumber, groupNumber, imageNumber);
	  document.write("</td>");
      if (j % 5 == 0) document.write("</tr><tr>");
    }
    document.write("</tr></table>");
  }
  document.close();
}

function showImageLink(gallery, group, image) {
  document.write("<a href=\"gallery.htm?img=" + gallery + group + image + "\">")
  document.write("<img src=\"images/galeria/p" + gallery + group + image + ".jpg\" ");
  document.write("alt=\"" + imagesDescription[gallery + group + image] + "\" ");
  //document.write("width=\"80\" height=\"80\" class=\"foto\">");
  document.write("class=\"foto\">");
  document.write("<br>" + imagesDescription[gallery + group + image] + "</a>");
}

function getGalleryNumber(imageName) {
  return imageName.substr(0,2);
}

function getGroupNumber(imageName) {
  return imageName.substr(2,2);
}

function getImageNumber(imageName) {
  return imageName.substr(4,2);
}

function formatInt(number, sizeIncludingLeadingZeros) {
  var value = new String(number);
  while (value.length < sizeIncludingLeadingZeros) {
    value = "0" + value;
  }
  return value;
}

function showGalleryNavigationLinks(gallery) {
  var prevGallery = "";
  var nextGallery = "";
  if (parseInt(gallery, 10) > 1) {
	prevGallery = formatInt(parseInt(gallery, 10) - 1, 2);
  }
  if (parseInt(gallery, 10) < galleriesCount) {
    nextGallery = formatInt(parseInt(gallery, 10) + 1, 2);
  }
  document.write("<div align=\"center\"><a href=\"");
  if (prevGallery != "")
    document.write("gallery.htm?gal=" + prevGallery + "\" title=\"" + galleriesName[prevGallery]);
  else
    document.write("#\" style=\"color:Black; cursor:default;");
  document.write("\">[ << Anterior ]</a>");

  document.write(" · <a href=\"galeria.htm\"> [ Volver a la lista ] </a> · ");

  document.write("<a href=\"");
  if (nextGallery != "")
    document.write("gallery.htm?gal=" + nextGallery + "\" title=\"" + galleriesName[nextGallery]);
  else
    document.write("#\" style=\"color:Black; cursor:default;");
  document.write("\">[ Siguiente >> ]</a></div>");
}

function showImageNavigationLinks(imageName) {
  var gallery = getGalleryNumber(imageName);
  var group = getGroupNumber(imageName);
  var image = getImageNumber(imageName);
  var prevImageName = "";
  var nextImageName = "";
  if (parseInt(image, 10) > 1) { // imagen anterior del mismo grupo
	prevImageName = gallery + group + formatInt(parseInt(image, 10) - 1, 2);
  } else {
    if (parseInt(group, 10) > 1) { // última imagen del grupo anterior
	  prevImageName = gallery + formatInt(parseInt(group, 10) - 1, 2) +
	                  formatInt(groupsImageCount[gallery + formatInt(parseInt(group, 10) - 1, 2)], 2);
	}
  }
  if (parseInt(image, 10) < groupsImageCount[gallery + group]) { // imagen siguiente del mismo grupo
    nextImageName = gallery + group + formatInt(parseInt(image, 10) + 1, 2);
  } else {
    if (parseInt(group, 10) < galleriesGroupCount[gallery]) { // primera imagen del grupo siguiente
      nextImageName = gallery + formatInt(parseInt(group, 10) + 1, 2) + "01";
	}
  }

  document.write("<div align=\"center\"><a href=\"");
  if (prevImageName != "")
    document.write("gallery.htm?img=" + prevImageName + "\" title=\"" + imagesDescription[prevImageName]);
  else
    document.write("#\" style=\"color:Black; cursor:default;");
  document.write("\">[ << Anterior ]</a>");

  document.write(" · <a href=\"gallery.htm?gal=" + imageName.substr(0,2) + "\"> [ Volver a la galería ] </a> · ");

  document.write("<a href=\"");
  if (nextImageName != "")
    document.write("gallery.htm?img=" + nextImageName + "\" title=\"" + imagesDescription[nextImageName]);
  else
    document.write("#\" style=\"color:Black; cursor:default;");
  document.write("\">[ Siguiente >> ]</a></div>");
}

var galleriesCount = 13;

galleriesName["01"] = "III Trofeo de Baile Deportivo Vila d'Alaquàs";
galleriesGroupCount["01"] = 1;
groupsDescription["0101"] = "Algunas de las parejas de nuestro club"
groupsImageCount["0101"] = 24;
imagesDescription["010101"] = "Ramón y Rosa";
imagesDescription["010102"] = "José Julián y Carla";
imagesDescription["010103"] = "Victor y Nadia";
imagesDescription["010104"] = "Roberto y Sonia";
imagesDescription["010105"] = "Ramón y Rosa";
imagesDescription["010106"] = "Alberto y Andrea";
imagesDescription["010107"] = "Demetrio e Isabel";
imagesDescription["010108"] = "Sergio y Belén";
imagesDescription["010109"] = "Raúl y Laura";
imagesDescription["010110"] = "Dani y Ainhoa";
imagesDescription["010111"] = "Carles y Yana";
imagesDescription["010112"] = "Jesús y Gloria";
imagesDescription["010113"] = "Demetrio e Isabel";
imagesDescription["010114"] = "Juan y Gema";
imagesDescription["010115"] = "Victor y Julia";
imagesDescription["010116"] = "Alberto y Andrea";
imagesDescription["010117"] = "Christian y Estrella";
imagesDescription["010118"] = "José Julián y Carla";
imagesDescription["010119"] = "Juan Ramón y Paqui";
imagesDescription["010120"] = "Antonio y Loli";
imagesDescription["010121"] = "Alfonso y Verónica";
imagesDescription["010122"] = "Carles y Yana";
imagesDescription["010123"] = "Dani y Ainhoa";
imagesDescription["010124"] = "Raúl y Laura";

galleriesName["02"] = "Batalla en el PaintBall de Benicassim";
galleriesGroupCount["02"] = 3;
groupsDescription["0201"] = "El escuadrón al completo se prepara para el combate";
groupsDescription["0202"] = "Imágenes inéditas en primera línea del conflicto bélico";
groupsDescription["0203"] = "Las consecuencias de la batalla";
groupsImageCount["0201"] = 4;
groupsImageCount["0202"] = 4;
groupsImageCount["0203"] = 2;
imagesDescription["020101"] = "Salida desde Alaquàs";
imagesDescription["020102"] = "Equipados para la guerra";
imagesDescription["020103"] = "Comprobando los equipos";
imagesDescription["020104"] = "Nacidos para la gloria";
imagesDescription["020201"] = "Preparados...listos...ya";
imagesDescription["020202"] = "Esperando al enemigo";
imagesDescription["020203"] = "Recargando munición";
imagesDescription["020204"] = "No te escondas, que te veo";
imagesDescription["020301"] = "Marcas de guerra";
imagesDescription["020302"] = "La última bala";

galleriesName["03"] = "IV Trofeo de Baile Deportivo Vila d'Alaquàs";
galleriesGroupCount["03"] = 3;
groupsDescription["0301"] = "La competición";
groupsDescription["0302"] = "Algunas parejas del C.B.D. Alaquàs";
groupsDescription["0303"] = "Más parejas";
groupsImageCount["0301"] = 5;
groupsImageCount["0302"] = 9;
groupsImageCount["0303"] = 20;
imagesDescription["030101"] = "La preparación";
imagesDescription["030102"] = "Los jueces";
imagesDescription["030103"] = "El baile";
imagesDescription["030104"] = "La espera";
imagesDescription["030105"] = "Los trofeos";
imagesDescription["030201"] = "Christian y Mónica";
imagesDescription["030202"] = "Victor y Julia";
imagesDescription["030203"] = "Victor y Julia";
imagesDescription["030204"] = "Juan Ramón y Paqui";
imagesDescription["030205"] = "Gonzalo y Perla";
imagesDescription["030206"] = "Jesús y Gloria";
imagesDescription["030207"] = "Carles y Yana";
imagesDescription["030208"] = "Carles y Yana";
imagesDescription["030209"] = "Sasha y Amagoya";
imagesDescription["030301"] = "";
imagesDescription["030302"] = "";
imagesDescription["030303"] = "";
imagesDescription["030304"] = "";
imagesDescription["030305"] = "";
imagesDescription["030306"] = "";
imagesDescription["030307"] = "";
imagesDescription["030308"] = "";
imagesDescription["030309"] = "";
imagesDescription["030310"] = "";
imagesDescription["030311"] = "";
imagesDescription["030312"] = "";
imagesDescription["030313"] = "";
imagesDescription["030314"] = "";
imagesDescription["030315"] = "";
imagesDescription["030316"] = "";
imagesDescription["030317"] = "";
imagesDescription["030318"] = "";
imagesDescription["030319"] = "";
imagesDescription["030320"] = "";

galleriesName["04"] = "Nuestro club en el Campeonato de España de Latino 2005";
galleriesGroupCount["04"] = 4;
groupsDescription["0401"] = "CATEGORÍA ADULTO";
groupsDescription["0402"] = "CATEGORÍA YOUTH";
groupsDescription["0403"] = "CATEGORÍA SENIOR";
groupsDescription["0404"] = "CATEGORÍA JUNIOR";
groupsImageCount["0401"] = 5;
groupsImageCount["0402"] = 3;
groupsImageCount["0403"] = 1;
groupsImageCount["0404"] = 1;
imagesDescription["040101"] = "Sasha y Amagoya";
imagesDescription["040102"] = "Sasha y Amagoya";
imagesDescription["040103"] = "Sasha y Amagoya";
imagesDescription["040104"] = "Javi y Joanna";
imagesDescription["040105"] = "Miguel y Azahara";
imagesDescription["040201"] = "Carles y Yana";
imagesDescription["040202"] = "Juanma y Carolina";
imagesDescription["040203"] = "Jose Pedro y María";
imagesDescription["040301"] = "Jose Mª e Inma";
imagesDescription["040401"] = "Victor y Raquel";

galleriesName["05"] = "Talleres de peinado y maquillaje";
galleriesGroupCount["05"] = 1;
groupsDescription["0501"] = "";
groupsImageCount["0501"] = 15;
imagesDescription["050101"] = "";
imagesDescription["050102"] = "";
imagesDescription["050103"] = "";
imagesDescription["050104"] = "";
imagesDescription["050105"] = "";
imagesDescription["050106"] = "";
imagesDescription["050107"] = "";
imagesDescription["050108"] = "";
imagesDescription["050109"] = "";
imagesDescription["050110"] = "";
imagesDescription["050111"] = "";
imagesDescription["050112"] = "";
imagesDescription["050113"] = "";
imagesDescription["050114"] = "";
imagesDescription["050115"] = "";

galleriesName["06"] = "Campamento de Verano 2005 C.B.D. Alaquàs";
galleriesGroupCount["06"] = 7;
groupsDescription["0601"] = "El deporte y el entorno";
groupsDescription["0602"] = "Los entrenamientos";
groupsDescription["0603"] = "La piscina";
groupsDescription["0604"] = "Las comidas";
groupsDescription["0605"] = "El relax";
groupsDescription["0606"] = "La gran cena";
groupsDescription["0607"] = "La fiesta final";
groupsImageCount["0601"] = 4;
groupsImageCount["0602"] = 6;
groupsImageCount["0603"] = 6;
groupsImageCount["0604"] = 10;
groupsImageCount["0605"] = 3;
groupsImageCount["0606"] = 4;
groupsImageCount["0607"] = 7;
imagesDescription["060101"] = "";
imagesDescription["060102"] = "";
imagesDescription["060103"] = "";
imagesDescription["060104"] = "";
imagesDescription["060201"] = "";
imagesDescription["060202"] = "";
imagesDescription["060203"] = "";
imagesDescription["060204"] = "";
imagesDescription["060205"] = "";
imagesDescription["060206"] = "";
imagesDescription["060301"] = "";
imagesDescription["060302"] = "";
imagesDescription["060303"] = "";
imagesDescription["060304"] = "";
imagesDescription["060305"] = "";
imagesDescription["060306"] = "";
imagesDescription["060401"] = "";
imagesDescription["060402"] = "";
imagesDescription["060403"] = "";
imagesDescription["060404"] = "";
imagesDescription["060405"] = "";
imagesDescription["060406"] = "";
imagesDescription["060407"] = "";
imagesDescription["060408"] = "";
imagesDescription["060409"] = "";
imagesDescription["060410"] = "";
imagesDescription["060501"] = "";
imagesDescription["060502"] = "";
imagesDescription["060503"] = "";
imagesDescription["060601"] = "";
imagesDescription["060602"] = "";
imagesDescription["060603"] = "";
imagesDescription["060604"] = "";
imagesDescription["060701"] = "";
imagesDescription["060702"] = "";
imagesDescription["060703"] = "";
imagesDescription["060704"] = "";
imagesDescription["060705"] = "";
imagesDescription["060706"] = "";
imagesDescription["060707"] = "";


galleriesName["07"] = "German Open Championship 2005";
galleriesGroupCount["07"] = 4;
groupsDescription["0701"] = "GOC 2005 - Profesional Standard";
groupsDescription["0702"] = "GOC 2005 - Profesional Latino";
groupsDescription["0703"] = "GOC 2005 - Amateur Standard";
groupsDescription["0704"] = "GOC 2005 - Amateur Latino";
groupsImageCount["0701"] = 5;
groupsImageCount["0702"] = 5;
groupsImageCount["0703"] = 5;
groupsImageCount["0704"] = 5;
imagesDescription["070101"] = "";
imagesDescription["070102"] = "";
imagesDescription["070103"] = "";
imagesDescription["070104"] = "";
imagesDescription["070105"] = "";
imagesDescription["070201"] = "";
imagesDescription["070202"] = "";
imagesDescription["070203"] = "";
imagesDescription["070204"] = "";
imagesDescription["070205"] = "";
imagesDescription["070301"] = "";
imagesDescription["070302"] = "";
imagesDescription["070303"] = "";
imagesDescription["070304"] = "";
imagesDescription["070305"] = "";
imagesDescription["070401"] = "";
imagesDescription["070402"] = "";
imagesDescription["070403"] = "";
imagesDescription["070404"] = "";
imagesDescription["070405"] = "";

galleriesName["08"] = "V Trofeo de Baile Deportivo Vila d'Alaquàs";
galleriesGroupCount["08"] = 3;
groupsDescription["0801"] = "La competición";
groupsDescription["0802"] = "Algunas parejas del C.B.D. Alaquàs";
groupsDescription["0803"] = "Más parejas";
groupsImageCount["0801"] = 4;
groupsImageCount["0802"] = 16;
groupsImageCount["0803"] = 18;
imagesDescription["080101"] = "Los participantes";
imagesDescription["080102"] = "Los jueces";
imagesDescription["080103"] = "La organización";
imagesDescription["080104"] = "El espectáculo";
imagesDescription["080201"] = "Carles y Yana";
imagesDescription["080202"] = "Pablo y Joanna";
imagesDescription["080203"] = "Sergio y María";
imagesDescription["080204"] = "Jose Pedro y María";
imagesDescription["080205"] = "Sergio y Belén";
imagesDescription["080206"] = "Deme e Isabel";
imagesDescription["080207"] = "Victor y Julia";
imagesDescription["080208"] = "Alfonso y Tatiana";
imagesDescription["080209"] = "Jesús y Gloria";
imagesDescription["080210"] = "Juan Ramón y Paqui";
imagesDescription["080211"] = "Carles y Yana";
imagesDescription["080212"] = "Jose Pedro y María";
imagesDescription["080213"] = "Victor y Raquel";
imagesDescription["080214"] = "Deme e Isabel";
imagesDescription["080215"] = "Joaquín y Puri";
imagesDescription["080216"] = "Paco y Fina";
imagesDescription["080301"] = "";
imagesDescription["080302"] = "";
imagesDescription["080303"] = "";
imagesDescription["080304"] = "";
imagesDescription["080305"] = "";
imagesDescription["080306"] = "";
imagesDescription["080307"] = "";
imagesDescription["080308"] = "";
imagesDescription["080309"] = "";
imagesDescription["080310"] = "";
imagesDescription["080311"] = "";
imagesDescription["080312"] = "";
imagesDescription["080313"] = "";
imagesDescription["080314"] = "";
imagesDescription["080315"] = "";
imagesDescription["080316"] = "";
imagesDescription["080317"] = "";
imagesDescription["080318"] = "";

galleriesName["09"] = "VII Trofeo de Baile Deportivo Vila d'Alaquàs";
galleriesGroupCount["09"] = 1;
groupsDescription["0901"] = "";
groupsImageCount["0901"] = 13;
imagesDescription["090101"] = "";
imagesDescription["090102"] = "";
imagesDescription["090103"] = "";
imagesDescription["090104"] = "";
imagesDescription["090105"] = "";
imagesDescription["090106"] = "";
imagesDescription["090107"] = "";
imagesDescription["090108"] = "";
imagesDescription["090109"] = "";
imagesDescription["090110"] = "";
imagesDescription["090111"] = "";
imagesDescription["090112"] = "";
imagesDescription["090113"] = "";

galleriesName["10"] = "Fiesta de Verano del C.B.D. Alaquàs";
galleriesGroupCount["10"] = 1;
groupsDescription["1001"] = "";
groupsImageCount["1001"] = 29;
imagesDescription["100101"] = "";
imagesDescription["100102"] = "";
imagesDescription["100103"] = "";
imagesDescription["100104"] = "";
imagesDescription["100105"] = "";
imagesDescription["100106"] = "";
imagesDescription["100107"] = "";
imagesDescription["100108"] = "";
imagesDescription["100109"] = "";
imagesDescription["100110"] = "";
imagesDescription["100111"] = "";
imagesDescription["100112"] = "";
imagesDescription["100113"] = "";
imagesDescription["100114"] = "";
imagesDescription["100115"] = "";
imagesDescription["100116"] = "";
imagesDescription["100117"] = "";
imagesDescription["100118"] = "";
imagesDescription["100119"] = "";
imagesDescription["100120"] = "";
imagesDescription["100121"] = "";
imagesDescription["100122"] = "";
imagesDescription["100123"] = "";
imagesDescription["100124"] = "";
imagesDescription["100125"] = "";
imagesDescription["100126"] = "";
imagesDescription["100127"] = "";
imagesDescription["100128"] = "";
imagesDescription["100129"] = "";

galleriesName["11"] = "Participantes del CBD en Campeonatos 2009";
galleriesGroupCount["11"] = 1;
groupsDescription["1101"] = "";
groupsImageCount["1101"] = 11;
imagesDescription["110101"] = "David y Claudia";
imagesDescription["110102"] = "Victor y Vanesa";
imagesDescription["110103"] = "Victor y Vanesa";
imagesDescription["110104"] = "Nestor y Sonia";
imagesDescription["110105"] = "Nestor y Sonia";
imagesDescription["110106"] = "Sergio y Paula";
imagesDescription["110107"] = "Jaime y Reyes";
imagesDescription["110108"] = "Sergio y Belén";
imagesDescription["110109"] = "Sergio y Belén";
imagesDescription["110110"] = "Sebastián y Merche";
imagesDescription["110111"] = "Juan Ramón y Paqui";

galleriesName["12"] = "Campamento de Verano 2009 C.B.D. Alaquàs";
galleriesGroupCount["12"] = 1;
groupsDescription["1201"] = "";
groupsImageCount["1201"] = 21;
imagesDescription["120101"] = "";
imagesDescription["120102"] = "";
imagesDescription["120103"] = "";
imagesDescription["120104"] = "";
imagesDescription["120105"] = "";
imagesDescription["120106"] = "";
imagesDescription["120107"] = "";
imagesDescription["120108"] = "";
imagesDescription["120109"] = "";
imagesDescription["120110"] = "";
imagesDescription["120111"] = "";
imagesDescription["120112"] = "";
imagesDescription["120113"] = "";
imagesDescription["120114"] = "";
imagesDescription["120115"] = "";
imagesDescription["120116"] = "";
imagesDescription["120117"] = "";
imagesDescription["120118"] = "";
imagesDescription["120119"] = "";
imagesDescription["120120"] = "";
imagesDescription["120121"] = "";

galleriesName["13"] = "Exhibición Fiestas Alaquàs 2009";
galleriesGroupCount["13"] = 1;
groupsDescription["1301"] = "";
groupsImageCount["1301"] = 33;
imagesDescription["130101"] = "";
imagesDescription["130102"] = "";
imagesDescription["130103"] = "";
imagesDescription["130104"] = "";
imagesDescription["130105"] = "";
imagesDescription["130106"] = "";
imagesDescription["130107"] = "";
imagesDescription["130108"] = "";
imagesDescription["130109"] = "";
imagesDescription["130110"] = "";
imagesDescription["130111"] = "";
imagesDescription["130112"] = "";
imagesDescription["130113"] = "";
imagesDescription["130114"] = "";
imagesDescription["130115"] = "";
imagesDescription["130116"] = "";
imagesDescription["130117"] = "";
imagesDescription["130118"] = "";
imagesDescription["130119"] = "";
imagesDescription["130120"] = "";
imagesDescription["130121"] = "";
imagesDescription["130122"] = "";
imagesDescription["130123"] = "";
imagesDescription["130124"] = "";
imagesDescription["130125"] = "";
imagesDescription["130126"] = "";
imagesDescription["130127"] = "";
imagesDescription["130128"] = "";
imagesDescription["130129"] = "";
imagesDescription["130130"] = "";
imagesDescription["130131"] = "";
imagesDescription["130132"] = "";
imagesDescription["130133"] = "";

