﻿/* Licuit Interactive SL */
/* main.css */
/* Created July, 2009 */
/* Modified July, 2009
--------------------------------------- */

Desplegable = new Class({
		
		options: {},
		mainLayer: null,
		btn: null,
		opened: false,
		fx: null,
		id: "",
		boton: "",
		color: "",
		height: "",
		
		
		initialize: function(){
        },
		
		setup: function(){
			this.mainLayer = $(this.id);
			this.btn = this.mainLayer.getFirst("a");
			this.fx = new Fx.Tween(this.mainLayer,{duration: '300', transition:"sine:out"});

			var tClass = this;
			
			this.btn.addEvent('click', function(){ tClass.toggle(); });
			
			this.height = tClass.getScrollSize();
		},
		
		getScrollSize:function(){			
			var alto = this.mainLayer.scrollHeight;
			return alto;
		},
		
		toggle: function(){
			if(this.opened){
				//Cerrar
				this.fx.start("height", 23);
				$(this.boton).setStyle('backgroundPosition', '0px 0px');
	  			if (this.color != ""){
					$(this.boton).setStyle('color', '#FFFFFF');
				}


			}else{
				//Abrir
				this.fx.start("height", this.height);
				$(this.boton).setStyle('backgroundPosition', '0px -23px');
				if (this.color != ""){
					$(this.boton).setStyle('color', this.color);
				}
				
			}
			
			this.opened = !this.opened;
		}
				
    });



var desplegableCategorias = new Desplegable();
desplegableCategorias.id = "categories";
desplegableCategorias.boton = "categoria";
window.addEvent('domready', function(){desplegableCategorias.setup(); });

var hoy=new Date()
var ano=hoy.getFullYear() 

var desplegables = [];

for (i=2008;i<=ano;i++){
	
	var  obj = new Desplegable();
	obj.id = "filtroFechas"+i;
	obj.boton = "anyo"+i;
	obj.color = "#FF5800";
	
	desplegables.push(obj);	
	
}

window.addEvent('domready', 
				function(){
					for (var i=0; i < desplegables.length; i++){
						desplegables[i].setup();
					}
				});
