// GaleriaClass by mar_cim

function GaleriaClass () {
  
  this.i = 1;
  this.max = 3;
  
  
  this.prev = function() {
    hide = this.i+this.max-1;
    show = hide-this.max;
    i = this.i-1;
    return this.change(hide, show, i);
  }
  
  this.next = function() {
    hide = this.i;
    show = hide+this.max;
    i = this.i+1;
    this.change(hide, show, i);
  }
  
  this.change = function(hide, show, i) {
    if(document.getElementById('galeria_foto_'+show)) {
      $("#galeria_foto_"+hide).hide("slow"); 
      $("#galeria_foto_"+show).show("slow"); 
      //document.getElementById('galeria_foto_'+hide).style.display = 'none';
      //document.getElementById('galeria_foto_'+show).style.display = 'block';
      this.i = i;
      
    }
  }
  
  this.open = function(href) {
    window.open(href, 'foto', 'width=700,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no'); 
  }
  
  this.hideAll = function () {
    document.getElementById('galeria_fotos').style.overflow = 'hidden';
    for(k=1; k<100; ++k) {
      if(document.getElementById('galeria_foto_'+k)) {
        if(k>=this.max+1)
        document.getElementById('galeria_foto_'+k).style.display = 'none';
        document.getElementById('galeria_foto_'+k).href = 'javascript:galeria.open("'+document.getElementById('galeria_foto_'+k).href+'")';
      }
      else {
        return;
      }
    }
  }
  
  this.hideAll();
  
}

var galeria = new GaleriaClass();


