

function cargarDesplegables(clase, textoMostrar, textoOcultar)
{
	if( !$defined(textoMostrar) ) textoMostrar = 'Ver más';
	if( !$defined(textoOcultar) ) textoOcultar = 'Ocultar';
	if( !$defined(clase) ) clase = 'desplegable';
	$$('.'+clase).each( function( e )
	{
		var boton = crearBoton(textoMostrar);
		boton.inject( e, 'before' );
		boton.addEvent('click', function( evento )
					{
						new Fx.Reveal( e ).toggle();
						intercambiarNombre( boton, textoMostrar, textoOcultar );
					}
		);
		e.dissolve();
	}
	);
}

function cargarDesplegablesPagebreak()
{
	cargarDesplegables('desplegablePagebreak');
}

function crearBoton( etiqueta )
{
	return new Element('a', {
		'html': etiqueta,
		styles: {
			'display': 'block'
		}
	});
}

function intercambiarNombre( objeto, etiqueta1, etiqueta2 )
{
	if( objeto.get('html') == etiqueta1 )
		objeto.set('html', etiqueta2);
	else
		objeto.set('html', etiqueta1);
}

function cargarDesplegablesEspeciales( idEnvolturaBoton, claseObjetivos, textoMostrar, textoOcultar )
{
	if( !$defined(textoMostrar) ) textoMostrar = 'Ver más';
	if( !$defined(textoOcultar) ) textoOcultar = 'Ocultar';
	
	var boton = crearBoton(textoMostrar);
	$(idEnvolturaBoton).grab( boton );
	selectorClaseFormado = '.' + claseObjetivos;
	$$( selectorClaseFormado ).each( function( e )
						{
							e.dissolve();
						}
						);
	
	boton.addEvent('click', function( evento )
					{
						intercambiarNombre( boton, textoMostrar, textoOcultar );
						$$( selectorClaseFormado ).each( function( e )
						{
							new Fx.Reveal( e ).toggle();
							//intercambiarNombre( boton, textoMostrar, textoOcultar );
						}
						);
					}
				);
}
