var gbCurrentFoto = null;
var gbCurrentFotoTienda = null;

var Servicios = {
   
  beforeStart : function() {
		var scroll = new Fx.Scroll('fotos_servicio', {
			wait: false,
			duration: 500,
			offset: {'x': 0, 'y': 0},
			transition: Fx.Transitions.Quad.easeInOut
		});
		scroll.toElement('foto_1');
		$("leyenda").innerHTML = $("foto_1").title;
		gbCurrentFoto = 1;
		$("innerFotos").setStyle('width', (this.fotosQuantity('foto') * 315));
		
		var scroll = new Fx.Scroll('fotos_servicio_tienda', {
			wait: false,
			duration: 500,
			offset: {'x': 0, 'y': 0},
			transition: Fx.Transitions.Quad.easeInOut
		});
		scroll.toElement('fotoTienda_1');
		$("leyendaTienda").innerHTML = $("fotoTienda_1").title;
		gbCurrentFotoTienda = 1;
		$("innerFotosTienda").setStyle('width', (this.fotosQuantity('fotoTienda') * 315));
				
		$("capa_ondulada").setStyles({'top' : -150, 'display' : 'block'});
		$("cortina").setStyles({'top' : -280, 'display' : 'block'});
		$("sol").setStyles({'opacity' : 0, 'display' : 'block'});
		$("styledogs").setStyles({'opacity' : 0, 'display' : 'block'});
		$("escuela").setStyles({'opacity' : 0, 'display' : 'block'});
		$("menubg").setStyles({'width' : 0, 'display' : 'block', 'z-index': '100000'});
		$("menu").setStyles({'width' : 0, 'display' : 'block', 'z-index': '100000'});
		Servicios.preloadImages();
  },
  
  start: function(){
  },
  
  preloadImages : function() {
			var path = Site.getBaseUrl();
			var images = [
				path + 'img/fondo_html.gif',
				path + 'img/transparencia_noticias.png',
				path + 'img/fondo_cabecera.jpg',
				path + 'img/cabecera_1.png',
				path + 'img/cabecera_2.png',
				path + 'img/cabecera_3.png',
				path + 'img/styledogs.png',
				path + 'img/escuela_canina.png',
				path + 'img/foto_carol.png',
				path + 'img/texto_carol.png',
				path + 'img/fondo_introduccion.jpg',
				path + 'img/fondo_noticias.jpg',
				path + 'img/cuadro_noticias.jpg'
				
			];
			new Asset.images(images, { onComplete: function() {
				Servicios.headerAnimation();
			} });
	},

	headerAnimation : function() {
		var fx_capa_ondulada = $("capa_ondulada").effects({duration: 400, transition: Fx.Transitions.Circ.easeOut});
		var fx_cortina = $("cortina").effects({duration: 400, transition: Fx.Transitions.Circ.easeOut});
		var fx_sol = $("sol").effects({duration: 0, transition: Fx.Transitions.Circ.easeOut});
		var fx_menu = $("menu").effects({duration: 500, transition: Fx.Transitions.Circ.easeOut});
		var fx_bgmenu = $("menubg").effects({duration: 500, transition: Fx.Transitions.Circ.easeOut});
		
		
		fx_capa_ondulada.start({'top' : 0}).chain(function() {
			fx_cortina.start({'top' : 0}).chain(function() {
				fx_sol.start({'opacity' : 1});
				var effect = new Fx.Styles($("styledogs"), {'duration' : 500}).start({'opacity' : 1}).chain(function() {
					var effect = new Fx.Styles($("escuela"), {'duration' : 200}).start({'opacity' : 1}).chain(function() {
						fx_bgmenu.start({'width' : 850});
						fx_menu.start({'width' : 850}).chain(function() {
							
						});
					});
				});
				
			});
		});
	},
	
	newsAnimation : function() {
		var effect = new Fx.Styles($("inner_noticias"), {'duration' : 1000}).start({'opacity' : 1});
	},
	
	fotosDarrera : function() {
		var scroll = new Fx.Scroll('fotos_servicio', { wait: false, duration: 500, offset: {'x': 0, 'y': 0}, transition: Fx.Transitions.Quad.easeInOut});
		if (gbCurrentFoto==1) gbCurrentFoto = this.fotosQuantity('foto') + 1;
		gbCurrentFoto--;
		scroll.toElement('foto_' + (gbCurrentFoto));
		$("leyenda").innerHTML = $("foto_" + gbCurrentFoto).title;
	},
	
	fotosDarreraTienda : function() {
		var scroll = new Fx.Scroll('fotos_servicio_tienda', { wait: false, duration: 500, offset: {'x': 0, 'y': 0}, transition: Fx.Transitions.Quad.easeInOut});
		if (gbCurrentFotoTienda==1) gbCurrentFotoTienda = this.fotosQuantity('fotoTienda') + 1;
		gbCurrentFotoTienda--;
		scroll.toElement('fotoTienda_' + (gbCurrentFotoTienda));
		$("leyendaTienda").innerHTML = $("fotoTienda_" + gbCurrentFotoTienda).title;
	},
	
	fotosDavant : function() {
		var scroll = new Fx.Scroll('fotos_servicio', { wait: false, duration: 500, offset: {'x': 0, 'y': 0}, transition: Fx.Transitions.Quad.easeInOut });
		if (gbCurrentFoto == this.fotosQuantity('foto')) gbCurrentFoto = 0;
		gbCurrentFoto++;
		scroll.toElement('foto_' + (gbCurrentFoto));
		$("leyenda").innerHTML = $("foto_" + gbCurrentFoto).title;
	},
	
	fotosDavantTienda : function() {
		var scroll = new Fx.Scroll('fotos_servicio_tienda', { wait: false, duration: 500, offset: {'x': 0, 'y': 0}, transition: Fx.Transitions.Quad.easeInOut });
		if (gbCurrentFotoTienda == this.fotosQuantity('fotoTienda')) gbCurrentFotoTienda = 0;
		gbCurrentFotoTienda++;
		scroll.toElement('fotoTienda_' + (gbCurrentFotoTienda));
		$("leyendaTienda").innerHTML = $("fotoTienda_" + gbCurrentFotoTienda).title;
	},
	
	fotosQuantity : function(whatGallery) {
		var rtnValue = 0;
		looping = true;
		while(looping) {
			if ($(whatGallery + '_' + (rtnValue + 1))) rtnValue++;
				else looping = false;
		}
		
		return rtnValue;
	}
	
  
  
	

};

window.addEvent('domready', function() { Servicios.beforeStart(); });
window.addEvent('load', function() { Servicios.start(); });
