
var showing = Array();

function toggleSlide(i, elemento, etiqueta,alto, etiquetaMostrar, etiquetaOcultar){
	var alto = '';
	var menu = $(elemento);
	var menu2 = $(elemento+"_1");
	if ( showing[i] ){
		saveHeight = menu.offsetHeight;
      		menu.style.overflow = "hidden";
		new Rico.Effect.SizeAndPosition( menu, null, null, null, 1, 25, 8 );
		$(etiqueta).innerHTML = etiquetaMostrar;
		showing[i] = false;
	}
	else {
		saveHeight = menu2.offsetHeight
		//new Rico.Effect.SizeAndPosition(element, null, null, w, h, duration, steps, options);
		new Rico.Effect.SizeAndPosition( menu, null, null, null, saveHeight, 25, 8, {complete:function() { $(menu).style.overflow = "visible"; }} );
      		$(etiqueta).innerHTML = etiquetaOcultar;
		
		showing[i] = true;
	}

}

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

var Rico = {};
Rico.Effect = {};
Rico.Effect.SizeAndPosition = Class.create();
Rico.Effect.SizeAndPosition.prototype = {

   initialize: function(element, x, y, w, h, duration, steps, options) {
      this.element = $(element);
      this.w = w;
      this.h = h;
      this.duration = duration;
      this.steps    = steps;
      this.options  = arguments[7] || {};

      this.sizeAndPosition();
   },

   sizeAndPosition: function() {
      if (this.isFinished()) {
         if(this.options.complete) this.options.complete(this);
         return;
      }

      if (this.timer)
         clearTimeout(this.timer);

      var stepDuration = Math.round(this.duration/this.steps) ;

      // Get original values: x,y = top left corner;  w,h = width height
      var currentW = this.element.offsetWidth;
      var currentH = this.element.offsetHeight;

      // If values not set, or zero, we do not modify them, and take original as final as well
      this.w = (this.w) ? this.w : currentW;
      this.h = (this.h) ? this.h : currentH;

      // how much do we need to modify our values for each step?
      var difW = this.steps >  0 ? (this.w - currentW)/this.steps : 0;
      var difH = this.steps >  0 ? (this.h - currentH)/this.steps : 0;

      this.resizeBy(difW, difH);

      this.duration -= stepDuration;
      this.steps--;

      this.timer = setTimeout(this.sizeAndPosition.bind(this), stepDuration);
   },

   isFinished: function() {
      return this.steps <= 0;
   },

   resizeBy: function( difW, difH ) {
      var currentWidth  = this.element.offsetWidth;
      var currentHeight = this.element.offsetHeight;
      var intDifW       = parseInt(difW);
      var intDifH       = parseInt(difH);

      var style = this.element.style;
      if ( intDifW != 0 )
         style.width   = (currentWidth  + intDifW) + "px";
      if ( intDifH != 0 )
         style.height  = (currentHeight + intDifH) + "px";
   }
}

