
	YAHOO.widget.Effect = function(el) {
		this.oEl    = YAHOO.util.Dom.get(el);
		this.height = parseInt(YAHOO.util.Dom.getStyle(this.oEl,'height'));
		this.width  = parseInt(YAHOO.util.Dom.getStyle(this.oEl,'width'));
	};

	YAHOO.widget.Effect.prototype.BlindUp = function(iTimer, onComplete) {
		var timer = iTimer || 1;
		this.oEl.style.overflow = 'hidden';
		var blind = new YAHOO.util.Anim(this.oEl, { height: { to:0} }, timer, YAHOO.util.Easing.easeBoth);
		if ( onComplete ) {
			blind.onComplete.subscribe(onComplete);
		}
		blind.animate();
	};

	YAHOO.widget.Effect.prototype.BlindDown = function(iTimer, onComplete) {
		this.oEl.style.visibility = 'hidden';
		this.oEl.style.overflow = 'hidden';
		this.oEl.style.height = '';
		var height = parseInt(YAHOO.util.Dom.getStyle(this.oEl,'height'));
		this.oEl.style.height = '0';
		this.oEl.style.visibility = 'visible';
		var timer = iTimer || 1;
		timer=1;
		var blind = new YAHOO.util.Anim(this.oEl, { height: { to:height, from:0} }, timer, YAHOO.util.Easing.easeBoth );
		if ( onComplete ) {
			blind.onComplete.subscribe(onComplete);
		}
		//blind.onTween.subscribe(frame);
		blind.animate();
	};

  YAHOO.matinee = function() {
		var $D = YAHOO.util.Dom;
		var $E = YAHOO.util.Event;
		var $M = YAHOO.util.Motion;
		var $A = YAHOO.util.Anim;
		var $  = $D.get;
		var $_ = $D.getElementsByClassName;
		return {
			init : function() {
			
        $E.on ($_('leermas'),  'click', this.click , this );
//        $E.on ($_('ampliado'), 'click', this.normalizar , this );
        $E.on ($('normalizar'), 'click', this.normalizar );
//        $E.on ($('desnormalizar'), 'click', this.desnormalizar );
      },
      click : function(e,obj) {
        var valor = new String(this);
        var id = valor.substring( valor.lastIndexOf('#')+1, valor.length);
        YAHOO.matinee.normalizar(e);
        YAHOO.matinee.amplia(e,id);
        return false;
      },
      amplia: function(e,id) {
        o = $('reducido'+id);
        var z = new YAHOO.widget.Effect(o);
  			if ( !$D.hasClass(o,'foo') ) {
  				$D.addClass(o,'foo')
          z.BlindUp();
				}
        $E.stopEvent(e);
        o = $('ampliado'+id);
        var z = new YAHOO.widget.Effect(o);
  			if ( $D.hasClass(o,'foo') ) {
  				$D.removeClass(o,'foo')
          z.BlindDown(1,frame);
				}
				$E.stopEvent(e);
			},
      normalizar : function(e) {
        //Cerramos los ampliados
        obj = $D.getElementsByClassName('ampliado','div');
        for(i=0;i<obj.length;i++){
          var o = obj[i];
          var z = new YAHOO.widget.Effect(o);
  				if ( !$D.hasClass(o,'foo') ) {
  					$D.addClass(o,'foo')
            z.BlindUp();
				  }
          $E.stopEvent(e);
        }
        //Abrimos los reducidos
        obj = $D.getElementsByClassName('reducido','div');
        for(i=0;i<obj.length;i++){
          var o = obj[i];
          var z = new YAHOO.widget.Effect(o);
  				if ( $D.hasClass(o,'foo') ) {
  					$D.removeClass(o,'foo')
  					z.BlindDown(1,frame);
				  }
          $E.stopEvent(e);
        }
	frame();
   	}	
    };
  }();
YAHOO.util.Event.onAvailable('interior', YAHOO.matinee.init, YAHOO.matinee, true);
YAHOO.util.Event.onAvailable('interior', YAHOO.matinee.normalizar, YAHOO.matinee, true);