var gbCurrentFoto = 1;
var Home = {
   
   
	beforeStart : function() {
         var numFotos = this.fotosQuantity();
         $("innerGaleria").setStyle("width", numFotos * 80 + "px");
         
         var scroll = new Fx.Scroll('galeria_darrers', {
            wait: false,
            duration: 500,
            offset: {'x': 0, 'y': 0},
            transition: Fx.Transitions.Quad.easeInOut
         });
         if ($("foto_1")) scroll.toElement('foto_1');
	},
	
	start: function(){
      	
	},
	
	preloadImages : function() {
			var path = (document.location.href).substring(0, (document.location.href).lastIndexOf("/") +1);
			var images = [

			];
			new Asset.images(images, { 
                onComplete: function() {
                    Site.headerAnimation();
                }
			});
	},
    fotosDarrera : function() {
         var scroll = new Fx.Scroll('galeria_darrers', {
            wait: false,
            duration: 500,
            offset: {'x': 0, 'y': 0},
            transition: Fx.Transitions.Quad.easeInOut
         });
         
         $("text_" + (gbCurrentFoto+1)).setStyle("display","none");
         if (gbCurrentFoto == 0) {
            gbCurrentFoto = this.fotosQuantity() - 1;
            scroll.toRight();
         } else {
            if (gbCurrentFoto == 1) {
                scroll.toLeft();
                gbCurrentFoto = 0;
            } else {
                gbCurrentFoto--;
                scroll.toElement('foto_' + (gbCurrentFoto));
            }
        }
        $("text_" + (gbCurrentFoto+1)).setStyle('display' , 'block');
     },

     fotosDavant : function() {
         var scroll = new Fx.Scroll('galeria_darrers', {
            wait: false,
            duration: 500,
            offset: {'x': 0, 'y': 0},
            transition: Fx.Transitions.Quad.easeInOut
         });
         $("text_" + (gbCurrentFoto+1)).setStyle("display","none");
         if ((gbCurrentFoto+1) == this.fotosQuantity()) {
            gbCurrentFoto = 0;
            scroll.toLeft();
         } else {
            gbCurrentFoto++;
            scroll.toElement('foto_' + (gbCurrentFoto));
        }
        $("text_" + (gbCurrentFoto+1)).setStyle('display' , 'block');
         
     },
     
     fotosQuantity : function() {
        var rtnValue = 0;
        looping = true;
        while(looping) {
            if ($('foto_' + (rtnValue + 1))) rtnValue++;
            else looping = false;
        }

        return rtnValue;
    }
	

};

window.addEvent('domready', function() { Home.beforeStart(); });
window.addEvent('load', function() { Home.start(); });
